Example #1
0
        public async Task <IActionResult> CreateBeer([FromBody] Beer beer)
        {
            var validationResults = await _brandValidation.ValidateBeer(beer);

            if (validationResults.Any(validationResult => validationResult != ValidationResult.Success))
            {
                return(new BadRequestObjectResult(validationResults.Where(result => result != null).Select(result => result?.ErrorMessage)));
            }

            return(new OkObjectResult(await _brandService.CreateBeer(beer)));
        }
        public async Task <Guid> CreateBeer(Beer beer)
        {
            await _brandValidation.ValidateBeer(beer);

            return(await _brandDataAccess.CreateBeer(beer.ToEntity()));
        }