public ActionResult Edit(BeautyHomePageConfig model)
        {
            try
            {
                if (model.Id != 0)
                {
                    if (BeautyHomePageConfigManager.UpdateBeautyHomePageConfig(model))
                    {
                        CleanCahce(model.Channel, model.Type);
                    }
                }
                else
                {
                    int outId = 0;
                    if (BeautyHomePageConfigManager.InsertBeautyHomePageConfig(model, ref outId))
                    {
                        CleanCahce(model.Channel, model.Type);
                    }
                }

                return(Json(true));
            }
            catch (Exception ex)
            {
                return(Json(false));

                throw ex;
            }
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(BeautyHomePageConfig model)
        {
            try
            {
                if (model.Id != 0)
                {
                    if (BeautyHomePageConfigManager.UpdateBeautyHomePageConfig(model))
                    {
                        CleanCahce(model.Channel, model.Type);
                    }
                    var beautyServiceProxy = new BeautyServiceProxy();
                    await beautyServiceProxy.RefreshModuleCacheAsync(model.Id);

                    await beautyServiceProxy.RemoveCacheKeyAsync($"BeautyCategoriesPrefixV2-{model.Id}");
                }
                else
                {
                    int outId = 0;
                    if (BeautyHomePageConfigManager.InsertBeautyHomePageConfig(model, ref outId))
                    {
                        CleanCahce(model.Channel, model.Type);
                    }
                }

                return(Json(true));
            }
            catch (Exception ex)
            {
                return(Json(false));

                throw ex;
            }
        }
 public bool InsertBeautyHomePageConfig(BeautyHomePageConfig model, ref int id)
 {
     try
     {
         return(DALBeautyHomePageConfig.InsertBeautyHomePageConfig(model, ref id));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "InsertBeautyHomePageConfig");
         throw ex;
     }
 }
 public bool UpdateBeautyHomePageConfig(BeautyHomePageConfig model)
 {
     try
     {
         return(DALBeautyHomePageConfig.UpdateBeautyHomePageConfig(model));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "UpdateBeautyHomePageConfig");
         throw ex;
     }
 }
 public List <BeautyHomePageConfig> GetBeautyHomePageConfigList(BeautyHomePageConfig model, int pageSize, int pageIndex, out int recordCount)
 {
     try
     {
         return(DALBeautyHomePageConfig.GetBeautyHomePageConfigList(model, pageSize, pageIndex, out recordCount));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "GetBeautyHomePageConfigList");
         throw ex;
     }
 }
        public static List <BeautyHomePageConfig> GetBeautyHomePageConfigList(BeautyHomePageConfig model, int pageSize, int pageIndex, out int recordCount)
        {
            string sql      = @" 
                        SELECT  *
                        FROM    ( 
                                 SELECT ROW_NUMBER() OVER ( ORDER BY A.Id DESC ) AS ROWNUMBER ,
                                        A.[Id] ,
                                        [Type] ,
                                        [StartVersion] ,
                                        [EndVersion] ,
                                        A.[Name] ,
                                        [Sort] ,
                                        [Title] ,
                                        [SmallTitle] ,
                                        [Channel] ,
                                        A.[CategoryID] ,
                                        [CategoryName] ,
                                        [Link] ,
                                        [Icon] ,
                                        A.[Status] ,
                                        [IsRegion] ,
                                        [CarLevel] ,
                                        A.[ActivityId] ,
                                        [StartTime] ,
                                        [EndTime] ,
                                        A.[CreateTime] ,
                                        A.[UpdateTime] ,
                                        b.Name AS ActivityName,
                                        ActivityPKID,
                                        Banner
                                 FROM   [Tuhu_Groupon].[dbo].SE_BeautyHomePageConfig AS A WITH ( NOLOCK )
                                        LEFT JOIN Tuhu_Groupon.dbo.ShopBeautyAcitivity AS b WITH ( NOLOCK ) ON A.ActivityPKID = b.Id
                                  WHERE     1 = 1  AND Type=@Type 
                                ) AS PG
                        WHERE   PG.ROWNUMBER BETWEEN STR(( @PageIndex - 1 ) * @PageSize + 1)
                                             AND     STR(@PageIndex * @PageSize)
                          ";
            string sqlCount = @"SELECT COUNT(1) FROM [Tuhu_Groupon].[dbo].[SE_BeautyHomePageConfig] WITH (NOLOCK)  WHERE 1=1 AND Type=@Type  ";

            var sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@PageSize", pageSize),
                new SqlParameter("@PageIndex", pageIndex),
                new SqlParameter("@Type", model.Type)
            };

            recordCount = (int)SqlHelper.ExecuteScalar(connOnRead, CommandType.Text, sqlCount, sqlParameters);

            return(SqlHelper.ExecuteDataTable(connOnRead, CommandType.Text, sql, sqlParameters).ConvertTo <BeautyHomePageConfig>().ToList());
        }
        public ActionResult List(BeautyHomePageConfig model, int pageIndex = 1, int pageSize = 15)
        {
            int    count  = 0;
            string strSql = string.Empty;

            var lists = BeautyHomePageConfigManager.GetBeautyHomePageConfigList(model, pageSize, pageIndex, out count);

            var list  = new OutData <List <BeautyHomePageConfig>, int>(lists, count);
            var pager = new PagerModel(pageIndex, pageSize)
            {
                TotalItem = count
            };

            return(View(new ListModel <BeautyHomePageConfig>(list.ReturnValue, pager)));
        }
        public ActionResult EditShopConfig(BeautyHomePageConfig model)
        {
            var result = false;

            model.StartTime = DateTime.Now;
            model.EndTime   = new DateTime(2999, 12, 31);
            model.Type      = (short)(model.Type + 1000);
            if (model.Id != 0)
            {
                result = BeautyHomePageConfigManager.UpdateBeautyHomePageConfig(model);
            }
            else
            {
                int outId = 0;
                result = BeautyHomePageConfigManager.InsertBeautyHomePageConfig(model, ref outId);
            }
            return(Json(new { Status = result }));
        }
        public JsonResult SaveBeautyBannerConfig(BeautyHomePageConfig model)
        {
            var    result = false;
            string msg    = string.Empty;

            try
            {
                var log = new BeautyOprLog
                {
                    LogType     = "SaveBeautyBannerConfig",
                    IdentityID  = $"{model.Id}",
                    OldValue    = null,
                    NewValue    = JsonConvert.SerializeObject(model),
                    OperateUser = User.Identity.Name,
                    Remarks     = $"新增美容首页Banner配置",
                };
                if (model.Id > 0)
                {
                    var oldModel = BeautyHomePageConfigManager.GetBeautyHomePageConfigById(model.Id) ?? new BeautyHomePageConfig();
                    oldModel.Region = JsonConvert.SerializeObject(MeiRongAcitivityConfigManager.GetRegion(model.Id, 3));
                    log.OldValue    = JsonConvert.SerializeObject(oldModel);
                    log.Remarks     = $"更新美容首页Banner配置";

                    result = BeautyHomePageConfigManager.UpdateBeautyHomePageBannerConfig(model);
                }
                else
                {
                    int outId = 0;
                    result = BeautyHomePageConfigManager.InsertBeautyHomePageBannerConfig(model, ref outId);

                    log.IdentityID = outId.ToString();
                }
                if (result)
                {
                    LoggerManager.InsertLog("BeautyOprLog", log);
                    UpdateBeautyBannerCache(model.Channel);
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            return(Json(new { Result = result, Msg = msg }));
        }
        public ActionResult Edit(short type, int id = 0)
        {
            ViewBag.ProvinceList = MeiRongAcitivityConfigManager.GetRegion(0);

            if (id == 0)
            {
                BeautyHomePageConfig model = new BeautyHomePageConfig();
                model.StartTime = DateTime.Now;
                model.EndTime   = DateTime.Now.AddDays(30);
                model.Status    = true;
                model.Channel   = "ios";
                model.Type      = type;
                return(View(model));
            }
            else
            {
                BeautyHomePageConfig model = BeautyHomePageConfigManager.GetBeautyHomePageConfigById(id);
                model.RegionList = MeiRongAcitivityConfigManager.GetRegionRelation(model.Id, 2);
                return(View(model));
            }
        }
        public static bool UpdateBeautyHomePageBannerConfig(BeautyHomePageConfig model)
        {
            const string sql          = @"UPDATE Tuhu_Groupon.dbo.SE_BeautyHomePageConfig SET                                      
                                           Type=@Type
                                          ,StartVersion=@StartVersion
                                          ,EndVersion=@EndVersion
                                          ,Name=@Name
                                          ,Sort=@Sort
                                          ,Title=@Title
                                          ,SmallTitle=@SmallTitle
                                          ,Channel=@Channel
                                          ,CategoryID=@CategoryID
                                          ,CategoryName=@CategoryName
                                          ,Link=@Link
                                          ,Icon=@Icon  
                                          ,Banner=@Banner 
                                          ,Status=@Status                                       
                                          ,IsRegion=@IsRegion
                                          ,CarLevel=@CarLevel
                                          ,ActivityId=@ActivityId  
                                          ,ActivityPKID=@ActivityPKID
                                          ,StartTime=@StartTime
                                          ,EndTime=@EndTime
                                          ,UpdateTime=GETDATE()                                        
                                WHERE Id=@Id";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@ActivityPKID", model.ActivityPKID),
                new SqlParameter("@ActivityId", model.ActivityId ?? string.Empty),
                new SqlParameter("@Banner", model.Banner ?? string.Empty),
                new SqlParameter("@CarLevel", model.CarLevel),
                new SqlParameter("@CategoryID", model.CategoryID),
                new SqlParameter("@CategoryName", model.CategoryName ?? string.Empty),
                new SqlParameter("@Channel", model.Channel ?? string.Empty),
                new SqlParameter("@EndTime", model.EndTime),
                new SqlParameter("@EndVersion", model.EndVersion ?? string.Empty),
                new SqlParameter("@Icon", model.Icon ?? string.Empty),
                new SqlParameter("@IsRegion", model.IsRegion),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@Link", model.Link ?? string.Empty),
                new SqlParameter("@Name", model.Name ?? string.Empty),
                new SqlParameter("@SmallTitle", model.SmallTitle ?? string.Empty),
                new SqlParameter("@Sort", model.Sort),
                new SqlParameter("@StartTime", model.StartTime),
                new SqlParameter("@StartVersion", model.StartVersion ?? string.Empty),
                new SqlParameter("@Title", model.Title ?? string.Empty),
                new SqlParameter("@Type", model.Type),
                new SqlParameter("@Id", model.Id)
            };

            List <RegionRelation> region = JsonConvert.DeserializeObject <List <RegionRelation> >(model.Region ?? string.Empty) ?? new List <RegionRelation>();

            string strConn          = ConfigurationManager.ConnectionStrings["Tuhu_Groupon"].ConnectionString;
            string connectionString = SecurityHelp.IsBase64Formatted(strConn) ? SecurityHelp.DecryptAES(strConn) : strConn;

            SqlConnection conn = new SqlConnection(connectionString);

            conn.Open();
            SqlTransaction tran = conn.BeginTransaction();

            try
            {
                SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql, sqlParameter);

                DALMeiRongAcitivityConfig.DeleteRegionRelation(model.Id, tran);

                if (model.IsRegion)
                {
                    foreach (var item in region)
                    {
                        item.Type       = 3;
                        item.ActivityId = model.Id;
                        DALMeiRongAcitivityConfig.InsertRegionRelation(item, tran);
                    }
                }


                tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                return(false);

                throw ex;
            }
            finally
            {
                tran.Dispose();
            }
        }
        public static bool InsertBeautyHomePageBannerConfig(BeautyHomePageConfig model, ref int id)
        {
            const string sql = @"INSERT INTO Tuhu_Groupon..SE_BeautyHomePageConfig
                                          (    
                                           [Type]
                                          ,[StartVersion]
                                          ,[EndVersion]
                                          ,[Name]
                                          ,[Sort]
                                          ,[Title]
                                          ,[SmallTitle]
                                          ,[Channel]
                                          ,[CategoryID]
                                          ,[CategoryName]
                                          ,[Link]
                                          ,[Icon]
                                          ,[Status]                                        
                                          ,[IsRegion]
                                          ,[CarLevel]
                                          ,[ActivityId]
                                          ,[StartTime]
                                          ,[EndTime]
                                          ,[CreateTime]
                                          ,[UpdateTime]
                                          ,[ActivityPKID]
                                          ,[Banner]
                                          )
                                  VALUES(  
                                           @Type
                                          ,@StartVersion
                                          ,@EndVersion
                                          ,@Name
                                          ,@Sort
                                          ,@Title
                                          ,@SmallTitle
                                          ,@Channel
                                          ,@CategoryID
                                          ,@CategoryName
                                          ,@Link
                                          ,@Icon
                                          ,@Status                                        
                                          ,@IsRegion
                                          ,@CarLevel
                                          ,@ActivityId
                                          ,@StartTime
                                          ,@EndTime
                                          ,GETDATE()
                                          ,GETDATE()  
                                          ,@ActivityPKID 
                                          ,@Banner                                
                                        )SELECT @@IDENTITY";

            var sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@ActivityPKID", model.ActivityPKID),
                new SqlParameter("@ActivityId", model.ActivityId ?? string.Empty),
                new SqlParameter("@Banner", model.Banner ?? string.Empty),
                new SqlParameter("@CarLevel", model.CarLevel),
                new SqlParameter("@CategoryID", model.CategoryID),
                new SqlParameter("@CategoryName", model.CategoryName ?? string.Empty),
                new SqlParameter("@Channel", model.Channel ?? string.Empty),
                new SqlParameter("@EndTime", model.EndTime),
                new SqlParameter("@EndVersion", model.EndVersion ?? string.Empty),
                new SqlParameter("@Icon", model.Icon ?? string.Empty),
                new SqlParameter("@IsRegion", model.IsRegion),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@Link", model.Link ?? string.Empty),
                new SqlParameter("@Name", model.Name ?? string.Empty),
                new SqlParameter("@SmallTitle", model.SmallTitle ?? string.Empty),
                new SqlParameter("@Sort", model.Sort),
                new SqlParameter("@StartTime", model.StartTime),
                new SqlParameter("@StartVersion", model.StartVersion ?? string.Empty),
                new SqlParameter("@Title", model.Title ?? string.Empty),
                new SqlParameter("@Type", model.Type),
            };


            List <RegionRelation> region = JsonConvert.DeserializeObject <List <RegionRelation> >(model.Region ?? "") ?? new List <RegionRelation>();

            string strConn          = ConfigurationManager.ConnectionStrings["Tuhu_Groupon"].ConnectionString;
            string connectionString = SecurityHelp.IsBase64Formatted(strConn) ? SecurityHelp.DecryptAES(strConn) : strConn;

            SqlConnection conn = new SqlConnection(connectionString);

            conn.Open();
            SqlTransaction tran = conn.BeginTransaction();

            try
            {
                id = Convert.ToInt32(SqlHelper.ExecuteScalar(tran, CommandType.Text, sql, sqlParameter));

                DALMeiRongAcitivityConfig.DeleteRegionRelation(model.Id, tran);

                foreach (var item in region)
                {
                    item.Type       = 3;
                    item.ActivityId = id;
                    DALMeiRongAcitivityConfig.InsertRegionRelation(item, tran);
                }

                tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                return(false);

                throw ex;
            }
            finally
            {
                tran.Dispose();
            }
        }