public ActionResult Edit(string preProductCode)
        {
            var model = new PreProductViewModel {
                IsCreate = true
            };

            if (string.IsNullOrEmpty(preProductCode))
            {
                model.F03_BatchLot      = 1;
                model.F03_YieldRate     = 100.0f;
                model.F03_ContainerType = "";
                model.F03_Point         = "";
                model.F03_LotNoEnd      = 99;
                model.MixDate1          = new TimeSpan(0, 0, 0);
                model.MixDate2          = new TimeSpan(0, 0, 0);
                model.MixDate3          = new TimeSpan(0, 0, 0);
            }
            else
            {
                var entity = _preProductDomain.GetById(preProductCode.Trim());
                if (entity != null)
                {
                    model = Mapper.Map <PreProductViewModel>(entity);

                    model.IsCreate = false;
                    model.Days     = entity.F03_TmpRetTime.Value.Day != 31?entity.F03_TmpRetTime.Value.Day:(int?)null;
                }
            }
            model.Grid = GenerateGridPreproductMaterial(preProductCode);
            return(PartialView("PreProduct/_PartialViewEditPreProduct", model));
        }
 public ActionResult Edit(PreProductViewModel model)
 {
     //  if (ModelState.IsValid)
     try
     {
         var item = Mapper.Map <PreProductItem>(model);
         if (model.Days == 0 || model.Days == null)
         {
             item.F03_TmpRetTime = new DateTime(1980,
                                                1,
                                                Constants.LastDayOfMonth,
                                                model.TmpRetTime.Hours,
                                                model.TmpRetTime.Minutes,
                                                model.TmpRetTime.Milliseconds);
         }
         else
         {
             item.F03_TmpRetTime = new DateTime(1980,
                                                1,
                                                model.Days.Value,
                                                model.TmpRetTime.Hours,
                                                model.TmpRetTime.Minutes,
                                                model.TmpRetTime.Milliseconds);
         }
         var isSuccess = _preProductDomain.CreateOrUpdate(item);
         if (!isSuccess.IsSuccess)
         {
             return(Json(new { Success = false, Message = isSuccess.ErrorMessages },
                         JsonRequestBehavior.AllowGet));
         }
         return
             (Json(
                  new { Success = true, Message = model.IsCreate ? MessageResource.MSG6 : MessageResource.MSG9 },
                  JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { Success = false, ex.Message }, JsonRequestBehavior.AllowGet));
     }
     // return Json(new {Success = false}, JsonRequestBehavior.AllowGet);
 }