public async Task <IActionResult> MakePayment(int BillNo) { if (HttpContext.Session.GetString("token") == null) { return(RedirectToAction("Login", "Login")); } else { BillServices Item = new BillServices(); BillServicesViewModel s = new BillServicesViewModel(); using (var client = new HttpClient()) { var contentType = new MediaTypeWithQualityHeaderValue("application/json"); client.DefaultRequestHeaders.Accept.Add(contentType); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token")); using (var response = await client.GetAsync("https://localhost:44328/api/Payments/")) { string apiResponse = await response.Content.ReadAsStringAsync(); Item = JsonConvert.DeserializeObject <BillServices>(apiResponse); } s.BillId = Item.BillNo; s.Amt = Item.BillAmt; } return(View(s)); } }
public async Task <IActionResult> GetBill(int id) { if (HttpContext.Session.GetString("token") == null) { return(RedirectToAction("Login", "Login")); } else { BillServices b = new BillServices(); using (var client = new HttpClient()) { var contentType = new MediaTypeWithQualityHeaderValue("application/json"); client.DefaultRequestHeaders.Accept.Add(contentType); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token")); using (var response = await client.GetAsync("https://localhost:44360/api/Bill/GetDetails" + id)) { string apiResponse = await response.Content.ReadAsStringAsync(); b = JsonConvert.DeserializeObject <BillServices>(apiResponse); } } return(View(b)); } }
public Payment MakePayment(BillServices services) { Payment pay = new Payment() { BillId = services.BillNo, Amount = services.BillAmt }; _payment.Payments.Add(pay); _payment.SaveChanges(); return(pay); }
public void GetAll() { var obj = new BillServices() { BillNo = 1234, CustomerName = "Manisha", BillAmt = 189 }; var itemrepo = new PaymentRepository(itemcontextmock.Object); var itemlist = itemrepo.MakePayment(obj); Assert.NotNull(itemlist); }
public IActionResult Post([FromBody] BillServices model) { try { _log4net.Info("Bill details"); if (ModelState.IsValid) { var payobj = _repo.MakePayment(model); return(Ok(payobj)); } return(BadRequest()); } catch { _log4net.Error("Error"); return(new NoContentResult()); } }