Пример #1
0
        /// <summary>
        /// 编辑品牌
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO EditCategoryAdvertiseExt(Jinher.AMP.BTP.Deploy.CategoryAdvertiseDTO entity)
        {
            try
            {
                entity.EntityState = System.Data.EntityState.Modified;
                var model = CategoryAdvertise.FromDTO(entity);
                model.EntityState = System.Data.EntityState.Modified;
                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                contextSession.Update(model);
                var result = contextSession.SaveChanges();

                return(new ResultDTO()
                {
                    isSuccess = true,
                    Message = "sucess",
                    ResultCode = 0
                });
            }
            catch (Exception ex)
            {
                LogHelper.Info(string.Format("更新品类广告 CategoryAdvertiseBP.EditCategoryAdvertise, cancelTheOrderDTO:{0} ,{1}", JsonHelper.JsonSerializer(entity), ex), "BTP_CategoryAdvertise");
                return(new ResultDTO()
                {
                    isSuccess = true,
                    Message = ex.Message,
                    ResultCode = 0
                });
            }
        }
Пример #2
0
        /// <summary>
        /// 添加品类广告
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO CreateCategoryAdvertiseExt(Jinher.AMP.BTP.Deploy.CategoryAdvertiseDTO entity)
        {
            var ifCreate = CategoryAdvertise.ObjectSet().Where(o => o.PushTime <= entity.PushTime && o.PutTime >= entity.PutTime && o.CategoryId == entity.CategoryId).Count();

            if (ifCreate > 0)
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "同一分类下同一时间段只能有一个分类广告", isSuccess = false
                });
            }

            try
            {
                var model = CategoryAdvertise.CreateCategoryAdvertise();
                model.AdvertiseImg   = entity.AdvertiseImg;
                model.AdvertiseMedia = entity.AdvertiseMedia;
                model.AdvertiseName  = entity.AdvertiseName;
                model.AdvertiseType  = entity.AdvertiseType;
                model.CategoryId     = entity.CategoryId;
                model.FreeUrl        = entity.FreeUrl;
                model.PushTime       = entity.PushTime;
                model.PutTime        = entity.PutTime;
                model.spreadEnum     = entity.spreadEnum;
                //model.State = entity.State;
                if (entity.PutTime <= DateTime.Now && entity.PushTime >= DateTime.Now)
                {
                    entity.State = 1;
                }
                else if (entity.PushTime < DateTime.Now)
                {
                    entity.State = 2;
                }
                else if (entity.PutTime > DateTime.Now)
                {
                    entity.State = 0;
                }

                model.AdverID     = entity.AdverID;
                model.UserService = entity.UserService;

                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                contextSession.SaveObject(model);
                contextSession.SaveChanges();

                return(new ResultDTO {
                    ResultCode = 0, Message = "", isSuccess = true
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("添加添加品牌分类关系发生错误。参数:{0}", JsonHelper.JsonSerializer(entity)), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error", isSuccess = false
                });
            }
        }
Пример #3
0
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO EditCategoryAdvertise(Jinher.AMP.BTP.Deploy.CategoryAdvertiseDTO entity)
 {
     base.Do();
     return(this.Command.EditCategoryAdvertise(entity));
 }
Пример #4
0
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO CreateCategoryAdvertise(Jinher.AMP.BTP.Deploy.CategoryAdvertiseDTO entity)
 {
     base.Do(false);
     return(this.CreateCategoryAdvertiseExt(entity));
 }