public BorrowerDocument Post(BorrowerDocument document) { if (document == null) { throw new ValidationException("request was empty"); } var borrower = new Borrower { Name = document.Name }; repository.Save(borrower); return(Mapper.Map <BorrowerDocument>(borrower)); }
public BorrowerDocument Update(int id, BorrowerDocument document) { var borrower = repository.Get(id); if (borrower == null) { throw new ResourceNotFoundException("Borrower not Found"); } if (document == null) { throw new ValidationException("request was empty"); } borrower.Name = document.Name; repository.Update(borrower); return(Mapper.Map <BorrowerDocument>(borrower)); }
public IHttpContentResult <BorrowerDocument> Put(int borrowerId, BorrowerDocument document) { return(Request.CreateContentResponse(resource.Update(borrowerId, document))); }
public IHttpContentResult <BorrowerDocument> Post(BorrowerDocument document) { var result = resource.Post(document); return(Request.CreateNewContentResponse(new Uri($"v1/borrowers/{result.BorrowerId}"), result)); }