示例#1
0
        public IActionResult Create([FromBody] CreateUserDTO createUser)
        {
            var userId = _userAppService.Create(createUser);

            return(new ObjectResult(userId)
            {
                StatusCode = (int)HttpStatusCode.Created
            });
        }
示例#2
0
        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());
        }
示例#3
0
        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;
            }
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }