public IHttpResponse Edit(UpdateDeleteProductInputModel model)
        {
            var product = this.Db.Products.FirstOrDefault(x => x.Id == model.Id);

            if (product == null)
            {
                return(this.BadRequestError(String.Format(Constants.NotFoundedProduct, model.Id)));
            }

            product.Barcode = model.Barcode;
            product.Picture = model.Picture;
            product.Name    = model.Name;
            product.Price   = model.Price;

            this.Db.SaveChanges();

            return(this.Redirect("/Products/ProductsAll"));
        }
        public IHttpResponse Edit(UpdateDeleteProductInputModel model)
        {
            var product = this.Db.Products.FirstOrDefault(x => x.Id == model.Id);

            if (product == null)
            {
                return(this.BadRequestError("Product not found."));
            }

            if (!Enum.TryParse(model.Type, out ProductType type))
            {
                return(this.BadRequestError("Invalid product type."));
            }

            product.Type        = type;
            product.Description = model.Description;
            product.Name        = model.Name;
            product.Price       = model.Price;

            this.Db.SaveChanges();

            return(this.Redirect("/Products/Details?id=" + product.Id));
        }