コード例 #1
0
        public ActionResult Edit(ProductCertificationViewModel model)
        {
            try
            {
                var item      = Mapper.Map <ProductCertificationItem>(model);
                var isSuccess = _prodCerDomain.CreateOrUpdate(item);
                if (!isSuccess.IsSuccess)
                {
                    return(Json(new { Success = false, Message = ProductManagementResources.MSG21 }, JsonRequestBehavior.AllowGet));
                }
                return(Json(
                           new { Success = true, Message = model.IsCreate ? MessageResource.MSG6 : MessageResource.MSG9 },
                           JsonRequestBehavior.AllowGet));

                ;
            }
            catch (DbUpdateException e)
            {
                var sb = new StringBuilder();
                sb.AppendLine("DbUpdateException error details - {e?.InnerException?.InnerException?.Message}");

                foreach (var eve in e.Entries)
                {
                    sb.AppendLine("Entity of type {eve.Entity.GetType().Name} in state {eve.State} could not be updated");
                }

                Console.WriteLine(sb.ToString());
                throw;
            }
            catch (Exception ex)
            {
                return(Json(new { Success = false, ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
 public ActionResult Edit(string prodCode, string prePdtLotNo, string productFlg)
 {
     try
     {
         var model = new ProductCertificationViewModel
         {
             IsCreate = true
                        //F39_Status = Constants.Status.Yet.ToString(),
                        //F39_KndEptBgnDate = DateTime.Now.ToString("MM/yyyy")
         };
         if (!string.IsNullOrEmpty(prodCode) && !string.IsNullOrEmpty(prePdtLotNo) &&
             !string.IsNullOrEmpty(productFlg))
         {
             var entity = _prodCerDomain.GetById(prodCode, prePdtLotNo, productFlg);
             if (entity != null)
             {
                 model = Mapper.Map <ProductCertificationViewModel>(entity);
                 //model.F39_Status = Enum.GetName(typeof(Constants.Status), ConvertHelper.ToInteger(model.F39_Status));
                 model.IsCreate = false;
             }
         }
         return(PartialView("_PartialViewEditProductCertification", model));
     }
     catch (Exception exception)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
     }
 }