//好友相册页面 public ActionResult albumPage() { string uid = ((User)Session["user"]).User_Id; //获取好友个人信息 string fid = Request.QueryString["friend_id"]; User friend = new User(); friend.User_Id = fid; UserSql usl = new UserSql(); friend = usl.getUserInfo(friend); ViewBag.friend = friend; //获取好友相册 AlbumSql asql = new AlbumSql(); //获取好友相册 Album album = new Album(); try { album.User_Id = friend.User_Id; } catch (NullReferenceException) { return(RedirectToAction("index", "Login")); } List <Album> list = asql.getFriendAlbumInfo(album); ViewBag.list = list; return(View()); }
public async Task GetAsync_OwnerDisabled_ThrowsException() { TestingObject <ReportService> testingObject = this.GetTestingObject(); Guid reportIdArg = Guid.NewGuid(); var mockDbContext = testingObject.GetDependency <Mock <IDatabaseContext> >(); var report = new ReportMetadataSql { Created = DateTime.UtcNow.AddYears(-2), OwnerId = Guid.NewGuid() }; mockDbContext .Setup(m => m.FindSingleAsync <ReportMetadataSql>(It.Is <Guid>(id => id == reportIdArg))) .ReturnsAsync(report); var owner = new UserSql { Enabled = false }; mockDbContext .Setup(m => m.FindSingleAsync <UserSql>(It.Is <Guid>(id => id == report.OwnerId))) .ReturnsAsync(owner); ReportService reportService = testingObject.GetResolvedTestingObject(); await Assert.ThrowsAsync <Exception>(async() => await reportService.GetAsync(reportIdArg)); }
public IActionResult PutMethod([FromForm] UserSql user) { if (ModelState.IsValid && user != null && !(string.IsNullOrEmpty(user.UserName))) { string query = @"update dbo.UserName set UserName='******' where Id=" + user.Id + @""; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("CommandsConnection"); SqlDataReader myReader; using (SqlConnection myCon = new SqlConnection(sqlDataSource)) { myCon.Open(); using (SqlCommand myCommand = new SqlCommand(query, myCon)) { myReader = myCommand.ExecuteReader(); table.Load(myReader); myReader.Close(); myCon.Close(); } } return(View()); } else { return(View("Bad")); } }
//登录 获取用户信息从数据库中验证 public ActionResult Login(User user) { UserSql us = new UserSql(); if (us.judgeUser(user)) { User u = us.getUserInfo(user); //应该验证是否封号 if (u.User_State == 0) { //return 封号view; return(View("IdBlocked")); } Session["LoginState"] = "已登录"; //获取用户的所有信息. 存放session Session["user"] = (User)u; return(RedirectToAction("Index", "FFTXIndex")); } else { return(View("LoginFail")); } }
public ActionResult changeHeadImg(HttpPostedFileBase file) { if (file == null) { return(RedirectToAction("Index", "Manage", new { headImgState = 0 })); } else { //根据用户名创建文件夹保存照片 string user_id = ((User)Session["user"]).User_Id; string path = Request.MapPath("~/Content/headimg/"); string hz = file.FileName.Substring(file.FileName.LastIndexOf(".")); if (Directory.Exists(path) == false)//如果不存在就创建file文件夹 { Directory.CreateDirectory(path); } string fname = user_id + hz; file.SaveAs(path + fname);//保存文件 //更新数据库 User u = new User(); u.User_Id = user_id; UserSql us = new UserSql(); u = us.getUserInfo(u); u.User_HeadImg = "/Content/headimg/" + fname; us.changeHeadImg(u); //更新数据库 return(RedirectToAction("Index", "Manage", new { headImgState = 1 })); } }
public async Task <BaseResponse <int> > CreateAsync(UserSql model) { var p = AddOutputParam("id"); p.Add("code", model.Code); p.Add("userName", model.UserName); p.Add("password", model.Password); p.Add("fullName", model.FullName); p.Add("phone", model.Phone); p.Add("roleId", model.RoleId); p.Add("email", model.Email); p.Add("createdby", model.CreatedBy); try { using (var con = GetConnection()) { await con.ExecuteAsync("sp_Employee_InsertUser_v2", p, commandType : CommandType.StoredProcedure); return(BaseResponse <int> .Create(p.Get <int>("id"))); } } catch (Exception e) { return(BaseResponse <int> .Create(0, GetException(e))); } }
public AccountController() { UserSql userSql = new UserSql(base.WebDbSqlConnectionString); PersonSql personSql = new PersonSql(base.WebDbSqlConnectionString); this.UserManager = new UserManager(userSql); this.PersonManager = new PersonManager(personSql); }
public async Task <ReportMetadata> GetAsync(Guid reportId) { if (reportId == Guid.Empty) { throw new ArgumentException("Report id must be provided", nameof(reportId)); } ReportMetadataSql reportSql = await this.DbContext.FindSingleAsync <ReportMetadataSql>(reportId); if (reportSql == null) { throw new Exception($"Report '{reportId}' was not found."); } // if report is older than 3 years, dont return it if (reportSql.Created.AddYears(3) < DateTime.UtcNow) { throw new Exception($"Report '{reportId}' is too old and will not be retrieved."); } UserSql ownerSql = await this.DbContext.FindSingleAsync <UserSql>(reportSql.OwnerId); if (ownerSql == null) { throw new Exception($"User '{reportSql.OwnerId}' not found."); } // if owner of report is disabled, dont return it if (!ownerSql.Enabled) { throw new Exception($"Report '{reportId}' is owned by a disabled user and will not be retrieved."); } User owner = UserSql.ToEntity(ownerSql); string authorFullName = UserUtil.GetFullName(owner.FirstName, owner.LastName); // modify title based on whether it's been updated if (reportSql.LastUpdated.HasValue) { reportSql.Title += " (Revision)"; } else { reportSql.Title += " (Original)"; } return(new ReportMetadata { Id = reportSql.Id, LastUpdated = reportSql.LastUpdated, LastRevisionById = reportSql.LastRevisionById, Title = reportSql.Title, Created = reportSql.Created, AuthorFullName = authorFullName }); }
public LoginWindow() { Sqlmanager sqlmanager = new Sqlmanager(); Datamanager datamanager = new Datamanager(); UserSql userSql = new UserSql(); GameSql gameSql = new GameSql(); DevelopSql developSql = new DevelopSql(); InitializeComponent(); }
public async Task <User> GetAsync(Guid userId) { if (userId == Guid.Empty) { throw new ArgumentException("Must specify a user id.", nameof(userId)); } UserSql userSql = await this.DbContext.FindSingleAsync <UserSql>(userId); if (userSql == null) { throw new Exception($"User '{userId}' was not found."); } return(UserSql.ToEntity(userSql)); }
public ActionResult forgetPassword(User user) { UserSql us = new UserSql(); //成功返回页面 string pwd = us.forgetPassword(user); if (pwd == null) { //找回密码失败 return(Content("信息验证失败,请重新输入")); } else { ViewBag.pwd = pwd; return(Content("您的密码是:" + pwd)); } }
//申请解封 public ActionResult applyDeblock(UserRequest ur) { ur.Request_Time = DateTime.Now; UserSql us = new UserSql(); if (us.requestDeblock(ur)) { Response.Write("申请完成,请等待"); Response.End(); } else { Response.Write("申请失败,请重试"); Response.End(); } return(View()); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); qLHS = new QLHS(); lg = new frmLogin(); quanLyChung = new QuanLyChung(); hocSinhSql = new HocSinhSql(); hs = new HocSinh(); giaoVienSql = new GiaoVienSql(); gv = new GiaoVien(); qLGV = new QLGV(); giangDay = new GiangDay(); giangDaySql = new GiangDaySql(); lop = new Lop(); lopSql = new LopSql(); diem = new Diem(); diemSql = new DiemSql(); userSql = new UserSql(); Application.Run(lg); }
//修改个人信息 public ActionResult changeInfo(User user) { //获取原本信息 User cuser = (User)Session["user"]; //用新的信息覆盖 cuser.User_Name = user.User_Name; cuser.User_Sex = user.User_Sex; cuser.User_Phone = user.User_Phone; cuser.User_Email = user.User_Email; //进行信息修改 if (new UserSql().updateUserInfo(cuser)) { Session["user"] = new UserSql().getUserInfo(cuser); return(RedirectToAction("Index", "Manage", new { infoState = 1 })); } else { return(RedirectToAction("Index", "Manage", new { infoState = 0 })); } }
public ActionResult searchReason() { string uid = Request.QueryString["user_id"]; //获取被封用户详细信息 User u = new User(); u.User_Id = uid; UserSql us = new UserSql(); u = us.getUserInfo(u); ViewBag.blockUser = u; //获取封号原因 AdminOperate ao = new AdminOperate(); AdminSql asl = new AdminSql(); ao = asl.getAdminOperateByuid(u); ViewBag.operate = ao; return(View()); }
public ActionResult Test(string id, string question, string answer) { User user = new User(); user.User_Id = id; user.Password_Question = question; user.Password_Answer = answer; UserSql us = new UserSql(); //成功返回页面 string pwd = us.forgetPassword(user); if (pwd == null) { //找回密码失败 return(Content("信息验证失败,请重新输入")); } else { ViewBag.pwd = pwd; return(Content("您的密码是:" + pwd)); } }
//注册事件 public ActionResult Register(User user) { UserSql us = new UserSql(); int regist_info = us.addUser(user); if (regist_info == 1) { //注册成功 创建 我的好友分组 Group p = new Group(); p.User_Id = user.User_Id; p.Group_Name = "我的好友"; new GroupSql().addGroupFriendInfo(p); //注册成功 创建 自己的站内信 return(RedirectToAction("Index", "Login"));; } else { Response.Write("注册失败了注册失败了注册失败了"); return(View("index")); } }
async Task Init(SocketUser author) { if (author == null) { throw new Exception("author is null"); } Id = author.Id; Username = author.Username; //Abbybot.print(sgu.Guild.Name); if (author is SocketGuildUser sgu) { isGuild = true; GuildId = sgu.Guild.Id; Nickname = sgu.Nickname; var err = Apis.Discord.__client.GetGuild(sgu.Guild.Id).GetUser(sgu.Id); Roles = await RoleManager.GetUserRoles(err); admin = sgu.Roles.ToList().Any(rs => rs.Permissions.Administrator); Ratings = (await RoleManager.GetRatings(Roles)).ToList(); } var eeeer = (isGuild && Nickname != null) ? Nickname : Username; Preferedname = Regex.Replace(eeeer.ToString(), @"([(\u2100-\u27ff)(\uD83C\uDC00 - \uD83C\uDFFF)(\uD83D\uDC00 - \uD83D\uDFFF)(\uD83E\uDD00 - \uD83E\uDFFF)])", @"\$1").Replace("\\ ", " "); await UserTrustSql.GetUserTimeout(Id); var u = await UserSql.GetUserData(Id); FavoriteCharacter = u.favoritecharacter; MarriedUserId = u.marriedid; IsLewd = u.isLewd; }
public async Task GetAsync_Success_Updated_ReturnsCorrectResult() { TestingObject <ReportService> testingObject = this.GetTestingObject(); Guid reportIdArg = Guid.NewGuid(); var mockDbContext = testingObject.GetDependency <Mock <IDatabaseContext> >(); var report = new ReportMetadataSql { Created = DateTime.UtcNow.AddYears(-2), OwnerId = Guid.NewGuid(), LastUpdated = DateTime.UtcNow, Title = "Report Title" }; mockDbContext .Setup(m => m.FindSingleAsync <ReportMetadataSql>(It.Is <Guid>(id => id == reportIdArg))) .ReturnsAsync(report); var owner = new UserSql { Enabled = true, FirstName = "Mary", LastName = "Jane" }; mockDbContext .Setup(m => m.FindSingleAsync <UserSql>(It.Is <Guid>(id => id == report.OwnerId))) .ReturnsAsync(owner); ReportService reportService = testingObject.GetResolvedTestingObject(); ReportMetadata result = await reportService.GetAsync(reportIdArg); Assert.EndsWith("(Revision)", result.Title); }
public async Task GetAsync_Success_ReturnsCorrectResult() { TestingObject <UserService> testingObject = this.GetTestingObject(); Guid userIdArg = Guid.NewGuid(); var mockDbContext = testingObject.GetDependency <Mock <IDatabaseContext> >(); var userSql = new UserSql { FirstName = "Mary", LastName = "Jane" }; mockDbContext .Setup(dbc => dbc.FindSingleAsync <UserSql>(It.Is <Guid>(id => id == userIdArg))) .ReturnsAsync(userSql); UserService userService = testingObject.GetResolvedTestingObject(); User result = await userService.GetAsync(userIdArg); Assert.Equal(userSql.FirstName, result.FirstName); Assert.Equal(userSql.LastName, result.LastName); }
public async Task <BaseResponse <bool> > UpdateAsync(UserSql model) { var p = new DynamicParameters(); p.Add("id", model.Id); p.Add("fullName", model.FullName); p.Add("phone", model.Phone); p.Add("roleId", model.RoleId); p.Add("email", model.Email); p.Add("UpdatedBy", model.UpdatedBy); try { using (var con = GetConnection()) { await con.ExecuteAsync("sp_Employee_UpdateUser_v2", p, commandType : CommandType.StoredProcedure); return(BaseResponse <bool> .Create(true));; } } catch (Exception e) { return(BaseResponse <bool> .Create(false, GetException(e))); } }
public void SaveUserHistoryEvent(UserHistoryDto userHistoryDto) { NonResultQuerry(UserSql.InserUserHistoryEventSql(userHistoryDto)); }
public IEnumerable <UserDto> GetAllActiveUsers() { return(QuerryForList <UserDto>(UserSql.GetAllActiveUsers())); }
public string GetSaltForUser(string login) { return(QueryForObject <string>(UserSql.GetSaltForUser(login))); }
public void InsertUser(UserDto user) { NonResultQuerry(UserSql.InsertUser(user)); }
public UserFactory() { userCreator = new UserSql(); }
public IEnumerable <UserHistoryTypeDto> GetAllActiveUserHistoryTypes() { return(QuerryForList <UserHistoryTypeDto>(UserSql.GetUserHistoryEvents())); }
public UserDto Authorize(UserCredential credentials) { return(QueryForObject <UserDto>(UserSql.GetUserInformation(credentials))); }
public UserRepository(UserSql userSql) { _userSql = userSql; }
public void UpdateUser(UserDto user) { NonResultQuerry(UserSql.UpdateUser(user)); }