public List <UserModel> GetUsers() { UserDataAccess da = new UserDataAccess(SqlConConnectionString); List <UserModel> result = da.GetUsers(); return(result); }
// GET api/user public UserModel Get() { string userId = RequestContext.Principal.Identity.GetUserId(); UserDataAccess userDataAccess = new UserDataAccess(); return(userDataAccess.GetUserById(userId).First()); }
public static bool Registration(string login, string password, Profile profile) { var userDataAccess = new UserDataAccess(); var userList = userDataAccess.Select(); var profileDataAccess = new ProfileDataAccess(); foreach (var element in userList) { if (element.Login == login) { return(false); } } //Проверяю на валидность Email var isValid = EmailValidationService.IsValidEmail(profile.Email); if (isValid) { var user = new User() { Login = login, Password = EncryiptionService.GetHashString(password) }; userDataAccess.Insert(user); profileDataAccess.Insert(profile); return(true); } else { return(false); } }
public UserServices() { if (UserServices.userDataAccess == null) { UserServices.userDataAccess = new UserDataAccess(); } }
private async void LoginButtonClicked(object sender, EventArgs e) { userDataAccess = new UserDataAccess(); user = userDataAccess.Login(Email.Text, Password.Text); if (user != null) { if (user.UserType == UserAdmin.Admin) { Navigation.InsertPageBefore(new AdminPage(), this); await Navigation.PopAsync(); } else { App.UserEmail = Email.Text; Navigation.InsertPageBefore(new MainTabbedPage(), this); await Navigation.PopAsync(); } } else { await DisplayAlert("Warning", "Please check your Email and Password", "Cancel"); } //Navigation.InsertPageBefore(new MainTabbedPage(), this); //await Navigation.PopAsync(); }
public Dictionary <int, UserInfo> GetAllUserInfo(ref string errMessage) { Database db = DatabaseFactory.CreateDatabase(); errMessage = ""; Dictionary <int, UserInfo> list = new Dictionary <int, UserInfo>(); try { DataSet ds = UserDataAccess.GetAllUserInfo(db); UserInfo userInfo; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { userInfo = new UserInfo(ds.Tables[0].Rows[i]); list.Add(userInfo.UserId, userInfo); } return(list); } catch (Exception ex) { errMessage = ex.Message + ex.StackTrace; logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace); return(null); } }
/// <summary> /// Éste método valida si el nombre de usuario y la clave de un usuario son validas. /// </summary> /// <param name="userName">Nombre de usuario.</param> /// <param name="password">Clave de usuario.</param> /// <returns>Una cadena no vacia si la validación tuvo éxito o nulo si fallo.</returns> public string ValidateUser(string userName, string passwordHash) { string sessionID = ""; Collection <UserEntity> users; UserDataAccess userDataAccess = new UserDataAccess(); users = userDataAccess.LoadWhere(UserEntity.DBUserName, userName, true, OperatorType.Equal); if (users.Count == 1) { UserEntity userEntity = (UserEntity)users[0]; if (userEntity.Password == passwordHash) { sessionID = CreateUserSession(userName, passwordHash); if (loggedMobiles.ContainsKey(userName)) { string oldSessionID = loggedMobiles[userName]; activeSessions.Remove(oldSessionID); permissionDictionary.Remove(oldSessionID); loggedMobiles.Remove(userName); } UsersPermissions(sessionID, userEntity); activeSessions.Add(sessionID, userEntity); loggedMobiles.Add(userName, sessionID); } } return(sessionID); }
private dynamic GetMeetupOAuthCodeByUserName() { var userName = GetValueFromHeaders("userName"); #region Get Access Code from DB. Refresh with meetup if needed if (userName != string.Empty) { // Check if user exists var user = new UserDataAccess().GetOAuthUser(userName); // Supposedly current code of the user didn't expire. if ((user != null) && (!user.Key.Equals(string.Empty))) { // if the key hasn't expired return it. if (DateTime.UtcNow.Subtract(user.DataTimeKeyObtained).TotalMinutes <= 55) { return(new { accessToken = user.Key, refreshToken = user.AdditionalData }); } else { return(RefreshOAuthCode(user)); } } } #endregion Get Access Code from DB. Refresh with meetup if needed return(null); }
public ActionResult ChangePassword(string oldpassword, string newpassword) { int id = StateHelper.UserId; UserDataAccess obj = new UserDataAccess(); oldpassword = EncryptionHelper.HashString(oldpassword); newpassword = EncryptionHelper.HashString(newpassword); bool success; bool IsCorrectPassword = obj.CheckPassword(id, oldpassword); if (IsCorrectPassword == true) { success = obj.ChangePassword(id, newpassword); if (success) { return(Json(new { Result = success, Message = CustomMessages.PasswordChanged }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Result = success, Message = CustomMessages.PasswordNotChanged }, JsonRequestBehavior.AllowGet)); } } else { success = false; return(Json(new { Result = success, Message = CustomMessages.PasswordNotCorrect }, JsonRequestBehavior.AllowGet)); } }
public int GetUserIDFromPassword(string password) { UserDataAccess da = new UserDataAccess(SqlConConnectionString); int userID = da.GetUserIDFromPassword(password); return(userID); }
public UserContext Login(string confirmationKey) { if (string.IsNullOrEmpty(confirmationKey)) { return(null); } using (var uow = Update()) { var da = new UserDataAccess(uow); var user = da.GetUser(confirmationKey); if (user == null) { return(null); } var districtId = user.DistrictRef; if (user.SisUserId.HasValue) { throw new NotImplementedException(); } var res = SimpleUserLogin(user); if (res != null) { user.ConfirmationKey = null; user.DistrictRef = districtId; da.Update(user); UpdateUserLoginInfo(user, null, null, null, uow); } uow.Commit(); return(res); } }
public ActionResult RegisterUserProposalSumit(string Email) { SentMail email = new SentMail(); string res = GenaratorPass(); UserModel user = new UserModel(); user.Email = Email; user.Password = res; string mensaje = "<p>Usted fue invitado a votar a la propuesta Salvemos a Lucho</p>" + "<p>Su Usuario es :" + Email + "</p>" + "<p>Su número de token para participar en la votación es : " + res + "</p>"; using (UserDataAccess userDataAccess = new UserDataAccess()) { List <UserModel> list = userDataAccess.SearchUser(user.Email); bool isValidUser = false; if (list == null || list.Count == 0) { isValidUser = userDataAccess.InserUser(user); } else { userDataAccess.UpdateUser(user, 3); } } email.SentEmail(mensaje, Email, "Solicitud de Votación", "Votacion de " + ((ProposalModel)Session["Proposal"]).ProposalName); ViewBag.Proposal = Session["Proposal"]; return(View("SendUpload")); }
public UserService() { if (userDataAccess == null) { userDataAccess = new UserDataAccess(); } }
public MechanicService() { _dbCurrentMechanics = new UserDataAccess <Mechanic>(); _dbOldMechanics = new UserDataAccess <Mechanic>(); _dbErrands = new UserDataAccess <Errand>(); _mechanicCompetences = new List <VehiclePart>(); }
public IHttpActionResult Login(UserViewModel model) { var user = UserDataAccess.CheckUserLogin(model.UserName, model.Password); if (user == null) { return(Content(HttpStatusCode.OK, new { data = new { }, code = HttpStatusCode.NotFound, message = "Username and password is not correct!", isSuccess = false })); } return(Content(HttpStatusCode.OK, new { data = new { user = UserDataAccess.GetUserInfoById(user.UserId) }, code = HttpStatusCode.OK, message = "success", isSuccess = true })); }
public void GetUserTest() { var da = new UserDataAccess(UnitOfWork); User user = new User { Id = Guid.NewGuid(), IsDeveloper = false, IsSysAdmin = false, Login = "******", Password = "******" }; da.Insert(user); var u = da.GetUser("TestUser", "somepwd", null); Assert.NotNull(u); Assert.AreEqual(u.Id, user.Id); u = da.GetUser("TestUser", "wrong pwd", null); Assert.IsNull(u); u = da.GetUser("TestUser", null, null); Assert.NotNull(u); Assert.AreEqual(u.Id, user.Id); u = da.GetUser(null, null, user.Id); Assert.NotNull(u); Assert.AreEqual(u.Id, user.Id); }
public ActionResult LogOn(FormCollection fc) { UserInfo user = UserDataAccess.Validate(fc["userName"], fc["password"]); if (user != null)//if the log-in is successful { FormsAuthentication.RedirectFromLoginPage(user.UserName, fc["checkboxRemember"] == "on"); if (Request.QueryString["ReturnUrl"] != null) { Response.Redirect(System.Web.HttpContext.Current.Request.QueryString["ReturnUrl"].ToString()); } else { if (user.UserRole == UserRole.Administrator.ToString()) { return(RedirectToAction("Admin")); } else { return(RedirectToAction("Member")); } } } else { this.ShowMessage("Invalid user name or password", MessageType.Error, false); } return(View()); }
private async void SubmitButtonClicked(object sender, EventArgs e) { UserDataAccess userDataAccess = new UserDataAccess(); User userClass = userDataAccess.GetUserByEmail(emailEntry.Text); if (userClass == null) { await DisplayAlert("No user", "There is no user in that email, please check your email", "OK"); return; } string mailSender = "*****@*****.**"; string password = "******"; string toMail = userClass.Email; string subject = "Forgotten Password"; string body = "Your password is " + userClass.Password; try { var mail = new MailMessage(); var smtpServer = new SmtpClient("smtp.gmail.com", 587); mail.From = new MailAddress(mailSender); mail.To.Add(toMail); mail.Subject = subject; mail.Body = body; smtpServer.Credentials = new NetworkCredential(mailSender, password); smtpServer.UseDefaultCredentials = false; smtpServer.EnableSsl = true; smtpServer.Send(mail); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } await Navigation.PushAsync(new LoginPage()); }
public RentalTransactionScript(IConfiguration configuration) { inventoryDataAccess = new InventoryDataAccess(configuration); rentalDataAccess = new RentalDataAccess(configuration); movieDataAccess = new MovieDataAccess(configuration); userDataAccess = new UserDataAccess(configuration); }
public ActionResult GetUser(string id) { var dt = UserDataAccess.GetUserList(null, id, null, null, null, new Pages()); var list = Util.ToList <GroupUserItem>(dt); return(Json(list, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage Login([FromBody] APILogin json) { if (!UserDataAccess.ValidateUser(json.e, json.hp)) { return new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized } } ; var user = UserDataAccess.GetByName(json.e); if (user == null) { return new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized } } ; var auth = new Authentication(); var hash = auth.LogIn(user); UserDataAccess.LogUserTransaction(user.IUserId, DateTime.Now); return(new HttpResponseMessage { Content = new StringContent(hash), StatusCode = HttpStatusCode.OK }); }
static void Main(string[] args) { // 1) Выведите список должников. var users = new List <User>(); using (var userDataAccess = new UserDataAccess()) { users = (List <User>)userDataAccess.Select(); } foreach (var user in users) { Console.WriteLine($"{user.Id}. {user.Login} | {user.Password} "); } // 2) Выведите список авторов книги №3 (по порядку из таблицы ‘Book’). /*var authors = new List<Author>(); * * using (var authorDataAccess = new AuthorDataAccess()) * { * authors = (List<Author>)authorDataAccess.Select(); * } * */ //3) Выведите список книг, которые доступны в данный момент. /*var books = new List<Book>(); * * using (var bookDataAccess = new BookDataAccess()) * { * books = (List<Book>)bookDataAccess.SelectAvailableBook(); * } * * foreach (var book in books) * { * Console.WriteLine($"{book.Id}. {book.Name}"); * }*/ // 4) Вывести список книг, которые на руках у пользователя №2. /*var books = new List<Book>(); * * using (var bookDataAccess = new BookDataAccess()) * { * books = (List<Book>)bookDataAccess.Select(); * } * * foreach (var book in books) * { * Console.WriteLine($"{book.Id}, {book.Name}"); * }*/ }
public User(string userId) { this.UserId = userId; SysUserInfo user = UserDataAccess.GetUser(userId); if (user != null) { this.Account = user.Account; this.Active = user.Active; this.CreateTime = user.CreateTime; this.CreateUser = user.CreateUser; this.DefaultUrl = user.DefaultUrl; this.DeptCode = user.DeptCode; this.Description = user.Description; this.DomainName = user.DomainName; this.Email = user.Email; this.EntryDate = user.EntryDate; this.ExtNo = user.ExtNo; this.LanguageId = user.LanguageId; this.LastLogonTime = user.LastLogonTime; this.LoginName = user.LoginName; this.LogonTimes = user.LogonTimes; this.Password = user.Password; this.SiteSerial = user.SiteSerial; this.UserName = user.UserName; } }
static void Main(string[] args) { IPostRepository postRepository = new PostDataAccess(); IUserRepository userRepository = new UserDataAccess(); ICommentRepository commentRepository = new CommentDataAccess(); var service = new UserService(userRepository, postRepository); // var response = service.GetUserActiveRespose(4); var commentService = new UserCommentsService(userRepository, postRepository, commentRepository); int user = 9; var userComments = commentService.GetUserComments(user); if (userComments.Comments.Count == 0) { Console.WriteLine($"User {user} has no comments"); } foreach (var c in userComments.Comments) { Console.WriteLine($"Comment for User: {userComments.User.Id},PostId: {c.PostId}, Body: {c.Text}"); } Console.ReadKey(); }
public BusinessResponse VerifyUser(string verificationLink) { var businessResp = new BusinessResponse { ResponseCode = ResponseCode.Fail }; var userNameAndPassword = StringCipher.Decrypt(verificationLink, MoneyMarketConstant.EncyrptingPassword); if (userNameAndPassword == null) { businessResp.ResponseMessage = ErrorMessage.WrongVerificationLink; return(businessResp); } var userName = userNameAndPassword.Split(':')[0]; var email = userNameAndPassword.Split(':')[1]; var dataAccess = new UserDataAccess(); dataAccess.ConfirmEmail(userName, email); businessResp.ResponseCode = ResponseCode.Success; return(businessResp); }
public Developer Edit(Guid developerId, string name, string email, string webSite, string paypalLogin) { BaseSecurity.EnsureSysAdminOrCurrentUser(developerId, Context); var user = ServiceLocator.UserService.GetById(developerId); var oldEmail = user.Login; user.Login = email; var developer = GetById(developerId); developer.Name = name; developer.WebSite = webSite; developer.PayPalLogin = paypalLogin; DoUpdate(u => { var usda = new UserDataAccess(u); if (oldEmail != email && usda.GetUser(email, null, null) != null) { throw new ChalkableException("User email already exists"); } new DeveloperDataAccess(u).Update(developer); usda.Update(user); if (oldEmail != email) { ServiceLocator.EmailService.SendChangeEmailToDeveloper(developer, oldEmail, email); } }); developer.User = user; return(developer); }
public ActionResult LogOn(LoginViewModel loginViewModel) { var user = UserDataAccess.Validate(loginViewModel.Email, loginViewModel.Password); if (user != null) //if the log-in is successful { FormsAuthentication.RedirectFromLoginPage(user.UserName, loginViewModel.RememberMe); if (Request.QueryString["ReturnUrl"] != null) { Response.Redirect(System.Web.HttpContext.Current.Request.QueryString["ReturnUrl"]); } else { if (user.UserRole == UserRole.Administrator.ToString()) { return(RedirectToAction("Admin")); } return(RedirectToAction("Member")); } } else { this.ShowMessage("Invalid user name or password", MessageType.Danger, false); } return(View()); }
public ActionResult Edit(string id) { try { UserDetailViewModel m = new UserDetailViewModel(); //取得使用者資料 var dtList = UserDataAccess.GetUserList(null, id, null, null, null, new Pages()); var list = Util.ToList <UserDetailViewModel>(dtList); //清單資料 m = list[0]; //取得排序過的選單清單 var dtMenu = UserDataAccess.GetUserMenuAuth(id); m.AuthList = Util.ToList <MenuAuth>(dtMenu); //取得使用者所屬的群組清單 var dtGroup = GroupDataAccess.GetUserGroup(id); m.GroupItems = Util.ToList <GroupItem>(dtGroup); return(View("Detail", m)); } catch { return(RedirectToAction("Error", "Home")); } }
public ActionResult List(string Account = "", string Name = "", string Email = "", int PageIndex = 1, int PageSize = 10) { try { //初始化物件 var m = new UserListViewModel(); m.Authority = Tool.GetPageAuthority(); m.Parameters = new QueryParameter(); m.Pages = new Pages(); //設定參數 m.Parameters.Account = Account; m.Parameters.Email = Email; m.Parameters.Name = Name; m.Pages.PageIndex = PageIndex; m.Pages.PageSize = PageSize; //清單資料 DataTable dtList = UserDataAccess.GetUserList(null, m.Parameters.Account, null, m.Parameters.Email, m.Parameters.Name, m.Pages); m.List = Util.ToList <ListItem>(dtList); return(View(m)); } catch { return(RedirectToAction("Error", "Home")); } }
public UserLoginViewModel() { User = new Models.User(); DataUser = new DataAccessLayer.User(); CheckUserAuthentication = new RelayCommand(UserAuthentication); userDataAccess = new UserDataAccess(); }
public MainViewModel() { var personData = new PersonDataAccess(RepositoryFactory<Person>.GetRepository()); var companyData = new CompanyDataAccess(RepositoryFactory<Company>.GetRepository()); var invoiceData = new InvoiceDataAccess(RepositoryFactory<Invoice>.GetRepository(), RepositoryFactory<InvoiceRow>.GetRepository()); var userData = new UserDataAccess(RepositoryFactory<User>.GetRepository()); RegistratePersonViewModel = new RegistratePersonViewModel(personData); RegistrateCompanyViewModel = new RegistrateCompanyViewModel(companyData); RegisterInvoiceViewModel = new RegistrateInvoiceViewModel(invoiceData, companyData, personData); InvoiceViewModel = new InvoiceViewModel(invoiceData); userData.AddUser("admin", "admin"); LoginViewModel = new LoginViewModel(userData); }
// // GET: /Home/ public ActionResult Index() { UserDataAccess userDataAccess = new UserDataAccess(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); userDataAccess.validateUserInfo("devanshu", 12); return View(); }