Example #1
0
        public static PaymentGenerateResponseModel GeneratePayment(PaymentGenerateRequestModel model)
        {
            PaymentGenerateResponseModel responseModel = new PaymentGenerateResponseModel();
            Payments newpayment = new Payments(model.Acc, model.Amount, model.Description);

            payments.Add(newpayment);
            responseModel.PaymentId = payments.Count;
            responseModel.IsSuccess = true;
            responseModel.Message   = "Payment created";
            return(responseModel);
        }
        public HttpResponseMessage GeneratePayment(PaymentGenerateRequestModel model)
        {
            HttpResponseMessage          httpResponse  = new HttpResponseMessage();
            PaymentGenerateResponseModel responsemodel = new PaymentGenerateResponseModel();

            if (!ModelState.IsValid)
            {
                responsemodel.IsSuccess = false;
                responsemodel.Message   = "False Request";

                httpResponse.Content    = new StringContent(JsonConvert.SerializeObject(responsemodel));
                httpResponse.StatusCode = HttpStatusCode.ExpectationFailed;
                return(httpResponse);
            }
            responsemodel           = PaymentDB.GeneratePayment(model);
            httpResponse.Content    = new StringContent(JsonConvert.SerializeObject(responsemodel));
            httpResponse.StatusCode = HttpStatusCode.Accepted;
            return(httpResponse);
        }