示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
 public IHttpContentResult <BorrowerDocument> Put(int borrowerId, BorrowerDocument document)
 {
     return(Request.CreateContentResponse(resource.Update(borrowerId, document)));
 }
示例#4
0
        public IHttpContentResult <BorrowerDocument> Post(BorrowerDocument document)
        {
            var result = resource.Post(document);

            return(Request.CreateNewContentResponse(new Uri($"v1/borrowers/{result.BorrowerId}"), result));
        }