public ActionResult Edit(int id = 0, bool success = false) { var qcTechList = new List <SelectListItem>(); using (var svc = new SecurityService()) { qcTechList.AddRange(svc.GetQCTechUsers().Select(u => new SelectListItem { Text = u.FullName, Value = u.Id.ToString(CultureInfo.InvariantCulture) })); } ViewBag.QCTech = new SelectList(qcTechList, "Value", "Text"); RawMaterialQc model = null; using (var svc = new RawMaterialsQcService()) { var dto = svc.Get(id); if (dto != null) { model = Mapper.Map <RawMaterialQcDto, RawMaterialQc>(dto); } } //hack if (success) { SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } if (model == null) { SetResponseMesssage(ActionTypeMessage.Error, General.ResponseMessageFailNoRecord); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Edit(RawMaterialQc model) { var success = false; if (ModelState.IsValid) { var dto = Mapper.Map <RawMaterialQc, RawMaterialQcDto>(model); dto.ModifiedBy = CurrentUser; dto.LastModified = DateTime.Now; using (var svc = new RawMaterialsQcService()) { svc.Update(dto); } success = true; } if (success) { SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } if (model == null) { SetResponseMesssage(ActionTypeMessage.Error, General.ResponseMessageFailNoRecord); return(RedirectToAction("Index")); } return(RedirectToAction("Edit", new { id = model.Id, success })); }
public ActionResult Create(RawMaterialQc model) { model.PlantId = CurrentPlantId; model.EnteredBy = CurrentUser; model.DateEntered = DateTime.Now; model.ModifiedBy = CurrentUser; model.LastModified = DateTime.Now; var dto = Mapper.Map <RawMaterialQc, RawMaterialQcDto>(model); int id; using (var svc = new RawMaterialsQcService()) { id = svc.Add(dto); } if (id > 0) { return(RedirectToAction("Edit", new { id })); } SetResponseMesssage(ActionTypeMessage.FailedSave); return(RedirectToAction("Index")); }