public void Handle(string target, HttpRequest baseRequest, HttpResponse response) { response.SetContentType("application/json;charset=utf-8"); response.SetStatus(HttpStatusCode.OK); baseRequest.SetHandled(true); try { if (IsApplication(baseRequest)) { LoanApplication application = new LoanApplication(); application.SetAmount(AmountFrom(baseRequest)); application.SetContact(ContactFrom(baseRequest)); Ticket ticket = _loanRepository.Store(application); response.Write(JsonSerialiser.ToJson(ticket)); } else if (IsStatusRequest(baseRequest) && IdSpecified(baseRequest)) { response.Write(FetchLoanInfo(baseRequest.GetParameter(TICKET_ID))); } else if (IsApproval(baseRequest) && IdSpecified(baseRequest)) { response.Write(ApproveLoan(baseRequest.GetParameter(TICKET_ID))); } else { response.Write("Incorrect parameters provided"); } } catch (ApplicationException ex) { response.Write("Uh oh! Problem occured: " + ex); } }
private string FetchLoanInfo(string ticketId) { LoanApplication formerApplication = _loanRepository.Fetch(ticketId); return(JsonSerialiser.ToJson(formerApplication)); }