예제 #1
0
        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));
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        public Payment MakePayment(BillServices services)
        {
            Payment pay = new Payment()
            {
                BillId = services.BillNo, Amount = services.BillAmt
            };

            _payment.Payments.Add(pay);
            _payment.SaveChanges();
            return(pay);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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());
            }
        }