public void LoadUserTest() { var userRepo = new UserRepo(); var sessionRepo = new SessionRepo(); var balanceRepo = new BalanceLogRepo(); var user = new User(); userRepo.Save(user); Assert.IsNotNull(user.Id, "Not saved."); var session = new Session { UserId = user.Id }; sessionRepo.Save(session); var date = DateTime.UtcNow; balanceRepo.Save(new BalanceLog { UserId = user.Id, Amount = 3, Comment = "comment", Date = date }); var manager = new UserManager(); var loaded = manager.LoadBySessionKey(session.Id).WithBallanceLog(); Assert.IsNotNull(loaded, "Not loaded"); Assert.AreEqual(user.Id, loaded.Id, "Loaded incorrectly"); Assert.IsNotNull(loaded.BallanceLog, "Balance log is null."); Assert.AreEqual(1, loaded.BallanceLog.Count(), "Balance log count incorrect."); var balance = loaded.BallanceLog.First(); Assert.AreEqual(3, balance.Amount, "Amount incorrect."); Assert.AreEqual("comment", balance.Comment, "Comment incorrect."); Assert.AreEqual(date, balance.Date, "Date incorrect."); }
public override void OnActionExecuting(HttpActionContext actionContext) { try { var headers = actionContext.Request.Headers; if (headers.Authorization != null) { if (headers.Authorization.Scheme == "Token") { using (UserRepo repo = new UserRepo()) { var result = repo.Auth(headers.Authorization.Parameter); if (result == null) throw new UnauthorizedException(); actionContext.ActionArguments.Add(KEY, result.Value); } } } else throw new UnauthorizedException(); } catch (UnauthorizedException) { actionContext.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized, }; } }
public void setup() { uRepo = new UserRepo(); userA = new USER { USER_ID = 1, USER_FNAME = "Ermin", USER_LNAME = "Avdagic", USER_DISPLAYNAME = "Me", USER_EMAIL = "*****@*****.**", PASSWORD = "******", REPUTATION = 1, CREATED_TIMESTAMP = DateTime.Now }; //uRepo.add(userA); uRepo.add(new USER { USER_ID = 2, USER_FNAME = "Jon", USER_LNAME = "Smith", USER_EMAIL = "*****@*****.**", USER_DISPLAYNAME = "JonSmith", REPUTATION = 5, PASSWORD = "******", CREATED_TIMESTAMP = DateTime.Now }); }
public void RepoTest() { Assert.AreEqual(1,1); _userRepository.SetValidator(userValidator); _articleRepository.SetValidator(articleValidator); _authorRepository.SetValidator(authorValidator); _userRepository.Save(user); _authorRepository.Save(author); _articleRepository.Save(article); ArrayList users = _userRepository.GetAll(); ArrayList authors = _authorRepository.GetAll(); ArrayList articles = _articleRepository.GetAll(); Assert.IsNotNull(users[0]); User userResult = (User) users[0]; Author authorResult = (Author) authors[0]; Article articleResult = (Article) articles[0]; _userRepository.SetXMLFilename("test.xml"); _userRepository.SaveAllToXML(); UserRepo second = new UserRepo(); second.SetXMLFilename("test.xml"); second.LoadAllFromXML(); second.SetXMLFilename("w"); // Assert.AreEqual(Constants.StringTest, userResult.Username); // Assert.AreEqual(Constants.StringTest, authorResult.Name); // Assert.AreEqual(Constants.StringTest, articleResult.Title); }
private void LoadInfo() { int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); User item = _UserRepo.GetById(id); if (item != null) { txtTendangnhap.Disabled = true; txtTendangnhap.Value = item.Username; txtFullname.Value = item.Fullname; txtPhone.Value = item.Phone; txtAddress.Value = item.Address; ddlUserType.SelectedValue = Utils.CStrDef(item.UserTypeID, ""); ddlKichhoat.SelectedIndex = Utils.CBoolDef(item.IsActive, false) ? 0 : 1; } User user = (User)Session["user"]; if (user != null) { //ADMIN //KETOANVIEN //QUANLY //GIAONHAN string code = getUserTypeCode(user.UserTypeID); if (code != "ADMIN") { ddlUserType.Enabled = false; btnBack.Visible = false; if (item == null) { Response.Write("<script>alert('Bạn không có quyền truy cập trang này!');location.href='login.aspx'</script>"); } } } }
protected void btnSave_Click(object sender, EventArgs e) { int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); User item = _UserRepo.GetById(id); if (item != null) { //item.Username = txtTendangnhap.Value; string saft = Security.CreateSalt(); string password = Security.Encrypt(txtMatkhau.Value, saft); item.Saft = saft; item.Password = password; item.IsActive = (ddlKichhoat.SelectedItem.Value == "1") ? true : false; _UserRepo.Update(item); } else { item = _UserRepo.GetByUsername(txtTendangnhap.Value); if (item != null) { lbMessage.Text = "Tên đăng nhập này đã tồn tại!"; return; } item = new User(); item.Username = txtTendangnhap.Value; string saft = Security.CreateSalt(); string password = Security.Encrypt(txtMatkhau.Value, saft); item.Saft = saft; item.Password = password; item.IsActive = (ddlKichhoat.SelectedItem.Value == "1") ? true : false; _UserRepo.Create(item); } Response.Redirect("~/pages/users.aspx"); }
public Manager(UserRepo _userGenericRepository, AuthorRepo _authorGenericRepository, ArticleRepo _articleGenericRepository) { this._userGenericRepository = _userGenericRepository; this._authorGenericRepository = _authorGenericRepository; this._articleGenericRepository = _articleGenericRepository; }
private void LoadInfo() { int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); User item = _UserRepo.GetById(id); if (item != null) { lbTen.Text = item.Username; } }
private void LoadInfo() { int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); User item = _UserRepo.GetById(id); if (item != null) { txtTendangnhap.Disabled = true; txtTendangnhap.Value = item.Username; ddlKichhoat.SelectedIndex = Utils.CBoolDef(item.IsActive, false) ? 0 : 1; } }
protected void btnRemove_Click(object sender, EventArgs e) { if (!chkChacchan.Checked) { lbMessage.Text = "Bạn chưa đồng ý chắc chắn xóa!"; return; } int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); _UserRepo.Remove(id); Response.Redirect("~/pages/users.aspx"); }
public User LoadBySessionKey(string sessionKey) { var sessionRepo = new SessionRepo(); var session = sessionRepo.GetAll().FirstOrDefault(s => s.Id == sessionKey); var userRepo = new UserRepo(); var user = userRepo.GetAll().FirstOrDefault(u => u.Id == session.UserId); if (user != null) { if (user.Taxes == null) user.Taxes = new List<Tax>(); } return user; }
public void TestMethod1() { var userRepo = new UserRepo(); var salt = Common.Security.GetPwdSalt(); var pwd = FormsAuthentication.HashPasswordForStoringInConfigFile("gaoning" + salt, "MD5"); var result = userRepo.Insert(new G1mist.CMS.Modal.T_Users { username = "******", password = pwd, salt = salt, createtime = DateTime.Now }); Assert.AreEqual(true, result); }
public User insertUser(User newUser) { User user2add = newUser; USER u3 = new USER(); UserRepo userRepo = new UserRepo(); u3.USER_FNAME = user2add.USER_FNAME; u3.USER_LNAME = user2add.USER_LNAME; u3.USER_EMAIL = user2add.EMAIL; u3.USER_DISPLAYNAME = user2add.USER_DISPLAYNAME; u3.PASSWORD = user2add.PASSWORD; u3.CREATED_TIMESTAMP = DateTime.Now; userRepo.add(u3); return user2add; }
public void UpdateBalanceTest() { var userRepo = new UserRepo(); var user = new User(); userRepo.Save(user); user.UpdateBalance(40, "Salary ;("); user.Save(); var loaded = userRepo.GetAll().Single(u => u.Id == user.Id).WithBallanceLog(); Assert.AreEqual(40, loaded.Balance, "Balance not loaded."); Assert.AreEqual(1, loaded.BallanceLog.Count(), "Log is incorrect."); Assert.AreEqual(40, loaded.BallanceLog.First().Amount, "Amount is incorrect."); Assert.AreEqual("Salary ;(", loaded.BallanceLog.First().Comment, "Comment is incorrect"); }
public ActionResult RecoverPassword(RecoverPasswordModel Model) { int userID; if (IsResetPasswordRequestValid(Model.AdditionalData, out userID)) { if (ModelState.IsValid) { UserRepo.TSP_Users(3, ID: userID, Password: Model.Password); Session.SetUser(UserRepo.GetSingle(userID)); HandleStandardMessaging(UserRepo.IsError); return(RedirectToAction("Profile", "Account")); } return(View("RecoverPassword", Model)); } return(HttpNotFound()); }
public ActionResult SubmitCode([Bind(Include = "Code, Email")] ConfirmationCode en) { if (ModelState.IsValid) { IUserRepo ur = new UserRepo(); IConfirmationCodeRepo cr = new ConfirmationCodeRepo(); ConfirmationCode cc = cr.GetConfirmationCode(en.Email); if (cc.IsPasswordReset && en.Code.Equals(cc.Code)) { User u = ur.GetUserByEmail(en.Email); cr.DeleteConfirmationCode(en.Email); return(View("~/Views/Home/ResetPassword.cshtml", u)); } return(View("~/Views/Home/ConfirmPasswordReset.cshtml", en)); } return(View("~/Views/Home/ConfirmPasswordReset.cshtml", en)); }
public ActionResult Add() { UserViewModel result = UserRepo.GetIdByName(User.Identity.Name); ViewBag.Employee = new SelectList(EmployeeRepo.Get(), "Id", "First_Name"); SouvenirStockViewModel model = new SouvenirStockViewModel(); model.Code = SouvenirStockRepo.GetNewCode(); if (result.Role == "Staff" || result.Role == "Admin") { return(PartialView("_Add", model)); } else { return(new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }))); } }
protected void btnSave_Click(object sender, EventArgs e) { int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); User item = _UserRepo.GetById(id); if (item != null) { item.Fullname = txtFullname.Value; item.Phone = txtPhone.Value; item.Address = txtAddress.Value; item.UserTypeID = Utils.CIntDef(ddlUserType.SelectedValue, 0); item.IsActive = (ddlKichhoat.SelectedItem.Value == "1") ? true : false; _UserRepo.Update(item); } //Response.Redirect("~/pages/users.aspx"); lbMessage.Text = "Lưu thành công!"; }
private void Button_Login_Click(object sender, RoutedEventArgs e) { if (validate(Login.Text, Password.Password)) { if (UserRepo.GetColumnValueByUsername(Login.Text, "status") == 0.ToString()) { UserRepo.updateLogin(Login.Text, GetLocalIPAddress()); WindowMain wm = new WindowMain(); wm.Show(); this.Close(); } else { MessageBox.Show("User already logged into the app"); } } }
public IActionResult SignUp([FromBody] SignUpRequest request_model) { if (!ModelState.IsValid) { return(BadRequest(ModelError())); } var userModel = Mapper.Map <UserModel>(request_model); UserRepo rp = new UserRepo(); rp.InsertUser(userModel); return(Ok(new SignUpResponse { status = 200, message = "SUCCESS", data = request_model })); }
private void Button_Connect_Click(object sender, RoutedEventArgs e) { string text = (string)listBox.SelectedItem; Contact UserToCall = getContactByUsername(text); if (UserRepo.getColumnByIds(UserToCall.SubjectId, "status") == 0.ToString()) { MessageBox.Show("User currently offline"); return; } string ContactIP = UserRepo.getColumnByIds(UserToCall.SubjectId, "ip_address"); int ContactID = UserToCall.SubjectId; //Console.WriteLine(ContactIP); Manager.Call(ContactIP, ContactID); ButtonSet(false, true, true); }
private bool FillEntity() { this.User = new Users { AppId = UserRepo.GetAppId(), UserType = this.cboUserType.Text, FullName = this.txtUserName.Text, Password = this.txtPassword.Text }; this.Login = new Logins { AppId = LoginRepo.GetAppId(), Password = this.txtPassword.Text, UserId = this.User.AppId }; this.Emp = new Employee { AppId = EmployeeRepo.GetAppId(), FullName = this.User.FullName, Email = null, Gender = null, Address = null, BirthDate = null, PhoneNumber = null, JoinDate = null, Salary = "", UserId = this.User.AppId }; UserValidation validator = new UserValidation(); ValidationResult results = validator.Validate(this.User); IList <ValidationFailure> failures = results.Errors; if (!(results.IsValid)) { foreach (ValidationFailure failure in failures) { MessageBox.Show(failure.ErrorMessage, "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } return(true); }
public async Task ChangeUserName(ChangeUserNameInput input) { await ValidateCode(input.ValidateCode); var user = await UserManager.GetUserByIdAsync(AbpSession.UserId.Value); if (!await UserManager.CheckPasswordAsync(user, input.Password)) { throw new UserFriendlyException("密码错误"); } if (UserRepo.CheckExists(p => p.UserName == input.UserName, AbpSession.UserId.Value)) { throw new UserFriendlyException("该用户名已存在"); } user.UserName = input.UserName; await UserRepo.UpdateAsync(user); }
public async Task recording_user_updates_last_active_at() { UserRepo userRepo = CreateUserRepo(); // given Instant t1 = Instant.FromUnixTimeSeconds(0); Instant t2 = Instant.FromUnixTimeSeconds(1); var userInfoT1 = new UserInfo("123", "X", "x", null, updatedAt: t1); var userInfoT2 = new UserInfo("123", "X", "x", null, updatedAt: t2); // when, then User userT1 = await userRepo.RecordUser(userInfoT1); Assert.AreEqual(t1, userT1.LastActiveAt); User userT2 = await userRepo.RecordUser(userInfoT2); Assert.AreEqual(t2, userT2.LastActiveAt); }
public ActionResult Approve(int id) { UserViewModel result = UserRepo.GetIdByName(User.Identity.Name); ViewBag.Panel = "Approval Design Request"; ViewBag.Employee = new SelectList(DesignApproveRepo.GetAssign(), "Id", "Full_Name"); DesignApproveViewModel model = DesignApproveRepo.GetById(id); if (result.Role == "Admin") { return(PartialView("_Approve", model)); } else { return(new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }))); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { if (Request.Cookies.Get("user") != null) { HttpCookie cookie = Request.Cookies.Get("user"); int id = int.Parse(cookie.Value); EventIDEntities db = new EventIDEntities(); User u = UserRepo.SearchByID(id); email.Text = u.UserEmail; password.Attributes["value"] = u.UserPassword; remMe.Checked = true; } } }
public UserInfo LoadUser(int id) { var entity = UserRepo.FindById(id); if (entity == null) { return(null); } return(new UserInfo() { Fio = entity.LastName + " " + entity.FirstName, IsActive = true, OrganizationName = entity.Organization.Name, OrganizationInn = entity.Organization.Inn, Id = id }); }
public bool AuthenticateUser(USER user) { UserRepo userRepo = new UserRepo(); bool AccessStatus = false; var dataUser = userRepo.RetrieveByName(user.USERNAME); if (dataUser != null) { if (dataUser.PASSWORD == user.PASSWORD) { AccessStatus = true; user.USER_ID = dataUser.USER_ID; } } return(AccessStatus); }
private void userDeleteManager_bt_Click(object sender, EventArgs e) { User user = new User(); // user.UserId = this.textboxUserSearch.Text; MessageBox.Show(user.UserId); UserRepo userRepo = new UserRepo(); if (userRepo.Delete(user.UserId)) { MessageBox.Show(" Perfectly Deleted"); } else { MessageBox.Show(" can not be deleted "); } }
private void tsMainEdit_Click(object sender, EventArgs e) { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { Users user = (Users)usersBindingSource.Current; EditUser editUser = new EditUser(user); if (editUser.ShowDialog() == DialogResult.OK) { UserRepo frm = new UserRepo(); frm.Save(user); SetDataSources(); } } }
public override void FillList(CreateTaskVM model) { UserRepo repoUser = new UserRepo(); List <User> result = repoUser.GetAll().ToList(); model.ListAssignee = new List <SelectListItem>(); foreach (var item in result) { model.ListAssignee.Add(new SelectListItem() { Text = item.Username, Value = item.Id.ToString() }); } model.ListAssignee[0].Selected = true; }
public void TestGetUserByEmail(string email) { // arrange _dbContext = _dbContext ?? Configurations.GetDbContext(); _mapperProvider = _mapperProvider ?? Configurations.GetMapperProvider(); _mapper = _mapper ?? Configurations.GetMapper(); // act var result = new UserRepo(_dbContext, _mapperProvider, _mapper).GetUserByEmail(email); // assert Assert.IsType <UserDTO>(result); Assert.True(result.UserId > 0); Assert.False(string.IsNullOrEmpty(result.FullName)); Assert.False(string.IsNullOrEmpty(result.Email)); Assert.False(string.IsNullOrEmpty(result.ScreenName)); }
public IHttpActionResult GetForAuthenticate() { var identity = (ClaimsIdentity)User.Identity; UserModel um = UserRepo.GetUserByUserID(Convert.ToInt32(identity.FindFirst(ClaimTypes.NameIdentifier).Value)); List <DelegationModel> dm = new List <DelegationModel>(); dm = DelegationRepo.GetDelegationByUserId(um.Userid, out string error); if (dm.Count > 0) { List <DelegationModel> ActiveDM = dm.Where(x => x.Startdate.Value.Date <= DateTime.Today.Date && x.Enddate.Value.Date >= DateTime.Today.Date && x.Active == ConDelegation.Active.ACTIVE).ToList(); if (ActiveDM.Count > 0) { foreach (DelegationModel d in ActiveDM) { if (um.Role == ConUser.Role.EMPLOYEEREP) { um.Role = ConUser.Role.TEMPHOD; um = UserRepo.UpdateUser(um); } } } else { List <DelegationModel> InActiveDM = dm.Where(x => x.Enddate.Value.Date < DateTime.Today.Date && x.Active == ConDelegation.Active.ACTIVE).ToList(); if (InActiveDM.Count > 0) { foreach (DelegationModel d in InActiveDM) { if (um.Role == ConUser.Role.TEMPHOD) { DelegationRepo.CancelDelegation(d, out error); um = UserRepo.GetUserByUserID(Convert.ToInt32(identity.FindFirst(ClaimTypes.NameIdentifier).Value)); } } } } } return(Ok(um)); }
public void setup() { bRepo = new BookRepo(); uRepo = new UserRepo(); userA = new USER { USER_FNAME = "Ermin", USER_LNAME = "Avdagic", USER_DISPLAYNAME = "Me", USER_EMAIL = "*****@*****.**", PASSWORD = "******", REPUTATION = 1, CREATED_TIMESTAMP = DateTime.Now }; uRepo.add(userA); bookA = new BOOK { USER_ID=333, BOOK_AUTHOR = "Me", BOOK_DESC = "About my life", BOOK_EDITION = 10, BOOK_PRICE = 20, BOOK_PUBLISHER = "IDK", BOOK_TITLE = "My Life", ISBN10 = 12345678910, ISBN13 = 12345678910111, CREATED_TIMESTAMP = DateTime.Now, CATEGORY_ID=1, CONDITION_ID=1 }; bRepo.add(bookA); uRepo.add(new USER { USER_FNAME = "Jon", USER_LNAME = "Smith", USER_EMAIL = "*****@*****.**", USER_DISPLAYNAME = "JonSmith", REPUTATION = 5, PASSWORD = "******", CREATED_TIMESTAMP = DateTime.Now }); }
public ActionResult Create(CreateBench formModel) { var repo = new BenchRepo(context); var userRepo = new UserRepo(context); try { User user = userRepo.GetByEmail(User.Identity.Name); var bench = new Bench(formModel.Description, formModel.NumSeats, formModel.Latitude, formModel.Longitude, user); repo.Insert(bench); return(RedirectToAction("Index")); } catch (DbUpdateException ex) { //HandleDbUpdateException(ex); } return(View("Create", formModel)); }
public void SetGame() { commands.CreateCommand("SetGame") .Parameter("Game", ParameterType.Unparsed) .Do(async(e) => { UserRepo userRepo = new UserRepo(new UserContext()); if (userRepo.IsAtlasAdmin(e.User.Id)) { BotUser.SetGame(e.GetArg("Game")); await e.Channel.SendMessage("Game set."); } else { await e.Channel.SendMessage(Eng_Default.NotAllowed()); } }); }
public ActionResult Login(UserModel newUser, string returnUrl) { if (this.ModelState.IsValid) { newUser.Password = newUser.Password.ToMD5HashCode(); var handler = new UserRepo(); var user = handler.Get(x => x.RuiJieId == newUser.RuiJieId); if (user.Password == newUser.Password) { FormsAuthentication.SetAuthCookie(user.Name, newUser.IsRememberMe); return(this.CheckReturnUrl(returnUrl) ? this.Redirect(returnUrl) : this.RedirectToAction("index", "Login") as ActionResult); } this.ModelState.AddModelError("", "请检查你的用户名或密码"); } return(this.View("Index", newUser)); }
public async Task supports_a_crazy_amount_of_money() { const long pokeyen = long.MaxValue - 123; const long tokens = long.MaxValue - 234; var userRepo = new UserRepo(CreateTemporaryDatabase(), pokeyen, tokens); User userFromRecording = await userRepo.RecordUser(new UserInfo("123", "X", "x", null)); Assert.AreEqual(pokeyen, userFromRecording.Pokeyen); Assert.AreEqual(tokens, userFromRecording.Tokens); User?userFromReading = await userRepo.FindBySimpleName("x"); Assert.NotNull(userFromReading); Assert.AreNotSame(userFromReading !, userFromRecording); Assert.AreEqual(pokeyen, userFromReading !.Pokeyen); Assert.AreEqual(tokens, userFromReading !.Tokens); }
public async Task supports_a_crazy_amount_of_money() { const long pokeyen = long.MaxValue - 123; const long tokens = long.MaxValue - 234; var userRepo = new UserRepo(CreateTemporaryDatabase(), pokeyen, tokens, ImmutableList <string> .Empty); User userFromRecording = await userRepo.RecordUser(new UserInfo("123", "X", "x")); Assert.That(userFromRecording.Pokeyen, Is.EqualTo(pokeyen)); Assert.That(userFromRecording.Tokens, Is.EqualTo(tokens)); User?userFromReading = await userRepo.FindBySimpleName("x"); Assert.NotNull(userFromReading); Assert.That(userFromRecording, Is.Not.SameAs(userFromReading !)); Assert.That(userFromReading !.Pokeyen, Is.EqualTo(pokeyen)); Assert.That(userFromReading !.Tokens, Is.EqualTo(tokens)); }
public User insertUser(User newUser) { User user2add = newUser; USER u3 = null; UserRepo userRepo = new UserRepo(); DateTime dt = DateTime.Now; long a = dt.Ticks; u3.USER_FNAME = newUser.USER_FNAME; u3.USER_LNAME = newUser.USER_LNAME; u3.USER_EMAIL = newUser.EMAIL; u3.USER_DISPLAYNAME = newUser.USER_DISPLAYNAME; u3.PASSWORD = newUser.PASSWORD; u3.CREATED_TIMESTAMP = BitConverter.GetBytes(a); userRepo.add(u3); return newUser; }
private void userEditManager_bt_Click(object sender, EventArgs e) { // string str = this.textboxUserSearch.Text; UserRepo userRepo = new UserRepo(); // List<User> userList = userRepo.GetUser(str); // this.dataGridViewUser.DataSource = userList; /* this.textBoxUserName.Text = userList[0].UserName.ToString(); * this.dateTimePickerDoB.Text = userList[0].DateOfBirth.ToString(); * this.textBoxPassword.Text = userList[0].Password.ToString(); * this.textBoxDesignation.Text = userList[0].Designation.ToString(); * this.textBoxSalary.Text = userList[0].Salary + ""; * this.dateTimePickerDoJ.Text = userList[0].DateOfJoing.ToString(); * this.comboBoxUserType.Text = userList[0].UserType.ToString(); * this.textBoxContactNumber.Text = userList[0].ContactNo + "";*/ // managerTabControl.SelectedIndex = 1; }
//Do some database seeding for some tests static void Main() { using (var userRepo = new UserRepo()) { userRepo.Add(new SQLitedllVM.Models.Userdetail { BusinessName = "Happy hour", Usernumber = 34523, ContactNumber = "0312354", Username = "******" }); //(userRepo.).Data.Add(new Point { JodId = 12 }); foreach (var v in userRepo.GetAll()) { Console.WriteLine($"Username: {v.Usernumber}"); } Console.WriteLine(); //iterate throught the users } Console.ReadLine(); }
private void btnSearchInventory_Click(object sender, EventArgs e) { try { this.dgvUsersGrid.AutoGenerateColumns = false; this.dgvUsersGrid.DataSource = UserRepo.SearchUser(this.txtSearchbar.Text); this.dgvUsersGrid.ClearSelection(); this.dgvUsersGrid.Refresh(); if (this.dgvUsersGrid.RowCount == 0) { MessageBox.Show("No Data Found!"); } } catch { MessageBox.Show("Please insert a valid keyword"); } }
private void Button_Search_Click(object sender, RoutedEventArgs e) { string username = TextBox_Username.Text; if (String.IsNullOrEmpty(username)) { MessageBox.Show("Fill username textbox"); } else { listView.Items.Clear(); var resultsList = UserRepo.getSimiliarUsers(username); foreach (var result in resultsList) { listView.Items.Add(result); } } }
public ActionResult AttachCard(long?ID) { if (ID.HasValue && ID > 0 && Security.IsCardNumberValid(ID.Value)) { UserRepo.TX_UM(7, string.Format(@" <data> <user_id>{0}</user_id> <card_number>{1}</card_number> </data>", CurrentUser.ID, ID)); HandleStandardMessaging(UserRepo.IsError); } else { TempData.SetMessage(Resources.ErrorCardNumberInvalid); } return(RedirectToAction("Card", "Account")); }
public ExternalController( IIdentityServerInteractionService interaction, IClientStore clientStore, IEventService events, IConfiguration configuration, TestUserStore users = null) { // if the TestUserStore is not in DI, then we'll just use the global users collection // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity) _users = users ?? new TestUserStore(TestUsers.Users); _interaction = interaction; _clientStore = clientStore; _events = events; _configuration = configuration; _userRepo = new UserRepo(); }
protected void btnSave_Click(object sender, EventArgs e) { int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); User item = _UserRepo.GetById(id); if (item != null) { //item.Username = txtTendangnhap.Value; string saft = Security.CreateSalt(); string password = Security.Encrypt(txtMatkhau.Value, saft); item.Saft = saft; item.Password = password; _UserRepo.Update(item); } //Response.Redirect("~/pages/users.aspx"); lbMessage.Text = "Đổi mật khẩu thành công!"; }
private void button1_Click(object sender, EventArgs e) { UserRepo r = new UserRepo(); if (txtPass == textBox4) { r.insertUserDetails(txtId, txtPass, txtName, txtEmail, txtPhone, txtAdress); MessageBox.Show("Done\nPlease Login to continue"); this.Dispose(); Login l = new Login(); l.Show(); f.Dispose(); } else { MessageBox.Show("Password Does not Match"); } }
static void Main(string[] args) { UserRepo userRepo = new UserRepo(); ArticleRepo articleRepo = new ArticleRepo(); AuthorRepo authorRepo = new AuthorRepo(); UserValidator userValidator = new UserValidator(); ArticleValidator articleValidator = new ArticleValidator(); AuthorValidator authorValidator = new AuthorValidator(); userRepo.SetValidator(userValidator); articleRepo.SetValidator(articleValidator); authorRepo.SetValidator(authorValidator); Manager manager = new Manager(userRepo, authorRepo, articleRepo); ConsoleUI console = new ConsoleUI(manager); console.Run(); }
private void LoadInfo() { int id = Utils.CIntDef(Request.QueryString["id"], 0); _UserRepo = new UserRepo(); User item = _UserRepo.GetById(id); if (item != null) { txtTendangnhap.Disabled = true; txtTendangnhap.Value = item.Username; } User user = (User)Session["user"]; if (user != null) { //ADMIN //KETOANVIEN //QUANLY //GIAONHAN string code = getUserTypeCode(user.UserTypeID); if (code != "ADMIN") { btnBack.Visible = false; } } }
public void bookSetup() { bookService = new BookService(); bRepo = new BookRepo(); uRepo = new UserRepo(); userA = new USER { USER_FNAME = "Cory", USER_LNAME = "Jenkings", PASSWORD = "******", USER_EMAIL = "*****@*****.**", USER_DISPLAYNAME = "C.J", CREATED_TIMESTAMP = DateTime.Now, REPUTATION = 509}; uRepo.add(userA); bookA = new BOOK { USER_ID=333, BOOK_PRICE = 20, BOOK_PUBLISHER = "idk", BOOK_TITLE = "my life", BOOK_AUTHOR = "Ermin", BOOK_EDITION = 10, BOOK_DESC = "A book with words and pictures", CREATED_TIMESTAMP = DateTime.Now, ISBN10 = 1111111111, ISBN13 = 1111111111111, CATEGORY_ID=1, CONDITION_ID=1 }; bRepo.add(bookA); }
private void LoadData() { _UserRepo = new UserRepo(); rptList.DataSource = _UserRepo.GetAll(); rptList.DataBind(); }
public static void Save(this User user) { var userRepo = new UserRepo(); userRepo.Save(user); }
public void UserData_withreference_Create_Retrive_Delete_Verify() { int preUsers = 0; int preIds = 0; using (var session = RavenDocumentStore.OpenSession()) { session.Advanced.AllowNonAuthoritiveInformation = false; var identities = session.Query<Identity>(); preIds = identities.Count(); var users = session.Query<UserData>(); preUsers = users.Count(); } UserRepo repo = new UserRepo(); string savedId; var id = repo.GetUserByIdentity(Id); Assert.IsNull(id); var user1 = repo.CreateUser(Id); savedId = user1.Id; user1.Claims.Add(new SimpleClaim { Subject = Id, ClaimType = "test", Issuer = "noone", Value = "dummy" }); repo.SaveUser(user1); var user2 = repo.GetUserByIdentity(Id); Assert.IsNotNull(user2); Assert.AreEqual(savedId, user2.Id); Assert.IsTrue(user2.IdentityIds.First().Contains(Id)); Assert.IsTrue(user2.Claims[0].Issuer == "noone"); var user3 = repo.GetUserByIdentity(Id); Assert.IsNotNull(user3); Assert.AreEqual(savedId, user3.Id); repo.DeleteUser(user3); var user4 = repo.GetUserByIdentity(Id); Assert.IsNull(user4); using (var session = RavenDocumentStore.OpenSession()) { session.Advanced.AllowNonAuthoritiveInformation = false; var identities = session.Query<Identity>(); Assert.AreEqual(preIds, identities.Count()); var users = session.Query<UserData>(); Assert.AreEqual(preUsers, users.Count()); } }