public bool SaveBeautyPopUpWindowsConfig(BeautyPopUpWindowsConfig model, string userName) { var result = false; try { var log = new BeautyOprLog { LogType = "SaveBeautyPopUpWindowsConfig", IdentityID = $"{model.PKID}", OldValue = null, NewValue = Newtonsoft.Json.JsonConvert.SerializeObject(model), OperateUser = userName, Remarks = $"新增美容弹窗配置", }; if (model.PKID <= 0) { int pkid = 0; result = DALBeautyHomePageConfig.InsertBeautyPopUpConfig(model, out pkid); log.IdentityID = pkid.ToString(); } else { var oldModel = GetBeautyPopUpWindowsConfigById(model.PKID); if (oldModel.IsRegion) { oldModel.RegionList = GetBeautyPopUpWindowsRegionConfigs(oldModel.PKID)?.ToList(); } log.OldValue = Newtonsoft.Json.JsonConvert.SerializeObject(oldModel); log.Remarks = $"更新美容弹窗配置"; result = DALBeautyHomePageConfig.UpdateBeautyPopUpConfig(model); } if (result) { LoggerManager.InsertLog("BeautyOprLog", log); } } catch (Exception ex) { Logger.Log(Level.Error, ex, "SaveBeautyPopUpWindowsConfig"); throw ex; } return(result); }
public JsonResult SavePopUpWindowsConfig(BeautyPopUpWindowsConfig model) { string msg = string.Empty; bool result = false; try { result = BeautyHomePageConfigManager.SaveBeautyPopUpWindowsConfig(model, User.Identity.Name); if (result) { RefreshBeautyPopUpCache(); } } catch (Exception ex) { msg = ex.Message; } return(Json(new { Result = result, Msg = msg })); }
public static bool UpdateBeautyPopUpConfig(BeautyPopUpWindowsConfig model) { #region sql const string sql = @"Update [Tuhu_groupon].[dbo].[SE_BeautyPopUpWindowsConfig] WITH(ROWLOCK) SET [PlaceType]=ISNULL(@PlaceType,PlaceType) ,[Name]=ISNULL(@Name,Name) ,[Channel]=ISNULL(@Channel,Channel) ,[CategoryId]=ISNULL(@CategoryId,CategoryId) ,[StartVersion]=ISNULL(@StartVersion,StartVersion) ,[EndVersion]=ISNULL(@EndVersion,EndVersion) ,[StartTime]=ISNULL(@StartTime,StartTime) ,[EndTime]=ISNULL(@EndTime,EndTime) ,[BackGroundImage]=ISNULL(@BackGroundImage,BackGroundImage) ,[BackGroundLink]=ISNULL(@BackGroundLink,BackGroundLink) ,[PromotionInfo]=ISNULL(@PromotionInfo,PromotionInfo) ,[Status] =ISNULL(@Status,Status) ,[UpdateTime]=GetDate() ,[IsRegion]=ISNULL(@IsRegion,IsRegion) ,[PopUpLogo]=ISNULL(@PopUpLogo,PopUpLogo) WHERE PKID=@PKID AND ISDELETED=0 "; #endregion var sqlparameters = new SqlParameter[] { new SqlParameter("PlaceType", model.PlaceType), new SqlParameter("Name", model.Name), new SqlParameter("PromotionInfo", model.PromotionInfo), new SqlParameter("StartTime", model.StartTime), new SqlParameter("EndTime", model.EndTime), new SqlParameter("StartVersion", model.StartVersion), new SqlParameter("EndVersion", model.EndVersion), new SqlParameter("CategoryId", model.CategoryId), new SqlParameter("Channel", model.Channel), new SqlParameter("BackGroundImage", model.BackGroundImage), new SqlParameter("BackGroundLink", model.BackGroundLink), new SqlParameter("Status", model.Status), new SqlParameter("IsRegion", model.IsRegion), new SqlParameter("PopUpLogo", model.PopUpLogo), new SqlParameter("PKID", model.PKID), }; using (var con = new SqlConnection(connectionString)) { con.Open(); var tran = con.BeginTransaction(); var result = Convert.ToInt32(SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql, sqlparameters)); if (result > 0) { if (!model.IsRegion) { tran.Commit(); return(true); } model.RegionList.ForEach(f => f.BeautyPopUpId = model.PKID); var temp = InsertBeautyPopUpWindowsRegionConfigs(tran, model.RegionList); if (temp) { tran.Commit(); return(true); } else { tran.Rollback(); return(false); } } else { tran.Rollback(); return(false); } } }
public static bool InsertBeautyPopUpConfig(BeautyPopUpWindowsConfig model, out int pkid) { #region sql const string sql = @" Insert Into [Tuhu_groupon].[dbo].[SE_BeautyPopUpWindowsConfig]( [PlaceType] ,[Name] ,[Channel] ,[CategoryId] ,[StartVersion] ,[EndVersion] ,[StartTime] ,[EndTime] ,[BackGroundImage] ,[BackGroundLink] ,[PromotionInfo] ,[Status] ,[CreateTime] ,[UpdateTime] ,[IsDeleted] ,[IsRegion] ,[PopUpLogo]) Values( @PlaceType ,@Name ,@Channel ,@CategoryId ,@StartVersion ,@EndVersion ,@StartTime ,@EndTime ,@BackGroundImage ,@BackGroundLink ,@PromotionInfo ,@Status ,GetDate() ,GetDate() ,0 ,@IsRegion ,@PopUpLogo );SELECT @@Identity;"; #endregion var sqlparameters = new SqlParameter[] { new SqlParameter("PlaceType", model.PlaceType), new SqlParameter("Name", model.Name), new SqlParameter("PromotionInfo", model.PromotionInfo), new SqlParameter("StartTime", model.StartTime), new SqlParameter("EndTime", model.EndTime), new SqlParameter("StartVersion", model.StartVersion), new SqlParameter("EndVersion", model.EndVersion), new SqlParameter("CategoryId", model.CategoryId), new SqlParameter("Channel", model.Channel), new SqlParameter("BackGroundImage", model.BackGroundImage), new SqlParameter("BackGroundLink", model.BackGroundLink), new SqlParameter("Status", model.Status), new SqlParameter("IsRegion", model.IsRegion), new SqlParameter("PopUpLogo", model.PopUpLogo) }; using (var con = new SqlConnection(connectionString)) { con.Open(); var tran = con.BeginTransaction(); var result = Convert.ToInt32(SqlHelper.ExecuteScalar(tran, CommandType.Text, sql, sqlparameters)); pkid = result; if (result > 0) { if (!model.IsRegion) { tran.Commit(); return(true); } model.RegionList.ForEach(f => f.BeautyPopUpId = result); var temp = InsertBeautyPopUpWindowsRegionConfigs(tran, model.RegionList, true); if (temp) { tran.Commit(); return(true); } else { tran.Rollback(); return(false); } } else { tran.Rollback(); return(false); } } }