//[HttpPost] //public ActionResult Create(TPO.Model.RawMaterials.RawMaterialQCModel model) //{ // TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC(); // model = qcBL.InsertRawMaterialQCModel(model); // return RedirectToAction("Edit", new { id = model.ID, unlocked = false }); //} public ActionResult Edit(int id = 0, bool isNew = false, bool success = false) { TPO.BL.Security.User userBL = new TPO.BL.Security.User(); ViewBag.QCTech = new SelectList(userBL.GetQCTechUsers(), "ID", "FullName"); TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC(); TPO.Model.RawMaterials.RawMaterialQCModel model = qcBL.GetRawMaterialQCModelByRawMaterialQCID(id); //model.IsEditMode = !isNew; //hack if (success) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess); } if (model == null) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord); //string.Format("Raw Material QC with ID {0} not found.", id); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(RedirectToAction("Index")); //return HttpNotFound(string.Format("Raw Material QC with ID {0} not found.", id)); } return(View(model)); }
//TODO: is this method needed? do business rules allow deletion of these records? // GET: /RawMaterialSpecificGravityDetail/Delete/5 public ActionResult Delete(int?id) { if (id == null) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoId); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(RedirectToAction("Index", "RawMaterialQC")); //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var specificGravityDto = repository.GetByID(id.Value); if (specificGravityDto != null) { RawMaterialQCSpecificGravityViewModel viewModel = MapDtoToViewModel(specificGravityDto); var userBL = new TPO.BL.Security.User(); ViewBag.QCTech = new SelectList(userBL.GetQCTechUsers(), "ID", "FullName"); return(View(viewModel)); } TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(RedirectToAction("Index", "RawMaterialQC")); //return HttpNotFound(); }
//// GET: /RawMaterialQC/LotID //public ActionResult GetTestIDs(int ID) //{ // List<SelectListItem> testItems = new List<SelectListItem>(); // TPOMVCApplicationEntities db = new TPOMVCApplicationEntities(); // var testRecords = // db.RawMaterialQCs.Where(x => x.RawMaterialReceivedID == ID) // .OrderByDescending(x => x.DateEntered) // .ToList(); // if (testRecords.Count > 0) // { // testItems.Add(new SelectListItem {Value = "", Text = "-- Select Test --"}); // } // else // { // testItems.Add(new SelectListItem {Value = "", Text = "-- No Tests for Lot: " + ID + " --"}); // } // foreach (var item in testRecords) // { // testItems.Add(new SelectListItem // { // Value = item.ID.ToString(), // Text = item.DateEntered.ToString("MM/dd/yy hh:mm") + " | " + item.BoxCarTested // }); // } // return Json(testItems); //} public ActionResult Create(string rm = "", string lot = "") { TPO.BL.Security.User userBL = new TPO.BL.Security.User(); ViewBag.QCTech = new SelectList(userBL.GetQCTechUsers(), "ID", "FullName"); TPO.Model.RawMaterials.RawMaterialQCModel model = new TPO.Model.RawMaterials.RawMaterialQCModel(); int tmpRawMaterialReceivedId = 0; if (!int.TryParse(lot, out tmpRawMaterialReceivedId)) { tmpRawMaterialReceivedId = 0; } model.RawMaterialReceivedID = tmpRawMaterialReceivedId; TPO.DL.Models.RawMaterialReceived rawMaterialLookup = new TPOMVCApplicationEntities().RawMaterialQCs.Where( w => w.RawMaterialReceivedID == tmpRawMaterialReceivedId).First().RawMaterialReceived; if (rawMaterialLookup == null) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord); //string.Format("Raw Material Test configuration not found for raw material {0}.", rm); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(RedirectToAction("Index")); //return HttpNotFound(string.Format("Raw Material Test configuration not found for raw material {0}.", rm)); } model.RawMaterialCode = rawMaterialLookup.RawMaterial.Code; model.LotCode = rawMaterialLookup.LotNumber; model.QCTechID = CurrentUserID; TPO.BL.RawMaterials.RawMaterialTest rmtBL = new TPO.BL.RawMaterials.RawMaterialTest(); model.QCConfiguration = rmtBL.GetQCConfigurationByRawMaterial(tmpRawMaterialReceivedId); if (model.QCConfiguration == null) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord); //string.Format("Raw Material Test configuration not found for raw material {0}.", rm); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(RedirectToAction("Index")); //return HttpNotFound(string.Format("Raw Material Test configuration not found for raw material {0}.", rm)); } TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC(); model = qcBL.InsertRawMaterialQCModel(model); model.LastModified = DateTime.Now; // return View(model); return(RedirectToAction("Edit", new { id = model.ID })); }