public void Update(UpdateCalendarDateDto dto)
        {
            var calendarDate = _calendarDateRepository.GetById(dto.Id);

            if (calendarDate != null)
            {
                calendarDate.Title     = dto.Title;
                calendarDate.IsHoliday = dto.IsHoliday;

                _calendarDateRepository.Update(calendarDate);
            }
            else
            {
                try
                {
                    throw new LogicalException();
                }
                catch (LogicalException ex)
                {
                    _logger.LogLogicalError
                        (ex, "CalendarDate entity with the id: '{0}', is not available." +
                        " update operation failed.", dto.Id);
                    throw;
                }
            }
        }
Пример #2
0
 public IHttpActionResult Update([FromBody] UpdateCalendarDateDto calendarDate)
 {
     if (calendarDate == null)
     {
         return(BadRequest());
     }
     if (!ModelState.IsValid)
     {
         string errorMessage = new ModelStateError(_logger).OutputMessage(ModelState);
         return(BadRequest(errorMessage));
     }
     try
     {
         _calendarDateService.Update(calendarDate);
     }
     catch (LogicalException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch
     {
         return(BadRequest(AppSettings.INTERNAL_SERVER_ERROR_MESSAGE));
     }
     return(Ok());
 }