Exemple #1
0
        public JsonResult SaveDataInDatabase(WarehouseVM model)
        {
            var result = false;

            try
            {
                if (model.IDWareHouse > 0)
                {
                    WareHouse warehouse = db.WareHouses.SingleOrDefault(x => x.IDWareHouse == model.IDWareHouse);
                    warehouse.Address = model.Address;
                    warehouse.Amount  = model.Amount;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    WareHouse warehouse = new WareHouse();
                    warehouse.Address = model.Address;
                    warehouse.Amount  = model.Amount;

                    db.WareHouses.Add(warehouse);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 private void UpdateSelectedWarehouse(WarehouseVM oldSelectedWarehouse)
 {
     if (oldSelectedWarehouse == null)
     {
         return;
     }
     SelectedWarehouse = oldSelectedWarehouse;
 }
 private void UpdateSelectedWarehouse(WarehouseVM oldSelectedWarehouse)
 {
     if (oldSelectedWarehouse == null) return;
     SelectedWarehouse = oldSelectedWarehouse;
 }