Ejemplo n.º 1
0
        public IActionResult Update(int id)
        {
            Data.Services.ProductServices productServices = new Data.Services.ProductServices();
            var entity = productServices.GetById(id);

            return(View(entity));
        }
Ejemplo n.º 2
0
        public IActionResult List()
        {
            Data.Services.ProductServices productServices = new Data.Services.ProductServices();
            var result = productServices.GetAll();

            return(View(result));
        }
Ejemplo n.º 3
0
        public IActionResult Create(ProductModel model)
        {
            Data.Services.ProductServices productServices = new Data.Services.ProductServices();

            var entity = new Product()
            {
                Name        = model.Name,
                Price       = model.Price,
                Descriprion = model.Descriprion,
                Image       = model.Image
            };

            productServices.AddProduct(entity);

            return(RedirectToAction("List"));
        }
Ejemplo n.º 4
0
        public IActionResult Update(Product model)
        {
            Data.Services.ProductServices productServices = new Data.Services.ProductServices();
            var entity = productServices.GetById(model.Id);

            if (entity == null)
            {
                return(NotFound());
            }

            entity.Name        = model.Name;
            entity.Price       = model.Price;
            entity.Descriprion = model.Descriprion;
            entity.Image       = model.Image;

            productServices.UpdateProduct(entity);

            return(RedirectToAction("List"));
        }
Ejemplo n.º 5
0
 public IActionResult Delete(int id)
 {
     Data.Services.ProductServices productServices = new Data.Services.ProductServices();
     productServices.DeleteProduct(id);
     return(RedirectToAction("List"));
 }