public bool EditCreditRequestForOnlinePayment(CreditRequestDTO creditRequestDTO, bool IsSuccess) { try { if (creditRequestDTO.PaymentId == null) { return(false); } return(CreditRequestService.EditCreditRequestForOnlinePayment(creditRequestDTO, IsSuccess)); } catch (TimeoutException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout) { Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."), ReasonPhrase = "Critical Exception" }); } catch (Exception) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."), ReasonPhrase = "Critical Exception" }); } }
public static CreditRequestDTO CreditRequestToDTO(CreditRequest CreditRequest) { if (CreditRequest == null) { return(null); } Mapper.CreateMap <CreditRequest, CreditRequestDTO>(); CreditRequestDTO CreditRequestDTO = Mapper.Map <CreditRequestDTO>(CreditRequest); return(CreditRequestDTO); }
public static CreditRequest CreditRequestToDomain(CreditRequestDTO CreditRequestDTO) { if (CreditRequestDTO == null) { return(null); } Mapper.CreateMap <CreditRequestDTO, CreditRequest>(); CreditRequest CreditRequest = Mapper.Map <CreditRequest>(CreditRequestDTO); CreditRequest._clientName = ClientService.GetById(CreditRequest.ClientId).Company; CreditRequest._userName = UserService.GetById(CreditRequest.RequestedBy).Name; return(CreditRequest); }
public CreditRequestDTO GenerateBill(CreditRequestDTO CreditRequestDTO) { try { return(CreditRequestService.GenerateBill(CreditRequestDTO)); } catch (TimeoutException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout) { Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."), ReasonPhrase = "Critical Exception" }); } catch (Exception) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."), ReasonPhrase = "Critical Exception" }); } }
public PaymentDTO GetPaymentDetailsURLByPaimentId(string paymentId) { try { payment OnlinePaymentDTO = new payment(); //OnlinePaymentDTO var queryString = HttpContext.Current.Request.QueryString; string payment_id = paymentId; string PaymentDetailUrl = ConfigurationManager.AppSettings["PaymentDetailsUrl"].ToString();// "https://test.instamojo.com/api/1.1/payments/[payment_id]?api_key=4709c5655f99d3799ccc22d8da23a137&auth_token=820cb88637df64e703782970c729a5fb"; PaymentDetailUrl = PaymentDetailUrl.Replace("%26", "&"); PaymentDetailUrl = PaymentDetailUrl.Replace("[payment_id]", payment_id); WebRequest request = HttpWebRequest.Create(PaymentDetailUrl); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string responseText = reader.ReadToEnd(); //responseText = responseText.Replace("\n",""); PaymentDTO PaymentDTO = JsonConvert.DeserializeObject <PaymentDTO>(responseText); if (PaymentDTO != null) { if (PaymentDTO.payment.custom_fields != null) { int CreditRequestId = Convert.ToInt32(PaymentDTO.payment.custom_fields.Field_52722.value); CreditRequestDTO CreditRequestDTO = new CreditRequestDTO(); CreditRequestDTO = CreditRequestService.GetById(CreditRequestId); if (PaymentDTO.success == true) { if (CreditRequestDTO.IsPaid != true) { CreditRequestDTO.PaymentId = PaymentDTO.payment.payment_id; CreditRequestDTO.ProvidedCredit = CreditRequestDTO.RequestedCredit; CreditRequestService.EditCreditRequestForOnlinePayment(CreditRequestDTO, true); } } else { CreditRequestDTO.PaymentId = PaymentDTO.payment.payment_id; CreditRequestDTO.IsPaid = false; CreditRequestService.EditCreditRequestForOnlinePayment(CreditRequestDTO, false); } } } // PaymentInfoDTO PaymentInfoDTO = JsonConvert.DeserializeObject<PaymentInfoDTO>(responseText); // OnlinePaymentDTO = urlpaymentId; //return PaymentDetailUrl; return(PaymentDTO);// OnlinePaymentDTO; } catch (TimeoutException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout) { Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."), ReasonPhrase = "Critical Exception" }); } catch (Exception) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."), ReasonPhrase = "Critical Exception" }); } }