Exemplo n.º 1
0
 public IActionResult PostTransfer([FromBody] SaveTransferResource record)
 {
     if (ModelState.IsValid)
     {
         try {
             repo.Create(mapper.Map <SaveTransferResource, Transfer>(record));
             SendNotificationsToClients();
             return(StatusCode(200, new {
                 response = ApiMessages.RecordCreated()
             }));
         } catch (Exception exception) {
             LoggerExtensions.LogException(0, logger, ControllerContext, record, exception);
             return(StatusCode(490, new {
                 response = ApiMessages.RecordNotSaved()
             }));
         }
     }
     LoggerExtensions.LogException(0, logger, ControllerContext, record, null);
     return(StatusCode(400, new {
         response = ApiMessages.InvalidModel()
     }));
 }
Exemplo n.º 2
0
 public IActionResult PutTransfer([FromRoute] int id, [FromBody] SaveTransferResource record)
 {
     if (id == record.Id && ModelState.IsValid)
     {
         try {
             repo.Update(record);
             SendNotificationsToClients();
             return(StatusCode(200, new {
                 response = ApiMessages.RecordUpdated()
             }));
         } catch (DbUpdateException exception) {
             LoggerExtensions.LogException(0, logger, ControllerContext, record, exception);
             return(StatusCode(490, new {
                 response = ApiMessages.RecordNotSaved()
             }));
         }
     }
     LoggerExtensions.LogException(0, logger, ControllerContext, record, null);
     return(StatusCode(400, new {
         response = ApiMessages.InvalidModel()
     }));
 }