public async Task <IActionResult> Put( [FromServices] ITransactionTypeBO transactionTypeBO, string id, [FromBody] TransactionType transactionType) { try { int result = await transactionTypeBO.Update(id, transactionType); if (result == 1) { return(NoContent()); } else { return(UnprocessableEntity("Error on update")); } } catch (Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException e) { return(NotFound(e.Message)); } catch (DbException e) { return(UnprocessableEntity(e.Message)); } catch (Exceptions.NotFoundException e) { return(NotFound("Not Found")); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public async Task <IActionResult> Post( [FromServices] ITransactionTypeBO transactionTypeBO, [FromBody] TransactionType transactionType) { try { int result = await transactionTypeBO.Save(transactionType); if (result == 1) { return(CreatedAtAction(null, null)); } else { return(UnprocessableEntity("Error on create")); } } catch (DbException e) { return(UnprocessableEntity(e.Message)); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public async Task <IActionResult> Delete( [FromServices] ITransactionTypeBO transactionTypeBO, string id) { try { int result = await transactionTypeBO.Delete(id); if (result == 1) { return(NoContent()); } else { return(UnprocessableEntity("Error on delete")); } } catch (Exceptions.NotFoundException e) { return(NotFound(e.Message)); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public async Task <ActionResult <IEnumerable <TransactionType> > > GetAll( [FromServices] ITransactionTypeBO ttypeBO) { try { var ttypes = await ttypeBO.GetAll(); return(Ok(ttypes)); } catch (Exceptions.NotFoundException e) { return(NotFound(e.Message)); } catch (System.Exception e) { return(BadRequest(e.Message)); } }