// GET: /RawMaterialQCRedHold/Edit/5 public ActionResult Edit(DateTime?holddate, DateTime?managerdate, DateTime?reddate, int?id) { RawMaterialQCRedHoldViewModel model = new Models.RawMaterialQCRedHoldViewModel(); try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //RawMaterialQCRedHold rawmaterialqcredhold = db.RawMaterialQCRedHolds.Find(id); //Sloppy error handling, have to fix the null ID variable. RawMaterialQCRedHoldDTO dto = RawMaterialQCRedHoldRepo.GetByID(id ?? -1); if (dto == null) { return(HttpNotFound()); } else { model = MapRawMaterialQCRedHoldDTOtoViewModel(dto); //TODO: Rewrite after QC object has been refactored. GetQcFormDetail(ref model); model.ManagerDate = managerdate; model.HoldDate = holddate; model.RedDate = reddate; PrepareSelectLists(); ViewBag.RawMaterialReceivedID = new SelectList(db.RawMaterialReceiveds, "ID", "RawMaterialID"); } } catch (Exception ex) { ViewBag.ExceptionMessage = ex.Message; TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(View(model)); } return(View(model)); }
// GET: /RawMaterialQCRedHold/Create/QCID public ActionResult Create(DateTime?holddate, DateTime?managerdate, DateTime?reddate, int?id) { TPOWeb.Models.RawMaterialQCRedHoldViewModel model = new Models.RawMaterialQCRedHoldViewModel(); if (id == null) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoId); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(RedirectToAction("Index", "RawMaterialQC")); //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } else { //Sloppy error handling, have to fix the null ID variable. RawMaterialQCRedHoldDTO lookupObjByQCId = RawMaterialQCRedHoldRepo.GetByQCID(id ?? -1); //test to see if record already exists, if it does, switch to edit view if (lookupObjByQCId != null && lookupObjByQCId.ID >= 0) { return(RedirectToAction("Edit", "RawMaterialQCRedHold", new { ID = lookupObjByQCId.ID })); } //TODO: Rewrite after QC object has been refactored. TPO.DL.Models.RawMaterialQC qcLookupObj = db.RawMaterialQCs.Find(id); model.RawMaterialQCId = qcLookupObj.ID; model.QCTechId = qcLookupObj.QCTechUserID; model.PlantId = qcLookupObj.PlantID; model.BoxCarTested = qcLookupObj.BoxCarTested; model.RawMaterialReceived = qcLookupObj.RawMaterialReceived.RawMaterial.Code; model.LotNumber = qcLookupObj.RawMaterialReceived.LotNumber; model.RawMaterialReceivedId = qcLookupObj.RawMaterialReceivedID; model.ManagerDate = managerdate; model.HoldDate = holddate; model.RedDate = reddate; PrepareSelectLists(); ViewBag.RawMaterialReceivedID = new SelectList(db.RawMaterialReceiveds, "ID", "RawMaterialID"); } return(View(model)); }