コード例 #1
0
ファイル: LoanHandler.cs プロジェクト: benrnz-sv/Mikado1
        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);
            }
        }
コード例 #2
0
        private string FetchLoanInfo(string ticketId)
        {
            LoanApplication formerApplication = _loanRepository.Fetch(ticketId);

            return(JsonSerialiser.ToJson(formerApplication));
        }