Ejemplo n.º 1
0
        public async Task <HttpStatusCode> DeleteCoffee(string coffeeDisplayId)
        {
            var statusCode = HttpStatusCode.NoContent;

            coffeeDisplayId.CheckArgumentIsNull(nameof(coffeeDisplayId));

            _logger.LogInformation($"Service-DeleteCoffee-Executing DeleteCoffee started at {DateTime.UtcNow}");

            var coffeeFromDb = await _coffeeRepository.FindAsync(s => s.CoffeeDisplayId == coffeeDisplayId).ConfigureAwait(false);

            if (coffeeFromDb == null)
            {
                _logger.LogInformation($"No Coffee found with coffee id  {coffeeDisplayId}");
                statusCode = HttpStatusCode.NotFound;
            }
            else
            {
                _coffeeRepository.SoftDeleteAsync(coffeeFromDb);
                await _coffeeRepository.SaveAllwithAudit().ConfigureAwait(false);
            }

            return(statusCode);
        }