public ActionResult Create( [Bind(Include = "Id,RawMaterialQCId,PlantId,RawMaterialReceivedId,FailPropertyId,HoldLotId,QCTechId,LeadOperatorId,SupervisorId,ManagerId,RedDate,Zone,RedComments,RedCorrectionAction,HoldDate,HoldComments,ManagerDate,ManagerComments,PrimeBoxCar,PrimeUOM,ReworkBoxCar,ReworkUOM,ScrapBoxCar,ScrapUOM,DateEntered,EnteredBy,LastModified,ModifiedBy")] RawMaterialQCRedHoldViewModel viewModel) { if (ModelState.IsValid) { try { //map objects for database TPO.Domain.DTO.RawMaterialQCRedHoldDTO dto = MapRawMaterialQCRedHoldViewModeltoDTO(viewModel); //update object records dto.ModifiedBy = CurrentUser; dto.EnteredBy = CurrentUser; dto.LastModified = DateTime.Now; dto.DateEntered = DateTime.Now; //save item, get item ID back int itemId = RawMaterialQCRedHoldRepo.Add(dto); //if item ID is valid redirect to edit page. if (itemId > 0) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess); return(RedirectToAction("Edit", "RawMaterialQCRedHold", new { ID = itemId })); } } catch (Exception ex) { //ViewBag.ExceptionMessage = ex.Message; //return View(viewModel); TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailSave); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); } finally { PrepareSelectLists(); ViewBag.RawMaterialReceivedID = new SelectList(db.RawMaterialReceiveds, "ID", "RawMaterialID"); } } return(View(viewModel)); }
public ActionResult Edit( [Bind(Include = "Id,RawMaterialQCId,PlantId,RawMaterialReceivedId,FailPropertyId,HoldLotId,QCTechId,LeadOperatorId,SupervisorId,ManagerId,RedDate,Zone,RedComments,RedCorrectionAction,HoldDate,HoldComments,ManagerDate,ManagerComments,PrimeBoxCar,PrimeUOM,ReworkBoxCar,ReworkUOM,ScrapBoxCar,ScrapUOM,DateEntered,EnteredBy,LastModified,ModifiedBy")] RawMaterialQCRedHoldViewModel viewModel) { ViewBag.SuccessMessage = ""; if (ModelState.IsValid) { try { //map objects for database TPO.Domain.DTO.RawMaterialQCRedHoldDTO dto = MapRawMaterialQCRedHoldViewModeltoDTO(viewModel); //update object records dto.EnteredBy = dto.EnteredBy ?? CurrentUser; dto.DateEntered = dto.DateEntered ?? DateTime.Now; dto.ModifiedBy = CurrentUser; dto.LastModified = DateTime.Now; //save item, get item ID back RawMaterialQCRedHoldRepo.Update(dto); TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess); //ViewBag.SuccessMessage = "Save completed successfully."; } catch (Exception ex) { ViewBag.ExceptionMessage = ex.Message; TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailSave); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); //return View(viewModel); } finally { ViewBag.RawMaterialReceivedID = new SelectList(db.RawMaterialReceiveds, "ID", "RawMaterialID"); } } else { ModelState.AddModelError(string.Empty, "Please enter required fields."); } PrepareSelectLists(); GetQcFormDetail(ref viewModel); return(View(viewModel)); }