Ejemplo n.º 1
0
        public async Task <IActionResult> CreateUser(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "users/Create")] HttpRequestMessage req,
            HttpRequest request, ILogger log)
        {
            var resultAuth = validAdmin(req, request, new List <string>()
            {
                "users.read"
            });

            if (!resultAuth.Success)
            {
                return(new BadRequestObjectResult(resultAuth.Message));
            }

            UserModel data = await req.Content.ReadAsAsync <UserModel>();

            var dataResult = await _controller.Create(data);

            if (!dataResult.Success)
            {
                return(new BadRequestObjectResult(dataResult.Message));
            }

            return(new OkObjectResult(dataResult.Value));
        }
Ejemplo n.º 2
0
        public IActionResult OnPostCreate(CreateUserVM command)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToPage("Index"));
            }
            var result = _userApplication.Create(command);

            return(new JsonResult(result));
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> UserRegistration([FromBody] User model)
 {
     try
     {
         return(Ok(await userApp.Create(model)));
     }
     catch (System.Exception)
     {
         throw;
     }
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([FromBody] CreateUserViewModel model)
        {
            if (model == null)
            {
                return(NoContent());
            }

            var validation = new CreateUserValidation(_user).Validate(model);

            if (!validation.IsValid)
            {
                return(BadRequest(new Validator(validation)));
            }

            await _user.Create(model);

            return(Ok());
        }