public JsonResult UserSiteAdd(AddUserSiteReq parames) { PublicUserModel loginUser = this.GetLoginUser(); if (parames.webBasicId > 0) { bool flag = false; try { flag = UserVerifier.CheckSite(parames.webBasicId, parames.loginName, parames.loginPwd); } catch (Exception) { } if (!flag) { return(Json(new { msg = "帐号或密码错误!" })); } #region 添加 UserSiteManageBll userSiteManageBll = new UserSiteManageBll(); UserSiteManageModel userSiteManageModel = new UserSiteManageModel() { SiteID = parames.webBasicId, UserID = loginUser.UserID, SiteStatus = 1, SiteUserName = parames.loginName, SiteUserPwd = parames.loginPwd }; userSiteManageBll.UserSiteManageAdd(userSiteManageModel); #endregion #region 绑定网站帐号任务 DoTask(loginUser.UserID, PointsEnum.First_BindSiteAccount); #endregion if (loginUser.VipType < 1) { PublicUser user = ncBase.CurrentEntities.PublicUser.Where(o => o.UserID == loginUser.UserID).FirstOrDefault(); if (user.IsNoNull()) { VipType vipType = ncBase.CurrentEntities.VipType.Where(o => o.VipTypeID == 2).FirstOrDefault(); user.VipType = vipType.IsNoNull() ? vipType.VipTypeID : 1; user.MaxStock = vipType.IsNoNull() ? Convert.ToInt32(vipType.MaxStock) : 50; user.PublishNum = vipType.IsNoNull() ? Convert.ToInt32(vipType.PublishNum) : 2; ncBase.CurrentEntities.SaveChanges(); } } return(Json(new { msg = "添加成功" })); } else { return(Json(new { msg = "添加失败" })); } }
public ApiResponse UserSiteManageAdd([FromBody] SiteUserReq model) { int gainPoints = 0; string gainPointsMsg = ""; if (model.SiteID > 0) { bool flag = false; try { flag = UserVerifier.CheckSite(model.SiteID, model.UserName, model.Password); } catch (Exception) { } if (!flag) { return(new ApiResponse(Metas.ACCOUNT_OR_PASSWORD_WRONG)); } UserSiteManageBll userSiteManageBll = new UserSiteManageBll(); UserSiteManageModel userSiteManageModel = new UserSiteManageModel() { SiteID = model.SiteID, UserID = GetCurrentUserId(), SiteStatus = 1, SiteUserName = model.UserName, SiteUserPwd = model.Password }; int row = userSiteManageBll.UserSiteManageAdd(userSiteManageModel); if (row > 0) { DoTask(GetCurrentUserId(), PointsEnum.First_BindSiteAccount, out gainPoints); gainPointsMsg = "完成“绑定网站帐号”任务"; var result = new { GainPoints = gainPoints, GainPointsMsg = gainPointsMsg }; return(new ApiResponse(Metas.SUCCESS, result)); } else { return(new ApiResponse(Metas.SITE_EXISTS)); } } else { return(new ApiResponse(Metas.SITE_NOT_EXISTS)); // Todo:这边没有判断站点是否存在、关闭 } }
public JsonResult CheckSite(int siteId) { int uid = this.GetLoginUser().UserID; UserBll userBll = new UserBll(); UserSiteManageBll userSiteManageBll = new UserSiteManageBll(); List <UserSiteManageModel> userSiteManageList = userSiteManageBll.GetUserSiteListByUserId(this.GetLoginUser().UserID);//用户关联的站点 UserSiteManageModel userSiteItem = userSiteManageList.Where(s => s.SiteID == siteId).FirstOrDefault(); if (userSiteItem.IsNull()) { return(Json(new { msg = "您还未绑定帐号!" })); } bool flag = false; try { flag = UserVerifier.CheckSite(siteId, userSiteItem.SiteUserName, userSiteItem.SiteUserPwd); } catch (Exception) { } if (flag) { UserSiteManage siteManage = ncBase.CurrentEntities.UserSiteManage.Where( o => o.SiteID == siteId && o.SiteUserName == userSiteItem.SiteUserName && o.UserID == uid).FirstOrDefault(); if (siteManage.IsNoNull()) { siteManage.SiteStatus = BitConverter.GetBytes(1)[0]; siteManage.BanTime = DateTime.Now; ncBase.CurrentEntities.SaveChanges(); return(Json(new { msg = "账号验证成功并已经激活使用!" })); } return(Json(new { msg = "未知错误!" })); } return(Json(new { msg = "账号密码不正确!" })); }