//// 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 })); }
/// <summary> /// Gets a RawMaterialQCModel representing the RawMaterialQC record indicated by the provided ID. /// The RawMaterialQCModel returns also includes configuration data for the various test available. /// </summary> /// <param name="id">The ID of the RawMaterialQC record in the database.</param> /// <returns>A RawMaterialQCModel</returns> public RawMaterialQCModel GetRawMaterialQCModelByRawMaterialQCID(int id) { RawMaterialQCModel model = null; using (RawMaterialsRepository repo = new RawMaterialsRepository()) { TPO.DL.Models.RawMaterialQC entity = repo.GetRawMaterialQCByID(id); if (entity != null) { model = Bind(entity, new RawMaterialQCModel()); RawMaterialTest testBL = new RawMaterialTest(); Int32 rawMatID = 0; TPO.DL.Models.RawMaterialReceived rawMaterialReceived = new TPOMVCApplicationEntities().RawMaterialReceiveds.Where(w => w.ID == model.RawMaterialReceivedID).First(); model.QCConfiguration = testBL.GetQCConfigurationByRawMaterial(rawMaterialReceived.RawMaterial.ID); } } return(model); }