public ActionResult Update(string key, List <spView_WebTemplate_TBGetAll_Result> changed, List <spView_WebTemplate_TBGetAll_Result> added, List <spView_WebTemplate_TBGetAll_Result> deleted) { Formulas formulas = new Formulas(); var order_no = TempData.Peek("OrderNumber").ToString(); OrderTBModels obj = new OrderTBModels(); ////Performing update operation if (changed != null && changed.Count() > 0) { foreach (var temp in changed) { obj.OrderNumber = order_no; //obj.StartDate = System.Convert.ToDateTime(temp.StartDate); //obj.EndDate = System.Convert.ToDateTime(temp.EndDate); //obj.FacilityCode = System.Convert.ToInt32(temp.FacilityCode); obj.ProductCode = System.Convert.ToInt32(temp.ProductCode); obj.OpeningBalance = temp.OpeningBalance; obj.QtyRecieved = temp.QtyRecieved; obj.Dispensed2MonthsReview = temp.Dispensed2MonthsReview; obj.DaysOutofStock = temp.DaysOutofStock; obj.ClosingBalance = temp.ClosingBalance; obj.LossesAndAdjustments = temp.LossesAndAdjustments; obj.AdjustedAMC = ((temp.Dispensed2MonthsReview * 30) / (60 - temp.DaysOutofStock)); obj.MonthsOfStock = ((temp.ClosingBalance) / (temp.AdjustedAMC)); obj.QuantityRequired = Convert.ToDouble(formulas.Allocated((4 * (temp.AdjustedAMC)) - (temp.ClosingBalance))); // obj.MaximumStockQuantity = (2 * temp.QuantityUsedDuringTwoMonths); obj.Comments = temp.Comments; obj.Quantity_Allocated = Convert.ToDouble(formulas.Allocated((temp.QuantityRequired))); obj.RFSONotes = temp.RFSONotes; obj.Update(); } } //Performing delete operation //if (deleted != null && deleted.Count() > 0) //{ // foreach (var temp in deleted) // { // db.core_householdmember.Remove(db.core_householdmember.FirstOrDefault(o => o.id == temp.id)); // } //} //db.SaveChanges(); //var data = 0; return Json(data, JsonRequestBehavior.AllowGet); var data = 0; return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateCustom(string key, List <spView_WebTemplate_TB_GetAll_Custom_Result> changed, List <spView_WebTemplate_TB_GetAll_Custom_Result> added, List <spView_WebTemplate_TB_GetAll_Custom_Result> deleted) { var order_no = TempData.Peek("OrderNumber").ToString(); OrderTBModels obj = new OrderTBModels(); ////Performing update operation if (added != null && added.Count() > 0) { foreach (var temp in added) { obj.OrderNumber = order_no; obj.ProductCode = System.Convert.ToInt32(temp.product_code); obj.QuantityRequired = temp.QuantityRequired; obj.Comments = temp.Comments; obj.Quantity_Allocated = temp.QuantityRequired; obj.RFSONotes = temp.RFSONotes; obj.Update(); } } if (changed != null && changed.Count() > 0) { foreach (var temp in changed) { obj.OrderNumber = order_no; obj.ProductCode = System.Convert.ToInt32(temp.product_code); obj.QuantityRequired = temp.QuantityRequired; obj.Comments = temp.Comments; obj.Quantity_Allocated = temp.QuantityRequired; obj.RFSONotes = temp.RFSONotes; obj.Update(); } } //var data = 0; return Json(data, JsonRequestBehavior.AllowGet); var data = 0; return(Json(data, JsonRequestBehavior.AllowGet)); }