Esempio n. 1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "customers")] HttpRequest request)
        {
            var createCustomerRequest = await _dtoService.GetModelAsync <CreateCustomerRequest>(request);

            var operation = await _customerService.CreateAsync(new Customer
            {
                Id      = Guid.NewGuid().ToString("N").ToUpper(),
                Name    = createCustomerRequest.CustomerName,
                Address = createCustomerRequest.CustomerAddress
            });

            if (operation.Status)
            {
                return(new OkObjectResult(operation.Data));
            }

            return(new BadRequestObjectResult(operation.ErrorMessage));
        }