Пример #1
0
        public ActionResult Edit(IEnumerable <JsonEditViewModel> products)
        {
            //Токен тут
            ValidateRequestHeader(Request);
            if (products == null || products.Count() == 0)
            {
                return(new EmptyResult());
            }

            var _products = GetProductsAll();

            foreach (var item in products)
            {
                Product product = _products.FirstOrDefault(p => p.Id == Convert.ToInt32(item.Id));
                if (product == null)
                {
                    continue;
                }
                else
                {
                    JsonUpdateDbProduct(item, product);
                    db.Entry(product).State = EntityState.Modified;
                }
            }
            db.SaveChanges();
            return(new EmptyResult());
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,Name")] WarehouseEditViewModel warehouse)
 {
     if (ModelState.IsValid)
     {
         var editWarehouse = db.Warehouses.Find(warehouse.Id);
         EditWarehouse(editWarehouse, warehouse);
         db.Entry(editWarehouse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(warehouse));
 }
Пример #3
0
 public ActionResult Edit(CategoryEditViewModel categoryView)
 {
     //categoryView.Categories = Helpers.GetCategories(db.Categories.Include(c => c.Description));
     if (ModelState.IsValid)
     {
         var category = db.Categories.Include(c => c.Description).ToList().FirstOrDefault(c => c.Id == categoryView.Id);
         EditCategory(category, categoryView);
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoryView));
 }
 public void Post(int id, [FromBody] Product product)
 {
     _db.Products.Attach(product);
     _db.Entry(product).State = EntityState.Modified;
     _db.SaveChanges();
 }