public IActionResult Get(Guid id) { var user = _userService.Get(id); var userViewModel = _userModelBuilder.BuildNew(user); return(Ok(userViewModel)); }
public IActionResult Register(RegisterUserForm registerViewModel) { if (ModelState.IsValid) { if (!_validateService.IsExistLogin(registerViewModel.Login)) { var roles = registerViewModel.RoleIds.Select(r => _roleService.Get(r)); var registeredUser = _accountService.Register( registerViewModel.Login, registerViewModel.Password, registerViewModel.FirstName, registerViewModel.LastName, registerViewModel.SurName, registerViewModel.Gender, registerViewModel.BirthDate, registerViewModel.Snils, registerViewModel.Email, registerViewModel.Phone, registerViewModel.RegistrationAddress, registerViewModel.FactAddress, registerViewModel.OtherPhones, roles); var url = Url.Link("UserResource", new { id = registeredUser.Id }); var userViewModel = _userModelBuilder.BuildNew(registeredUser); return(Created(url, userViewModel)); } else { return(BadRequest("Логин занят")); } } else { return(BadRequest("Заполните форму")); } }