Beispiel #1
0
        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());
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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));
        }