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"));
        }
        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));
        }