public ActionResult GetBrands() { var url = "http://localhost:55383/api/payment/get-brands"; var httpClient = new HttpClient(); var response = httpClient.GetAsync(url).Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { var data = httpClient.GetStringAsync(url).Result; var result = JsonConvert.DeserializeObject <List <CreditCardBrandViewModel> >(data); CreatePaymentBindingModel paymentModel; paymentModel = new CreatePaymentBindingModel(); paymentModel.Brands = result; return(RedirectToAction("CreatePayment", "Payment", new { model = paymentModel })); } throw new Exception("Status not recongnized"); }
public IActionResult Index() { var model = new CreatePaymentBindingModel { Courses = this.studentCourseInstancesService .GetCoursesForDropdownList() }; return(this.View(model)); }
public IActionResult Index(CreatePaymentBindingModel model) { var payment = this.studentPaymentsService .GetPaymentInfo(model); var payments = this.HttpContext .Session .Get <List <Payment> >(PaymentKey) ?? new List <Payment>(); payments.Add(payment); this.HttpContext .Session .Put(PaymentKey, payments); return(this.RedirectToAction("Cart")); }
public ActionResult CreatePayment(CreatePaymentBindingModel model) { var url = "http://localhost:55383/api/payment/create"; var firstName = model.FirstName; var lastName = model.LastName; var amount = model.Amount.ToString(); var creditCardNumber = model.CreditCardNumber; var securityCode = model.SecurityCode; var brandCode = model.BrandCode; var httpClient = new HttpClient(); var parameters = new List <KeyValuePair <string, string> >(); parameters .Add(new KeyValuePair <string, string>("firstName", firstName)); parameters .Add(new KeyValuePair <string, string>("lastName", lastName)); parameters .Add(new KeyValuePair <string, string>("amount", amount)); parameters .Add(new KeyValuePair <string, string>("creditCardNumber", creditCardNumber)); parameters .Add(new KeyValuePair <string, string>("securityCode", securityCode)); //parameters // .Add(new KeyValuePair<string, string>("brandCode", brandCode)); var encodedValues = new FormUrlEncodedContent(parameters); var response = httpClient.PostAsync(url, encodedValues).Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { var data = response.Content.ReadAsStringAsync().Result; var result = JsonConvert.DeserializeObject <CreatePaymentBindingModel>(data); CreatePaymentBindingModel paymentModel; paymentModel = new CreatePaymentBindingModel(); paymentModel.PaymentResult = result.PaymentResult; if (paymentModel.PaymentResult.IsSuccess) { TempData["paymentRsultMessage"] = paymentModel.PaymentResult.Message; } TempData["paymentRsultMessage"] = paymentModel.PaymentResult.Message; return(RedirectToAction("Index", "Home")); } else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { var data = response.Content.ReadAsStringAsync().Result; var result = JsonConvert.DeserializeObject <PaymentResultViewModel>(data); ModelState.AddModelError("", result.Message.ToString()); return(View()); } else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError) { return(View("Error")); } throw new Exception("Status not recongnized"); }