Esempio n. 1
0
        public async Task <IHttpActionResult> RegisterNewUser([FromBody] UserRegisterData user)
        {
            if (this.UserAlreadyExists(user.username))
            {
                return(BadRequest("User already exists!"));
            }

            if (!this.PasswordsMatch(user.password, user.confirm))
            {
                return(BadRequest("Passwords don't match"));
            }

            try
            {
                await this.userRepository.CreateUser(user);

                //await this.subscribersEvents.SendEventToSubscriber(user);

                return(Ok("User created successfully"));
            }
            catch (System.Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 2
0
 public async Task CreateUser(UserRegisterData user)
 {
     using (var db = new TokeServiceDbEntities())
     {
         db.Users.Add(this.MapUser(user));
         await db.SaveChangesAsync();
     }
 }
Esempio n. 3
0
 private User MapUser(UserRegisterData newUser)
 {
     return(new User()
     {
         role = (int)Core.Identity_Provider.Role.Candidate,
         guid = newUser.guid,
         instance = (int)Core.Identity_Provider.Instance.HeznekService,
         email = newUser.email,
         username = newUser.username,
         password = newUser.password.EncryptPassword()
     });
 }