public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); // TODO: refactor: change to OnGet() Faculties = applicationsManager.GetFaculties(); Lecterns = applicationsManager.GetLecterns(); Curriculums = applicationsManager.GetCurriculums(); if (ModelState.IsValid) { if (applicationsManager.ApplicationExist(Input.Email)) { ModelState.AddModelError(string.Empty, "User with this email has already submitted application"); return(Page()); } else { var application = MapToApplication(Input); bool success = await UsersManager.CreateUser(serviceProvider, configuration, application); if (success) { return(RedirectToPage("./ApplicationSent")); } else { ModelState.AddModelError(string.Empty, "Smth went wrong"); } } } return(Page()); }
protected void btnSave_Click(object sender, EventArgs e) { if (txtUserId.Text.ToString().Trim() != String.Empty) { Users usr = UsersManager.getUser(txtUserId.Text.ToString().ToUpper()); if (usr != null) { usr.Description = txtDescription.Text; usr.Password = txtPassword.Text; usr.UserGrp = ddlUsrGrp.SelectedValue; usr.Status = ddlStatus.SelectedValue; usr.EmpNo = txtEmpNo.Text; UsersManager.UpdateUser(usr); lblTranStatus.Visible = true; lblTranStatus.Text = "User updated successfully!!"; lblTranStatus.ForeColor = System.Drawing.Color.Green; } else { usr = new Users(); usr.UserName = txtUserId.Text; usr.Description = txtDescription.Text; usr.Password = txtPassword.Text; usr.UserGrp = ddlUsrGrp.SelectedValue; usr.Status = ddlStatus.SelectedValue; usr.EmpNo = txtEmpNo.Text; UsersManager.CreateUser(usr); lblTranStatus.Visible = true; lblTranStatus.Text = "User created successfully!!"; lblTranStatus.ForeColor = System.Drawing.Color.Green; } } }
public IActionResult Put( [FromBody] SignUpRequest data) { if (UsersManager.ValidateUserNotExists(data.clientId)) { UsersManager.CreateUser(data.clientId, data.clientSecret, data.email); return(Json(new { status = StatusMessages.OK })); } else { this.Response.StatusCode = 409; return(Json(new { status = StatusMessages.UserAlreadyExists })); } }
public async Task <ActionResult> ManageUsers(NewUserVM model) { List <UserDT> users = UsersManager.GetUsers(); if (!ModelState.IsValid) { ViewBag.Users = users; ViewBag.Valid = false; return(View(model)); } ApplicationUser user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { if (!System.Web.Security.Roles.RoleExists(UserRoleHelper.GetString(model.UserLevel))) { System.Web.Security.Roles.CreateRole(UserRoleHelper.GetString(model.UserLevel)); } System.Web.Security.Roles.AddUserToRole(user.UserName, UserRoleHelper.GetString(model.UserLevel)); UserDT newUser = new UserDT(); newUser.FirstName = model.FirstName; newUser.LastName = model.LastName; newUser.Email = model.Email; newUser.Role = model.UserLevel; newUser.AspNetId = user.Id; newUser = UsersManager.CreateUser(newUser); users.Add(newUser); } ViewBag.Users = users; return(View(model)); }
/// <summary> /// Register new user with login and password /// Also authenticate user /// </summary> /// <param name="regData">login of the user (email) and password of the user (not encrypted)</param> /// <exception cref="AuthExceptions.RegistrationException">If something went wrong</exception> /// <exception cref="AuthExceptions.UserAlreadyExists">If user already exists </exception> /// <returns>Authenticated Token</returns> public static TokenData RegisterUser(RegistrationData regData) { if (Instance._usersAuthData.Count(n => n.Key.Equals(regData)) != 0) { throw new AuthExceptions.UserAlreadyExists(regData); } AbstractUser user = UsersManager.CreateUser(regData); Instance._usersAuthData.Add(regData, user); try { return(AuthUser(regData)); } catch (AuthExceptions) { throw new AuthExceptions.RegistrationException(regData); } }
public void SubmitFileCompleted() { #region test_teext string file = "jhgadflnbijsdfgnbmoisdfgbnmojsdfgbnmosfgnmodgfosfnmosfgmnosfmnoiksfgmbnoisgnhoigsdfxnmoisdrftmnoisfrmnoisfgnm[isofgnmoiksfrnmosifgtnmoiskfgnmsfr"; #endregion var user = UsersManager.CreateUser( new RegistrationData("test6", "test6") { RootType = RootEnum.Candidate } ); FileData data = new FileData { Type = "CV", FileName = "test.txt" }; FileManager.SubmitFile(user, data, file); var wrapper = FileManager.GetFileData(user, "CV"); Assert.IsTrue(data.Equals(wrapper.Data) && file.Equals(wrapper.Bytes)); File.Delete("tests.bytes"); }
public async Task <IActionResult> OnPost(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); PopulateData(); if (ModelState.IsValid) { if (applicationsManager.ApplicationExist(Input.Email)) { ModelState.AddModelError(string.Empty, "User with this email has already existed"); return(Page()); } else { var user = ApplicationUserEditPageModel.ComposeApplicationUser(Input, Faculties, Lecterns, Curriculums); await UsersManager.CreateUser(serviceProvider, configuration, user, Input.Password, Input.Email, Input.UserType); return(LocalRedirect("~/Admin/Users")); } } return(Page()); }
public IActionResult Register(RegisterModelView viewRegistration) { TempData["FName"] = viewRegistration.FirstName; TempData["LName"] = viewRegistration.LastName; TempData["Email"] = viewRegistration.Email; TempData["UserName"] = viewRegistration.Username; TempData["Address"] = viewRegistration.Address; TempData["City"] = viewRegistration.City; TempData["Province"] = viewRegistration.Province; TempData["Country"] = viewRegistration.Country; TempData["Phone"] = viewRegistration.Phone; if (viewRegistration.FirstName == "" || viewRegistration.FirstName == null) { TempData["ErrorMessage"] = "First Name is required."; return(RedirectToAction("Register", "Account")); } else { if (viewRegistration.LastName == "" || viewRegistration.LastName == null) { TempData["ErrorMessage"] = "Last Name is required."; return(RedirectToAction("Register", "Account")); } else { if (viewRegistration.Email == "" || viewRegistration.Email == null) { TempData["ErrorMessage"] = "Email is required."; return(RedirectToAction("Register", "Account")); } else { if (viewRegistration.Username == "" || viewRegistration.Username == null) { TempData["ErrorMessage"] = "Usernamel is required."; return(RedirectToAction("Register", "Account")); } else { if (viewRegistration.Password == "" || viewRegistration.Password == null) { TempData["ErrorMessage"] = "Passord is required."; return(RedirectToAction("Register", "Account")); } else { int id; var auth = new Authentication { Username = viewRegistration.Username, Password = viewRegistration.Password }; lock (Lock) { id = UsersManager.CreateAuthentication(auth); } if (id > 0) { var user = new Users { Address = viewRegistration.Address, AuthenticationId = id, City = viewRegistration.City, Country = viewRegistration.Country, Email = viewRegistration.Email, Province = viewRegistration.Province, Phone = viewRegistration.Phone, LastName = viewRegistration.LastName, FirstName = viewRegistration.FirstName }; UsersManager.CreateUser(user); int UserId = UsersManager.GetUserIdByAuthId(id); var customer = new Customers { UserId = UserId }; CustomersManager.CreateCustomer(customer); TempData["Message"] = "Regitration completed! Login to Access the TableReady portal."; TempData["ErrorMessage"] = null; return(RedirectToAction("Login", "Account")); } else { TempData["Message"] = null; TempData["ErrorMessage"] = "USERNAME already exist.Try another one."; return(RedirectToAction(nameof(Register))); } } } } } } }
public async Task CreateUser(User user) { await usersManager.CreateUser(user); }