public ActionResult RawMaterialTest(int rawMaterialId, RawMaterialTestModel model) { using (RawMaterialTestService service = new RawMaterialTestService()) { model.LastModified = DateTime.Now; model.ModifiedBy = CurrentUser; model.PlantId = CurrentPlantId; if (model.ACLimitTypeID == 0) { model.ACLimitTypeID = null; } if (model.CBLimitTypeID == 0) { model.CBLimitTypeID = null; } if (model.ColorLimitTypeID == 0) { model.ColorLimitTypeID = null; } if (model.MFLimitTypeID == 0) { model.MFLimitTypeID = null; } if (model.MoistLimitTypeID == 0) { model.MoistLimitTypeID = null; } RawMaterialTestDto dto; if (model.Id > 0) { dto = service.GetByRawMatId(model.RawMaterialId); Mapper.Map(model, dto); if (string.IsNullOrEmpty(dto.EnteredBy)) { dto.EnteredBy = CurrentUser; dto.DateEntered = DateTime.Now; } service.Update(dto); } else { dto = new RawMaterialTestDto(); Mapper.Map(model, dto); dto.EnteredBy = CurrentUser; dto.DateEntered = DateTime.Now; service.Add(dto); } } return(RedirectToAction("Index")); }
/// <summary> /// Retrieves the test configuration details for the provided raw material. /// </summary> /// <param name="rawMaterialID">The unique code of the raw material.</param> /// <returns>An instance of RawMaterialTestModel.</returns> public RawMaterialTestModel GetQCConfigurationByRawMaterial(Int32 rawMaterialID) { RawMaterialTestModel model = null; using (RawMaterialsRepository repo = new RawMaterialsRepository()) { TPO.DL.Models.RawMaterialTest entity = repo.GetRawMaterialTestByRawMaterial(rawMaterialID); if (entity != null) { model = Bind(entity, new RawMaterialTestModel()); } } return(model); }
public PartialViewResult RawMaterialTest(int rawMaterialId) { RawMaterialTestModel model; using (RawMaterialTestService service = new RawMaterialTestService()) { var dtos = service.GetByRawMatId(rawMaterialId); model = Mapper.Map <RawMaterialTestDto, RawMaterialTestModel>(dtos); if (model == null) { model = new RawMaterialTestModel(); model.PlantId = CurrentPlantId; model.RawMaterialId = rawMaterialId; } } return(PartialView("QCTest", model)); }
/// <summary> /// Converts a RawMaterialTest Entity into a RawMaterialTestModel Model. /// </summary> /// <param name="entity">The RawMaterialTest Entity to convert.</param> /// <param name="to">The RawMaterialTestModel Model to which to convert.</param> /// <returns>An instance of RawMaterialTestModel representing the RawMaterialTest entity.</returns> private static RawMaterialTestModel Bind(TPO.DL.Models.RawMaterialTest entity, RawMaterialTestModel to) { to.ID = entity.ID; to.AshContentLimitTypeID = entity.ACLimitTypeID.HasValue ? entity.ACLimitTypeID.Value : RawMaterialTestModel.INVALID_ID; to.AshContentMinimum = entity.ACLimit1.HasValue ? (decimal)entity.ACLimit1.Value : 0; to.AshContentMaximum = entity.ACLimit2.HasValue ? (decimal)entity.ACLimit2.Value : 0; to.CarbonBlackLimitTypeID = entity.CBLimitTypeID.HasValue ? entity.CBLimitTypeID.Value : RawMaterialTestModel.INVALID_ID; to.CarbonBlackMinimum = entity.CBLimit1.HasValue ? (decimal)entity.CBLimit1.Value : 0; to.CarbonBlackMaximum = entity.CBLimit2.HasValue ? (decimal)entity.CBLimit2.Value : 0; to.ColorLimitTypeID = entity.ColorLimitTypeID.HasValue ? entity.ColorLimitTypeID.Value : RawMaterialTestModel.INVALID_ID; to.ColorMinimum = entity.ColorLimit1.HasValue ? (decimal)entity.ColorLimit1.Value : 0; to.ColorMaximum = entity.ColorLimit2.HasValue ? (decimal)entity.ColorLimit2.Value : 0; to.MeltFlowLimitTypeID = entity.MFLimitTypeID.HasValue ? entity.MFLimitTypeID.Value : RawMaterialTestModel.INVALID_ID; to.MeltFlowMinimum = entity.MFLimit1.HasValue ? (decimal)entity.MFLimit1.Value : 0; to.MeltFlowMaximum = entity.MFLimit2.HasValue ? (decimal)entity.MFLimit2.Value : 0; to.MoistureLimitTypeID = entity.MoistLimitTypeID.HasValue ? entity.MoistLimitTypeID.Value : RawMaterialTestModel.INVALID_ID; to.MoistureMinimum = entity.MoistLimit1.HasValue ? (decimal)entity.MoistLimit1.Value : 0; to.MoistureMaximum = entity.MoistLimit2.HasValue ? (decimal)entity.MoistLimit2.Value : 0; to.PlantID = entity.PlantID; to.TestFrequency = entity.TestFrequency; to.UseAshContentTest = entity.UseACTest; to.UseCarbonBlackTest = entity.UseCBTest; to.UseColorTest = entity.UseColorTest; to.UseMeltFlowTest = entity.UseMFTest; to.UseMoistureTest = entity.UseMoistTest; to.UseSpecificGravityTest = entity.UseSpecGrav.HasValue ? entity.UseSpecGrav.Value : false; to.UseVisualInspectionTest = entity.UseVisual.HasValue ? entity.UseVisual.Value : false; return(to); }