Example #1
0
        public async Task <IActionResult> Register([FromBody] LoginViewModel requestedUser)
        {
            if (ModelState.IsValid)
            {
                var newUser = Mapper.Map <PGUser>(requestedUser);
                _repository.AddUser(newUser);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"{requestedUser.Username}", Mapper.Map <LoginViewModel>(newUser)));
                }
            }

            return(BadRequest("Failed to Save User"));
        }