Пример #1
0
        public ActionResult Post([FromBody] CreateUserRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            else
            {
                var itemExists = _taskService.Users.Any(i => (string.Compare(i.EmailAddress, request.EmailAddress, true) == 0));
                if (itemExists)
                {
                    return(BadRequest());
                }
                User item = new User();
                item.UserId       = Guid.NewGuid().ToString().Replace("-", "");
                item.CreatedOnUtc = DateTime.UtcNow;
                item.UpdatedOnUtc = DateTime.UtcNow;
                item.EmailAddress = request.EmailAddress;
                if (_taskService.AddUser(item))
                {
                    HttpContext.Response.StatusCode = 201;
                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
        }