Exemplo n.º 1
0
        public async Task <HttpStatusCode> UpdateArea(string areaDisplayId, List <PatchDto> patchDtos)
        {
            var statusCode = HttpStatusCode.NoContent;

            areaDisplayId.CheckArgumentIsNull(nameof(areaDisplayId));

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

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

            var areaDromDb = await _areaRepository.FindAsync(s => s.AreaDisplayId == areaDisplayId && s.IsActive).ConfigureAwait(false);

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

            return(statusCode);
        }