public async Task <IHttpActionResult> Register(RegistrationUserVM model) { if (model == null) { return(BadRequest("Wypełnij pola")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } AppUser user = new AppUser { UserName = model.UserName, Email = model.Email }; var result = await AppUserManager.CreateAsync(user, model.Password); IHttpActionResult errorResult = GetErrorResult(result); var userDb = await AppUserManager.FindByNameAsync(model.UserName); await SendVerivicationCode(userDb.Id); return(Ok()); }
public async Task <IdentityResult> RegisterAppUser(RegistrationUserVM model) { AppUser user = new AppUser { UserName = model.UserName, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); return(result); }
public JsonResult SaveData(RegistrationUserVM model) { var check = _userService.GetUser(model.Username); if (check == null) { var credentials = _mapper.Map <Credential>(Credentials(model.Username, model.Password)); var user = _mapper.Map <User>(model); _userService.SaveData(user, credentials); } else { ModelState.AddModelError("Not new user", "Create new username"); } return(Json("Registration Successfull", JsonRequestBehavior.AllowGet)); }