public IActionResult Create([FromBody] CreateUserDTO createUser) { var userId = _userAppService.Create(createUser); return(new ObjectResult(userId) { StatusCode = (int)HttpStatusCode.Created }); }
public async Task <IActionResult> Register([FromBody] UserRegisterDto userRegisterDto) { var user = await userAppService.Get(userRegisterDto.Email); if (user != null) { return(UnprocessableEntity(new { Error = "Пользователь с таким email уже существует." })); } await userAppService.Create(userRegisterDto); return(new OkResult()); }
public User Post([FromBody] User user) { try { if (_logger.IsTraceEnabled) { _logger.Trace("User/Post - {0}", JsonConvert.SerializeObject(user)); } return(_userAppService.Create(user)); } catch (Exception ex) { _logger.Error(ex, String.Format("ERROR: User/Post user: {0}", JsonConvert.SerializeObject(user))); throw; } }
public ActionResult Post([FromBody] UserBO userBO) { UserAppService userAppService = new UserAppService(); ApiResponse _apiResponse = new ApiResponse(); try { userAppService.Create(userBO); _apiResponse.HttpStatusCode = "200"; _apiResponse.Message = "User successfully created"; _apiResponse.Status = "Success"; } catch (Exception ex) { _apiResponse.HttpStatusCode = "500"; _apiResponse.Message = ex.InnerException.Message; _apiResponse.Status = "Error"; } return(Ok(_apiResponse)); }
public async Task <ActionResult> Registration(RegisterModel model) { await SetInitialDataAsync(); if (ModelState.IsValid) { UserDTO userDto = new UserDTO { Email = model.Email, Password = model.Password, FirstName = model.FirstName, LastName = model.LastName, Login = model.Login, UserRole = UserRoleDTO.User }; try { _userService.CreateUser(userDto); } catch { ViewBag.Error = "Cannot register this user"; return(View(model)); } OperationDetails operationDetails = await UserAppService.Create(userDto); if (operationDetails.Succedeed) { return(View("SuccessRegister")); } else { ModelState.AddModelError(operationDetails.Property, operationDetails.Message); } } return(View(model)); }