public ActionResult ScrimRollAjaxCreate(string id) { dynamic d = JObject.Parse(id); ScrimRollModel model = new ScrimRollModel(); ScrimRoll bl = new ScrimRoll(); if (d["ID"] != null) { model.ID = d["ID"]; } model.ScrimRollCode = d["ScrimRollCode"]; //required model.ScrimRollTypeID = d["ScrimRollTypeID"]; model.Length = d["Length"]; model.DateReceived = d["DateReceived"]; //required model.ReceivedLength = d["ReceivedLength"]; // TODO: set values model.WeightUnitOfMeasureID = 1; //required model.LengthUnitOfMeasureID = 1; //required //model.LotCode = string.Empty; //model.WovenLotCode = string.Empty; //model.Weight = 0; //model.TareWeight = 0; //model.ReceivedWeight = 0; //model.ReceivedTareWeight = 0; //model.LengthUsed = 0; //model.WeightUsed = 0; model.EnteredBy = CurrentUser; model.ModifiedBy = CurrentUser; model.DateEntered = DateTime.Now; model.LastModified = DateTime.Now; if (model.ID == -1) { model = bl.InsertScrimRoll(model); } else { bl.UpdateScrimRoll(model); } return(RedirectToAction("Details")); }
public ActionResult Edit(DateTime?date, int id, ScrimRollModel model) { if (!ModelState.IsValid) { ModelState.AddModelError(string.Empty, "Please enter required fields."); GetRollTypesList(); GetUoMList(); return(View(model)); } model.EnteredBy = CurrentUser; model.ModifiedBy = CurrentUser; model.DateEntered = DateTime.Now; model.LastModified = DateTime.Now; model.DateReceived = date ?? DateTime.Now; ScrimRoll bl = new ScrimRoll(); bl.UpdateScrimRoll(model); TempData["ActionMessage"] = TPO.BL.Repositories.Message.MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave); TempData["ActionMessageType"] = TPO.BL.Repositories.Message.MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess); return(RedirectToAction("Details", new { id = model.ID })); }