public ActionResult Create(int qcID = 0) { if (qcID == 0) { SetResponseMesssage(ActionTypeMessage.Error, General.ResponseMessageFailNoId); return(RedirectToAction("Index", "RawMaterialQC")); } using (RawMaterialQCRedHoldService rhSvc = new RawMaterialQCRedHoldService()) { var dto = rhSvc.GetByQC(qcID); if (dto != null) { return(RedirectToAction("Edit", new { id = dto.Id })); } } RawMaterialQCRedHoldViewModel model = new RawMaterialQCRedHoldViewModel(); model.RawMaterialQCId = qcID; using (RawMaterialsQcService svc = new RawMaterialsQcService()) { RawMaterialQcDto qcDto = svc.Get(qcID); model.RawMaterialReceivedId = qcDto.RawMaterialReceivedId; using (RawMaterialReceivedService receiveSvc = new RawMaterialReceivedService()) { RawMaterialReceivedDto receivedDto = receiveSvc.Get(qcDto.RawMaterialReceivedId); model.BoxCarTested = receivedDto.LotNumber; model.RawMaterialReceived = receivedDto.RawMaterialCode; ViewBag.RawMaterialReceivedID = new SelectList(receiveSvc.GetAll(), "ID", "RawMaterialID"); } } PrepareSelectLists(); return(View(model)); }
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 Create(int id = 0) { RawMaterialQcDto dto; using (var svc = new RawMaterialsQcService()) { dto = svc.CreateNew(id); } if (dto == null) { SetResponseMesssage(ActionTypeMessage.Error, General.ResponseMessageFailNoRecord); return(RedirectToAction("Index")); } 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) })); } dto.DateEntered = DateTime.Now; ViewBag.QCTech = new SelectList(qcTechList, "Value", "Text"); var model = Mapper.Map <RawMaterialQcDto, RawMaterialQc>(dto); 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 JsonResult RawMaterialQCsGridByReceived(int receivedId, int?rows, int?page) { rows = rows ?? DefaultPageSize; page = page ?? DefaultPage; var data = new List <RawMaterialQc>(); int total; using (var svc = new RawMaterialsQcService()) { var dtos = svc.GetByReceived(receivedId); total = dtos.Count; var currentPageDtos = dtos.OrderBy(r => r.DateEntered).Skip((page.Value - 1) * rows.Value).Take(rows.Value).ToList(); data.AddRange(Mapper.Map <List <RawMaterialQcDto>, List <RawMaterialQc> >(currentPageDtos)); } return(BuildJsonResult(data, total)); }
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")); }