/// <summary>
 /// 根据Larfier测试结果,需要对没有箱柜尺寸的HM新增这些参数
 /// CreateDate:2013年12月10日15:32:00 Lee
 /// </summary>
 /// <param name="ctnModel"></param>
 /// <returns></returns>
 public ActionResult AddHMCarton(CMS_ProductCTN_Model ctnModel)
 {
     try
     {
         var  curUserInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);
         var  hcSvr       = new HmConfigServices();
         long CTNID       = 0;
         if (!hcSvr.AddHmCarton(ctnModel, curUserInfo.User_Account, out CTNID))
         {
             return(Json(new NBCMSResultJson
             {
                 Status = StatusType.Error,
                 Data = "Fail to Add current HM#'s cartons"
             }));
         }
         return(Json(new NBCMSResultJson
         {
             Status = StatusType.OK,
             Data = CTNID
         }));
     }
     catch (Exception ex)
     {
         NBCMSLoggerManager.Error("");
         NBCMSLoggerManager.Error(ex.Message);
         NBCMSLoggerManager.Error(ex.StackTrace);
         NBCMSLoggerManager.Error("");
         return(Json(new NBCMSResultJson
         {
             Status = StatusType.Exception,
             Data = ex.Message
         }));
     }
 }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctnModel"></param>
        /// <param name="userAccount"></param>
        /// <param name="ctnid"></param>
        /// <returns></returns>
        public bool AddHmCarton(CMS_ProductCTN_Model ctnModel, string userAccount, out long ctnid)
        {
            using (var db = new PermaisuriCMSEntities())
            {
                var hmnum = db.CMS_HMNUM.FirstOrDefault(h => h.ProductID == ctnModel.ProductID);
                if (hmnum == null)
                {
                    ctnid = 0;
                    return(false);
                }

                var newModel = new CMS_ProductCTN
                {
                    CTNComment = ctnModel.CTNComment,
                    CTNCube    = ctnModel.CTNCube,
                    CTNHeight  = ctnModel.CTNHeight,
                    CTNLength  = ctnModel.CTNLength,
                    CTNTitle   = ctnModel.CTNTitle,
                    CTNWidth   = ctnModel.CTNWidth,
                    HMNUM      = ctnModel.HMNUM,
                    ProductID  = ctnModel.ProductID,
                    UpdateBy   = userAccount,
                    UpdateOn   = DateTime.Now,
                    CreateOn   = DateTime.Now,
                    CTNWeight  = ctnModel.CTNWeight
                };

                db.CMS_ProductCTN.Add(newModel);

                hmnum.SKU_HM_Relation.Select(r => r.CMS_SKU.CMS_Ecom_Sync ?? (r.CMS_SKU.CMS_Ecom_Sync = new CMS_Ecom_Sync
                {
                    StatusID = 1//这里可以不用做任何设置,因为后面那个操作会全面覆盖这个...
                })).ForEach(k =>
                {
                    k.StatusID   = 0;
                    k.StatusDesc = "NeedSend";
                    k.UpdateBy   = userAccount;
                    k.UpdateOn   = DateTime.Now;
                });

                BllExtention.DbRecorder(new LogOfUserOperatingDetails
                {
                    ModelName    = ModelName,
                    ActionName   = MethodBase.GetCurrentMethod().Name,
                    ActionType   = LogActionTypeEnum.Inert.GetHashCode(),
                    ProductID    = hmnum.ProductID,
                    HMNUM        = hmnum.HMNUM,
                    Descriptions = "Add new carton  [ <b>" + newModel.CTNTitle + " </b>] for " + hmnum.HMNUM,
                    CreateBy     = userAccount,
                    CreateOn     = DateTime.Now
                });


                var retVal = db.SaveChanges();
                ctnid = newModel.CTNID;
                return(retVal > 0);
            }
        }