예제 #1
0
 public ActionResult Create([Bind(Include = "Id,Name")] WarehouseCreateViewModel warehouse)
 {
     if (ModelState.IsValid)
     {
         var newWarehouse = CreateWarehouse(warehouse);
         db.Warehouses.Add(newWarehouse);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(warehouse));
 }
예제 #2
0
 public ActionResult Create(CategoryCreateViewModel category)
 {
     ViewBag.Categories = Helpers.GetCategories(db.Categories.Include(c => c.Description));
     if (ModelState.IsValid)
     {
         var newCategory = CreateCategory(category);
         db.Categories.Add(newCategory);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
예제 #3
0
        public ActionResult Create(CreateViewModel product)
        {
            CommonDropDownList();
            if (ModelState.IsValid)
            {
                var dbProduct = new Product();
                CreateDbProduct(product, dbProduct);
                db.Products.Add(dbProduct);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
예제 #4
0
        public OrderDto Post([FromBody] OrderDto order)
        {
            var entity = order.ToOrder();

            db.Orders.Add(entity);
            db.ChangeTracker.Entries <Product>().ToList().ForEach(p => p.State = EntityState.Unchanged);
            db.SaveChanges();

            order.Id = entity.Id;
            return(order);
        }
 public void Post(int id, [FromBody] Product product)
 {
     _db.Products.Attach(product);
     _db.Entry(product).State = EntityState.Modified;
     _db.SaveChanges();
 }