Esempio n. 1
0
        public async Task <HttpStatusCode> UpdateCoffee(string coffeeDisplayId, List <PatchDto> patchDtos)
        {
            var statusCode = HttpStatusCode.NoContent;

            coffeeDisplayId.CheckArgumentIsNull(nameof(coffeeDisplayId));

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

            _logger.LogInformation($"Service-UpdateCoffee-Executing get the coffee to be patched {DateTime.UtcNow}");

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

            if (coffeeFromDb == null)
            {
                _logger.LogInformation($"No Area found with coffeeDisplayId {coffeeDisplayId}");
                statusCode = HttpStatusCode.NotFound;
            }
            else
            {
                _coffeeRepository.ApplyPatch(coffeeFromDb, patchDtos);
                await _coffeeRepository.SaveAllwithAudit().ConfigureAwait(false);
            }

            return(statusCode);
        }