Prueba2
This commit is contained in:
parent
bc07e3ebd9
commit
2582de76ff
@ -284,7 +284,6 @@ namespace WebVentaCoche.Controllers
|
|||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
return RedirectToAction(nameof(Index));
|
return RedirectToAction(nameof(Index));
|
||||||
|
|
||||||
// Si hay errores, los mostramos
|
|
||||||
foreach (var e in result.Errors)
|
foreach (var e in result.Errors)
|
||||||
ModelState.AddModelError("", e.Description);
|
ModelState.AddModelError("", e.Description);
|
||||||
return View(model);
|
return View(model);
|
||||||
|
|||||||
@ -26,10 +26,8 @@
|
|||||||
value="@Model.Price.ToString(System.Globalization.CultureInfo.InvariantCulture)"
|
value="@Model.Price.ToString(System.Globalization.CultureInfo.InvariantCulture)"
|
||||||
step="0.01" required />
|
step="0.01" required />
|
||||||
</div>
|
</div>
|
||||||
<!-- Botón Guardar -->
|
|
||||||
<button type="button" id="updateProduct" class="btn btn-primary mt-3">Guardar</button>
|
<button type="button" id="updateProduct" class="btn btn-primary mt-3">Guardar</button>
|
||||||
|
|
||||||
<!-- Botón Volver a la lista -->
|
|
||||||
<div class="text-right mt-3">
|
<div class="text-right mt-3">
|
||||||
<a href="/Admin/Products" class="btn btn-secondary">Volver a la lista</a>
|
<a href="/Admin/Products" class="btn btn-secondary">Volver a la lista</a>
|
||||||
</div>
|
</div>
|
||||||
@ -44,14 +42,13 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
const productId = @Model.Id;
|
const productId = @Model.Id;
|
||||||
|
|
||||||
// PUT: Actualizar producto
|
|
||||||
$('#updateProduct').click(function () {
|
$('#updateProduct').click(function () {
|
||||||
const updatedProduct = {
|
const updatedProduct = {
|
||||||
id: productId,
|
id: productId,
|
||||||
name: $('#Name').val(),
|
name: $('#Name').val(),
|
||||||
shortDescription: $('#ShortDescription').val(),
|
shortDescription: $('#ShortDescription').val(),
|
||||||
longDescription: $('#LongDescription').val(),
|
longDescription: $('#LongDescription').val(),
|
||||||
price: parseFloat($('#Price').val()) // Asegúrate de que sea un número
|
price: parseFloat($('#Price').val())
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -69,7 +66,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// DELETE: Eliminar producto
|
|
||||||
$('#deleteProduct').click(function () {
|
$('#deleteProduct').click(function () {
|
||||||
if (confirm('¿Estás seguro de que deseas eliminar este producto?')) {
|
if (confirm('¿Estás seguro de que deseas eliminar este producto?')) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user