Exemplo n.º 1
0
        public JsonResult UpdateResourceAllocations(UpdateResourcesViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { success = false }, JsonRequestBehavior.DenyGet));
            }

            var ts = new TerritoryService();

            ts.UpdateResourceAllocations(this.UserContext.TerritoryId.Value, vm.WaterAllocation, vm.WoodAllocation
                                         , vm.FoodAllocation, vm.StoneAllocation, vm.OilAllocation, vm.IronAllocation);
            try
            {
                ts.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(Json(new { success = true }, JsonRequestBehavior.DenyGet));
        }