private void ValidateLogin(UserAccountDataContext dc, string login) { var user = dc.Users.FirstOrDefault(u => u.Login == login); if (user != null) { throw new ServerSideException(String.Format( "A user with the login name: {0}, already exists", login)); } }
private void ValidateEmail(UserAccountDataContext dc, string email) { var user = dc.Users.FirstOrDefault(u => u.Email == email); if (user != null) { throw new ServerSideException(String.Format( "This email: {0}, is already in use", email)); } }
public void Handle(LogInCommand command) { using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Login == command.Login); ValidateLoginData(user, command); var appUser = CreateAppUserEntity(user); CookieHandler.Create(appUser, command.RememberMe); } }
public ActionResult ChangeRole() { ChangeUserRoleViewModel model; var user = System.Web.HttpContext.Current.GetCurrentUser(); using (var dbContext = new UserAccountDataContext()) { model = dbContext.Users.GetUserRole(user.UserId); } return(View(model)); }
public ActionResult ChangeData() { ChangeUserDataViewModel model; var user = System.Web.HttpContext.Current.GetCurrentUser(); using (var dbContext = new UserAccountDataContext()) { model = dbContext.Users.GetUserData(user.UserId); } return View(model); }
public void Handle(ConfirmAccountCommand command) { using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.ConfirmGuid == command.ConfirmGuid); if (user == null) { throw new ServerSideException("User not find, check your activate link and try agine, or contact us"); } user.ConfirmAccount(); } }
public void Handle(UpdateUserAddressCommand command) { using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Id == command.UserId); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } UpdateUserAddres(user.Address, command); dbContext.SaveChanges(); } }
public void Handle(AddUserCommand command) { ValidateCommandParameters(command); using (var dbContext = new UserAccountDataContext()) { ValidateLogin(dbContext, command.Login); ValidateEmail(dbContext, command.Email); User user = CreateUserEntity(command); dbContext.Users.Add(user); dbContext.SaveChanges(); // TODO add event: User registered - send confirm email } }
public void Handle(UpdateUserDataCommand command) { ValidatePhoneNumber(command.Phone); using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.Single(u => u.Id == command.Id); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } UpdateUserEntity(user, command); dbContext.SaveChanges(); } }
public void Handle(ChangeUserRoleCommand command) { using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Id == command.UserId); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } // TODO Check if user have league or team // if user have league or team then cant change role ChangeRole(user, command); dbContext.SaveChanges(); } }
public void Handle(ChangePasswordCommand command) { ValidatePasswordConfirm(command.NewPassword, command.NewPasswordRepeat); using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Id == command.UserId); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } ChangePassword(user, command); dbContext.SaveChanges(); // TODO add event: User changed password - send email with new password } }
public void Handle(RemoveUserCommand command) { using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Id == command.UserId); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } // TODO Check if user have league or team // if user have league or team then cant delete account dbContext.Users.Remove(user); dbContext.SaveChanges(); // TODO create event - user removed - LogOff } }
public void Handle(ChangeEmailCommand command) { ValidateCommandParameters(command); using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Id == command.UserId); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } ChangeEmail(user, command); dbContext.SaveChanges(); // TODO add event: User email changed - send confirm email } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var userAccountDataContext = new UserAccountDataContext(); Database.SetInitializer(new MigrateDatabaseToLatestVersion<UserAccountDataContext, UsersAccounts.Model.Migrations.Configuration>()); userAccountDataContext.Database.Initialize(false); var managementDataContext = new ManagementDataContext(); Database.SetInitializer(new MigrateDatabaseToLatestVersion<ManagementDataContext, Management.Model.Migrations.Configuration>()); managementDataContext.Database.Initialize(false); var leagueDataContext = new LeagueDataContext(); Database.SetInitializer(new MigrateDatabaseToLatestVersion<LeagueDataContext, League.Model.Migrations.Configuration>()); leagueDataContext.Database.Initialize(false); BootstrapContexts(); }
public void Handle(ForgotPasswordCommand command) { if (!IsValidEmail(command.Email)) { throw new ServerSideException("Email format is invalid"); } using (var dbContext = new UserAccountDataContext()) { var user = dbContext.Users.SingleOrDefault(u => u.Email == command.Email); if (user == null) { throw new ServerSideException( String.Format("User with email: {0} does not exist", command.Email)); } // TODO Generate new password // TODO Send email with new password } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var userAccountDataContext = new UserAccountDataContext(); Database.SetInitializer(new MigrateDatabaseToLatestVersion <UserAccountDataContext, UsersAccounts.Model.Migrations.Configuration>()); userAccountDataContext.Database.Initialize(false); var managementDataContext = new ManagementDataContext(); Database.SetInitializer(new MigrateDatabaseToLatestVersion <ManagementDataContext, Management.Model.Migrations.Configuration>()); managementDataContext.Database.Initialize(false); var leagueDataContext = new LeagueDataContext(); Database.SetInitializer(new MigrateDatabaseToLatestVersion <LeagueDataContext, League.Model.Migrations.Configuration>()); leagueDataContext.Database.Initialize(false); BootstrapContexts(); }
public LoginDataAccess(UserAccountDataContext context) { this._context = context; }
public GenerateNewPasswordDataAccess(UserAccountDataContext context) { this._context = context; }
public OutboxDataAccess(UserAccountDataContext context) { this._context = context ?? throw new ArgumentNullException(nameof(context)); }
public CreateNewAccountDataAccess(UserAccountDataContext context) { this._context = context; }