-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsharpTechStore.cs
More file actions
42 lines (35 loc) · 1.07 KB
/
Copy pathcsharpTechStore.cs
File metadata and controls
42 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
namespace TechStore.Models
{
public class Product
{
public int Id { get; set; }
[Required(ErrorMessage = "El nombre del producto es obligatorio.")]
public string Name { get; set; }
public string Description { get; set; }
[Required(ErrorMessage = "El precio del producto es obligatorio.")]
[Range(0.01, double.MaxValue, ErrorMessage = "El precio debe ser mayor que cero.")]
public decimal Price { get; set; }
public decimal IGV => Price * 0.18m; // Calcula el IGV como el 18% del precio
}
}
using Microsoft.AspNetCore.Mvc;
using TechStore.Models;
namespace TechStore.Controllers
{
public class ProductController : Controller
{
public IActionResult Add()
{
return View();
}
[HttpPost]
public IActionResult Add(Product product)
{
if (ModelState.IsValid)
{
return RedirectToAction("Index", "Home");
}
return View(product);
}
}
}