/// <summary> /// Converts a RawMaterialQCModel Model into a RawMaterialQC Entity. /// </summary> /// <param name="entity">The RawMaterialQCModel Model to convert.</param> /// <param name="to">The RawMaterialQC Entity to which to convert.</param> /// <returns>An instance of RawMaterialQC representing the RawMaterialQCModel Model.</returns> private static TPO.DL.Models.RawMaterialQC Bind(RawMaterialQCModel model, TPO.DL.Models.RawMaterialQC to) { //to.PlantID = model.PlantID; //TODO: Implement retrieving PlantID to.PlantID = 1; if (model.QCTechID != RawMaterialQCModel.INVALID_ID) { to.QCTechUserID = model.QCTechID; } else { to.QCTechUserID = null; } to.RawMaterialReceivedID = model.RawMaterialReceivedID; to.VisualInspection = model.VisuallyInspected; to.SpecGrav = (double?)model.SpecificGravity; to.ColorCoA = (double?)model.ColorTestCoA; to.ColorFS = (double?)model.ColorTestFS; to.MFCoA = (double?)model.MeltFlowTestCoA; to.MFFS = (double?)model.MeltFlowTestFS; to.ACCoA = (double?)model.AshContentTestCoA; to.ACFS = (double?)model.AshContentTestFS; to.MoistCoA = (double?)model.MoistureTestCoA; to.MoistFS = (double?)model.MoistureTestFS; to.CBCoA = (double?)model.CarbonBlackTestCoA; to.CBFS = (double?)model.CarbonBlackTestFS; to.BoxCarTested = model.BoxCar; to.Comments = model.Comments; return(to); }
/// <summary> /// Converts a RawMaterialQC Entity into a RawMaterialQCModel Model. /// </summary> /// <param name="entity">The RawMaterialQC Entity to convert.</param> /// <param name="to">The RawMaterialQCModel Model to which to convert.</param> /// <returns>An instance of RawMaterialQCModel representing the RawMaterialQC Entity.</returns> private static RawMaterialQCModel Bind(TPO.DL.Models.RawMaterialQC entity, RawMaterialQCModel to) { to.ID = entity.ID; to.PlantID = entity.PlantID; to.QCTechID = entity.QCTechUserID.HasValue ? entity.QCTechUserID.Value : RawMaterialQCModel.INVALID_ID; to.RawMaterialReceivedID = entity.RawMaterialReceivedID; //Code and Lot are one way read and not passed back to model (i.e. read-only) to.RawMaterialCode = entity.RawMaterialReceived.RawMaterial.Code; to.LotCode = entity.RawMaterialReceived.LotNumber; to.VisuallyInspected = entity.VisualInspection.HasValue ? entity.VisualInspection.Value : false; to.SpecificGravity = entity.SpecGrav.HasValue ? (decimal)entity.SpecGrav.Value : 0; to.ColorTestCoA = entity.ColorCoA.HasValue ? (decimal)entity.ColorCoA.Value : 0; to.ColorTestFS = entity.ColorFS.HasValue ? (decimal)entity.ColorFS.Value : 0; to.MeltFlowTestCoA = entity.MFCoA.HasValue ? (decimal)entity.MFCoA.Value : 0; to.MeltFlowTestFS = entity.MFFS.HasValue ? (decimal)entity.MFFS.Value : 0; to.AshContentTestCoA = entity.ACCoA.HasValue ? (decimal)entity.ACCoA.Value : 0; to.AshContentTestFS = entity.ACFS.HasValue ? (decimal)entity.ACFS.Value : 0; to.MoistureTestCoA = entity.MoistCoA.HasValue ? (decimal)entity.MoistCoA.Value : 0; to.MoistureTestFS = entity.MoistFS.HasValue ? (decimal)entity.MoistFS.Value : 0; to.CarbonBlackTestCoA = entity.CBCoA.HasValue ? (decimal)entity.CBCoA.Value : 0; to.CarbonBlackTestFS = entity.CBFS.HasValue ? (decimal)entity.CBFS.Value : 0; to.BoxCar = entity.BoxCarTested; to.Comments = entity.Comments; to.DateEntered = entity.DateEntered; to.EnteredBy = entity.EnteredBy; to.LastModified = entity.LastModified; to.ModifiedBy = entity.ModifiedBy; return(to); }
/// <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); }
// // GET: /RawMaterialQC/ public ActionResult Index(int?id, bool unlocked = false) { TPOMVCApplicationEntities db = new TPOMVCApplicationEntities(); // var RawMat = db.RawMaterialQCs.Where(s => s.RawMaterialReceivedID != null).ToList(); TPO.BL.RawMaterials.RawMaterial RawMatList = new TPO.BL.RawMaterials.RawMaterial(); ViewBag.RawMaterialQCList = RawMatList.GetRawMaterials(); //TODO: Refactor after RawMaterialModel is completed to use intID List <RawMaterialModel> rawMatListFromBL = RawMatList.GetRawMaterials(); var QCList = db.Users.Where(s => s.ID != null).ToList(); IEnumerable <SelectListItem> rawMaterialSelectList = from s in rawMatListFromBL select new SelectListItem { Value = s.RawMaterialCode, Text = (s.RawMaterialCode + " | " + s.RawMaterialName) }; //IEnumerable<SelectListItem> selectList = from s in RawMat // select new SelectListItem // { // Value = s.RawMaterialID, // Text = s.RawMaterialID + " | " + s.RawMaterialLotID.ToString() // }; IEnumerable <SelectListItem> lotSelectList = from s in RawMaterialReceivedRepo.GetAll() select new SelectListItem { Value = s.LotNumber, Text = s.LotNumber + " | " + s.LastModified.ToShortDateString() }; //IEnumerable<SelectListItem> lotSelectList = from s in RawMat // select new SelectListItem // { // Value = s.RawMaterialLotID, // Text = (s.RawMaterialLotID.Length != 11 ? s.RawMaterialLotID : s.RawMaterialLotID) + " | " + // s.DateEntered.ToShortDateString() + // " | " + s.LastModified.ToShortDateString() // }; IEnumerable <SelectListItem> lotTestList = from s in RawMat select new SelectListItem { Value = s.ID.ToString(), Text = s.DateEntered.ToShortDateString() + " | " + s.BoxCarTested }; //new SelectList() ViewBag.RawMaterialQC = new SelectList(rawMaterialSelectList, "Value", "Text"); ViewBag.RawMaterialLotQC = new SelectList(lotSelectList, "Value", "Text"); ViewBag.RawMaterialQCLotTest = new SelectList(lotTestList, "Value", "Text"); ViewBag.RawMaterialQCLastModified = new SelectList(RawMat, "ID", "LastModified"); ViewBag.RawMaterialEnteredBy = new SelectList(QCList, "ID", "FullName"); TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC(); //if (id != null) //{ // RawMaterialQCModel model = qcBL.GetRawMaterialQCModelByRawMaterialQCID(id ?? Convert.ToInt32(id)); //} //else //{ // RawMaterialQCModel model = new RawMaterialQCModel(); //} RawMaterialQCModel model = qcBL.GetRawMaterialQCModelByRawMaterialQCID(id ?? Convert.ToInt32(id)); if (model == null) { model = new RawMaterialQCModel(); } var tests = (from t in db.RawMaterialQCs where t.RawMaterialReceived.ID == t.RawMaterialReceivedID select t).ToList(); ViewBag.QCItems = tests; return(View(model)); }