コード例 #1
0
        public void Update(UpdateWorkUnitDto dto)
        {
            var workUnit = _workUnitRepository.GetById(dto.Id);

            if (workUnit != null)
            {
                workUnit.Title = dto.Title;

                _workUnitRepository.Update(workUnit);
            }
            else
            {
                try
                {
                    throw new LogicalException();
                }
                catch (LogicalException ex)
                {
                    _logger.LogLogicalError
                        (ex, "WorkUnit entity with the id: '{0}', is not available." +
                        " update operation failed.", dto.Id);
                    throw;
                }
            }
        }
コード例 #2
0
 public IHttpActionResult Update([FromBody] UpdateWorkUnitDto workUnit)
 {
     if (workUnit == null)
     {
         return(BadRequest());
     }
     if (!ModelState.IsValid)
     {
         string errorMessage = new ModelStateError(_logger).OutputMessage(ModelState);
         return(BadRequest(errorMessage));
     }
     try
     {
         _workUnitService.Update(workUnit);
     }
     catch (LogicalException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch
     {
         return(BadRequest(AppSettings.INTERNAL_SERVER_ERROR_MESSAGE));
     }
     return(Ok());
 }