public ActionResult AddUserLevel() { UserLevelModel userLevel = new UserLevelModel(); userLevel.Initialize(); return(View(userLevel)); }
public ActionResult GetUserLevel(UserLevelModel userLevel) { string sFunctionName = "GetUserLevel()"; try { if (userLevel.UserTypeID == null) { userLevel.UserLevelList = ApplicationHelper.GetUserLevelsList(); } else { userLevel.UserLevelList = ApplicationHelper.GetUserLevelsList().Where(x => x.UserTypeID == userLevel.UserTypeID); } return(Json(new { UserLevelList = JsonConvert.SerializeObject(userLevel.UserLevelList), ResponseMessage = "Successfully fetched User Levels.", success = true })); } catch (Exception ex) { return(Json(new { ResponseMessage = "failed to Fetch User Levels.", success = false })); } }
public async Task <bool> SaveUserLevel(UserLevelModel userLevel) { await _context.UserLevel.AddAsync(userLevel); await _context.SaveChangesAsync(); return(true); }
public ActionResult ViewUserLevel() { UserLevelModel userLevel = new UserLevelModel(); userLevel.Initialize(); userLevel.UserLevelList = ApplicationHelper.GetUserLevelsList(); return(View(userLevel)); }
public ActionResult AddUserLevel(UserLevelModel userLevel) //public ActionResult AddUserLevel(string model) { string sFunctionName = "AddUserLevel()"; //UserLevelModel userLevel = (UserLevelModel)JsonConvert.DeserializeObject(model); ResponseModel Result = new ResponseModel(); try { Result = userLevel.AddUserLevel(userLevel.UserTypeID, userLevel.UserLevelName); if (Result.isSuccessful) { return(Json(new { ResponseMessage = "User Level \"" + userLevel.UserLevelName + "\" Successfully Added.", success = true })); //return RedirectToAction(Constants.WebPageAction.AddUserLevelDone, Constants.WebPageController.UserManagement, userLevel); } else { return(Json(new { ResponseMessage = "User Level \"" + userLevel.UserLevelName + "\" already exist.", success = false })); //return RedirectToAction(Constants.WebPageAction.Index, Constants.WebPageController.Error); } } catch (Exception ex) { Result.FailedWithException(); return(Json(new { ResponseMessage = "User Level \"" + userLevel.UserLevelName + "\" Failed to Add.", success = false })); } }
public ActionResult DeleteUserLevel(UserLevelModel userLevel) { string sFunctionName = "DeleteUserLevel()"; ResponseModel Result = new ResponseModel(); Result.FailedWithoutException(); try { Result = userLevel.DeleteUserLevel(); if (Result.isSuccessful) { return(Json(new { UserLevelList = JsonConvert.SerializeObject(userLevel.UserLevelList), ResponseMessage = "Successfully delete the " + userLevel.UserTypeName + " User Type " + userLevel.UserLevelName + " User Level.", success = true })); } else { return(Json(new { ResponseMessage = "Failed to delete the " + userLevel.UserTypeName + " User Type " + userLevel.UserLevelName + " User Level.", success = false })); } } catch (Exception ex) { return(Json(new { ResponseMessage = "Failed to delete the " + userLevel.UserTypeName + " User Type " + userLevel.UserLevelName + " User Level. Please try again later.", success = false })); } }
public ActionResult EditUserLevel(UserLevelModel userLevel) { string sFunctionName = "EditUserLevel()"; ResponseModel Result = new ResponseModel(); Result.FailedWithoutException(); try { Result = userLevel.EditUserLevel(); if (Result.isSuccessful) { return(Json(new { UserLevelList = JsonConvert.SerializeObject(userLevel.UserLevelList), ResponseMessage = "User Level " + userLevel.UserLevelName + " successfully edited to " + userLevel.NewUserLevelName + ".", success = true })); } else { return(Json(new { ResponseMessage = "Failed to edit the user level. Please try again.", success = false })); } } catch (Exception ex) { return(Json(new { ResponseMessage = "Failed to edit the user level. Please try again.", success = false })); } }
/// <summary> /// 用户升级(包括写用户变动日志) /// </summary> /// <param name="UserId">用户Id</param> /// <returns></returns> public bool UpgradeUser(int UserId) { try { int AscOrDesc = -1; //0 - 降级,1 - 升级,-1 不动 List <UserLevelModel> Items = dal.GetList().Where(x => x.LevelModel == 1).ToList(); int ToLevelId = GetLevelId(UserId, Items, out AscOrDesc); if (AscOrDesc != -1) { UsersBLL.Instance.UpdateUserLevel(UserId, ToLevelId); UserLevelModel LevelModel = Items.Where(x => x.LevelId == ToLevelId).ToList()[0]; UserLogsModel UserLog = new UserLogsModel(); UserLog.CreateTime = DateTime.Now; UserLog.UserId = UserId; if (AscOrDesc == 0) { UserLog.LogType = 0; UserLog.Reamark = "用户降级成为" + LevelModel.LevelName; } else if (AscOrDesc == 1) { UserLog.LogType = 1; UserLog.Reamark = "用户升级成为" + LevelModel.LevelName; } UserLogsBLL.Instance.Add(UserLog); } return(true); } catch (Exception ex) { LogHelper.WriteError("UserLevelBLL---->UpgradeUser发生异常,异常信息:" + ex.Message); return(false); } }
/// <summary> /// 保存等级 /// </summary> private void SaveLevel() { try { int LevelId = this.GetFormValue("levelid", 0); //等级Id int LevelType = this.GetFormValue("leveltype", 0); //等级类型 string LevelName = this.GetFormValue("levelname", ""); //等级名称 int BelongOneNum = this.GetFormValue("onenum", 0); //直接下线(不限等级)人数 int BuddyBelongOne = this.GetFormValue("belongone", 0); //直接下线代理商人数 int BuddyBelongTwo = this.GetFormValue("belongtwo", 0); //下下线代理商人数 int BelongOneOrderNum = this.GetFormValue("ordernum", 0); //直接下线下单人数 int LevelModel = this.GetFormValue("levelmodel", 0); //升级模式 string LevelMemo = this.GetFormValue("levelmemo", ""); //备注 List <UpgradeConditionModel> Items = new List <UpgradeConditionModel>(); UpgradeConditionModel item = new UpgradeConditionModel(); if (LevelType == 0) { item.ConditionKey = "UserCondition"; item.ConditionDecs = "平台注册用户"; item.ConditionValue = -1; item.ConditionType = 0; Items.Add(item); } else if (LevelType == 1) { item.ConditionKey = "BelongOneNum"; item.ConditionDecs = "直接下线(不限等级)>=<span style=\"color:red;\">{Value}</span>人"; item.ConditionValue = BelongOneNum; item.ConditionType = 0; Items.Add(item); } else if (LevelType == 2) { item.ConditionKey = "BuddyBelongOne"; item.ConditionDecs = "直接下线代理商>=<span style=\"color:red;\">{Value}</span>人"; item.ConditionValue = BuddyBelongOne; item.ConditionType = 0; Items.Add(item); item = new UpgradeConditionModel(); item.ConditionKey = "BuddyBelongTwo"; item.ConditionDecs = "下下线代理商>=<span style=\"color:red;\">{Value}</span>人"; item.ConditionValue = BuddyBelongTwo; item.ConditionType = 0; Items.Add(item); item = new UpgradeConditionModel(); item.ConditionKey = "BelongOneOrderNum"; item.ConditionDecs = "直接下线>=<span style=\"color:red;\">{Value}</span>人下单"; item.ConditionValue = BelongOneOrderNum; item.ConditionType = 1; Items.Add(item); } else if (LevelType == 3 || LevelType == 4) { item.ConditionKey = "CompanyCondition"; item.ConditionDecs = "系统开通"; item.ConditionValue = -1; item.ConditionType = 0; Items.Add(item); } int TableLevelNo = UserLevelBLL.Instance.GetLevelNo(LevelType); UserLevelModel model = new UserLevelModel(); model.LevelId = LevelId; model.LevelName = LevelName; if (TableLevelNo == -1) { model.LevelNo = 0; } else { model.LevelNo = TableLevelNo + 1; } model.LevelType = (Core.Enum.HQEnums.UserLevelTypeOptions)LevelType; model.Remark = LevelMemo; model.LevelModel = LevelModel; model.UpgradeCondition = Items; if (model.LevelId > 0) { if (UserLevelBLL.Instance.Update(model)) { this.code = 1; this.msg = "修改成功!"; return; } else { this.code = -1; this.msg = "修改失败,请刷新后重试!"; return; } } else { model.Createtime = DateTime.Now; if (UserLevelBLL.Instance.Add(model) > 0) { this.code = 1; this.msg = "添加成功!"; return; } else { this.code = -1; this.msg = "添加失败,请刷新后重试!"; return; } } } catch (Exception ex) { this.code = -1; this.msg = "请求发生异常,请刷新后重试!"; LogHelper.WriteError("UserLevelHandler---->SaveLevel方法发生异常,异常信息:" + ex.Message); return; } }
public ActionResult AddUserLevelDone(UserLevelModel userLevel) { return(View()); }
public ActionResult result([FromBody] UserLevelModel model) { return(Ok()); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(UserLevelModel model) { return(dal.Add(model)); }
/// <summary> /// 获得等级Id(返回-1则不升级) /// </summary> /// <param name="UserId">用户Id</param> /// <param name="AscOrDesc">升级还是降级(0-降级,1-升级,-1 不动)</param> /// <returns></returns> public int GetLevelId(int UserId, List <UserLevelModel> Items, out int AscOrDesc) { int ToLevelId = -1; AscOrDesc = -1; int MyMemberNum = UsersBLL.Instance.GetMyMemberNum(UserId); int MyBelongOneNum = UsersBLL.Instance.GetMyBelongOneBuddyNum(UserId); int MyBelongTwoNum = UsersBLL.Instance.GetMyBelongTwoBuddyNum(UserId); int MyMemberOrderNum = OrdersBLL.Instance.GetMyMemberOrderNum(UserId); #region 代理商 List <UserLevelModel> AgentItems = Items.Where(x => x.LevelType == Enum.HQEnums.UserLevelTypeOptions.代理商).OrderBy(x => x.LevelNo).ToList(); if (AgentItems.Count > 0) { foreach (UserLevelModel item in AgentItems) { int BelongOneNum = -1; foreach (UpgradeConditionModel model in item.UpgradeCondition) { if (model.ConditionKey == "BelongOneNum") { BelongOneNum = model.ConditionValue; } } if (BelongOneNum > -1 && MyMemberNum >= BelongOneNum) { ToLevelId = item.LevelId; } } } #endregion #region 运营商 List <UserLevelModel> OperatorItems = Items.Where(x => x.LevelType == Enum.HQEnums.UserLevelTypeOptions.运营商).ToList(); if (OperatorItems.Count > 0) { foreach (UserLevelModel item in OperatorItems) { int BuddyBelongOne = -1; int BuddyBelongTwo = -1; int BelongOneOrderNum = -1; foreach (UpgradeConditionModel model in item.UpgradeCondition) { if (model.ConditionKey == "BuddyBelongOne") { BuddyBelongOne = model.ConditionValue; } if (model.ConditionKey == "BuddyBelongTwo") { BuddyBelongTwo = model.ConditionValue; } if (model.ConditionKey == "BelongOneOrderNum") { BelongOneOrderNum = model.ConditionValue; } } if ((MyBelongOneNum >= BuddyBelongOne && MyBelongTwoNum >= BuddyBelongTwo) || MyMemberOrderNum >= BelongOneOrderNum) { ToLevelId = item.LevelId; } } } #endregion if (ToLevelId > -1) { UsersModel userInfo = UsersBLL.Instance.GetModel(UserId); UserLevelModel ToLevelModel = Items.Where(x => x.LevelId == ToLevelId).ToList()[0]; UserLevelModel UserLevelModel = Items.Where(x => x.LevelId == userInfo.LevelId).ToList()[0]; if (ToLevelModel.LevelType > UserLevelModel.LevelType) { AscOrDesc = 1; } else if (ToLevelModel.LevelType == UserLevelModel.LevelType) { if (ToLevelModel.LevelNo > UserLevelModel.LevelNo) { AscOrDesc = 1; } else if (ToLevelModel.LevelNo == UserLevelModel.LevelNo) { AscOrDesc = -1; } else { AscOrDesc = 0; } } else { AscOrDesc = 0; } } return(ToLevelId); }