示例#1
0
        public async Task <IActionResult> Put([FromBody] WeekUpdateDto week)
        {
            try
            {
                _weekService.Update(week);
                var saveResult = await _weekService.SaveAsync();

                if (saveResult == 0)
                {
                    _logger.LogError($"Unable to update a week at this time id: {week.Id}");
                    return(StatusCode(StatusCodes.Status500InternalServerError));
                }

                return(NoContent());
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, $"An error occurred while trying to update a week id: {week.Id}");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
        public void Update(WeekUpdateDto week)
        {
            var weekToUpdate = _context.ForecastWeeks.Single(x => x.Id == week.Id);

            _mapper.Map <ForecastWeek>(week);
        }