Documentation Index
Fetch the complete documentation index at: https://mintlify.com/interezante456-pixel/nuevo-proyecto-viernes/llms.txt
Use this file to discover all available pages before exploring further.
ProductoController manages the product catalog for Tienda Mi Cholo. It provides a paginated, searchable product list accessible to all authenticated users, along with create, edit, delete, and status-toggle operations restricted to the Administrador and Gerente roles. The controller carries [ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)] and a class-level [Authorize] attribute, so every action requires a valid login session. Products maintain a boolean Estado flag that controls visibility in the sale form’s product search — only products with Estado = true and Stock > 0 appear in GET /Venta/BuscarProductos.
Actions
GET /Producto/Lista
Returns a paginated, optionally filtered list of all products, each with itsCategoria eagerly loaded, ordered by ID_Producto ascending.
Authorization: Any authenticated user (all roles).
Optional search string. When provided, filters products whose
NombreProducto or Descripcion contains the value (case-insensitive SQL LIKE). Whitespace-only values are ignored.Page number to display. Defaults to
1. If the requested page exceeds the total number of pages, the controller clamps it to the last valid page.Page size is fixed at 15 records per page. The controller computes the offset with
Skip((pagina - 1) * 15).Take(15). Pagination metadata (PaginaActual, TotalPaginas, TotalRegistros, PageSize) is passed to the view via ViewBag.List<Producto> and can build pager links using ViewBag.TotalPaginas and the current buscar value preserved in ViewBag.Buscar.
GET /Producto/Nuevo
Displays the new-product creation form. PopulatesViewBag.Categorias with all categories from the database so the form can render a category dropdown.
Authorization: Administrador, Gerente.
POST /Producto/Nuevo
Validates and persists a new product. Enforces that the sale price is not lower than the purchase price before accepting the model. SetsEstado = true on all newly created products regardless of what the form submits.
Authorization: Administrador, Gerente.
Model-bound
Producto object. Key fields:NombreProducto— product name (nvarchar(100)).Descripcion— product description (nvarchar(200), nullable after migration 3).PrecioCompra— purchase cost (decimal(10,2)).PrecioVenta— selling price (decimal(10,2)). Must be ≥PrecioCompra.Stock— initial stock quantity (int).Categoria_ID— foreign key toCategorias.
GET /Producto/Lista.
GET /Producto/Editar/
Loads an existing product into the edit form. Fetches the product byID_Producto and populates ViewBag.Categorias for the category dropdown.
Authorization: Administrador, Gerente.
Primary key (
ID_Producto) of the product to edit.POST /Producto/Editar
Validates and saves changes to an existing product. Applies the samePrecioVenta ≥ PrecioCompra rule as the create action.
Authorization: Administrador, Gerente.
Full model-bound
Producto object including the existing ID_Producto. All fields are updated via _context.Productos.Update(producto).GET /Producto/Lista.
GET /Producto/Eliminar/
Permanently removes a product from the database (hard delete) and redirects to the product list. Authorization:Administrador, Gerente.
Primary key (
ID_Producto) of the product to delete.GET /Producto/Lista.
POST /Producto/CambiarEstado/
Toggles theEstado boolean on a product — active products (Estado = true) become inactive, and inactive products become active. This is the recommended way to hide a product from the sale form without deleting it.
Authorization: Administrador, Gerente.
Primary key (
ID_Producto) of the product whose status should be toggled.GET /Producto/Lista.