public async Task <int> DisburePension(ProcessPensionInput input)
        {
            PensionerDetails    pensioner = new PensionerDetails();
            HttpClient          client    = _pensionDetailApi.Initial();
            HttpResponseMessage res       = await client.GetAsync($"api/PensionerDetailss/{input.AdhaarNumber}");

            if (res.IsSuccessStatusCode)
            {
                var result = res.Content.ReadAsStringAsync().Result;
                pensioner = JsonConvert.DeserializeObject <PensionerDetails>(result);
                double currentAmount = pensioner.Salary;
                if (pensioner.PensionType == "Self")
                {
                    currentAmount = currentAmount * 80 / 100;
                }
                else
                {
                    currentAmount = currentAmount * 50 / 100;
                }
                currentAmount += pensioner.Allowances;
                if (pensioner.BankDetails.BankType == "Public")
                {
                    currentAmount -= 500;
                }
                else
                {
                    currentAmount -= 550;
                }
                if (currentAmount == input.PensionAmount)
                {
                    ProcessPensionStatusCode = 10;
                }
            }
            return(ProcessPensionStatusCode);
        }
        public async Task <ActionResult> AllDetails(AadharEntry AEntry)
        {
            if (HttpContext.Session.GetString("User") != null)
            {
                PensionDetailApi _api   = new PensionDetailApi();
                PensionerDetails Pd     = new PensionerDetails();
                HttpClient       client = _api.Initial();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token"));
                HttpResponseMessage res = await client.GetAsync($"api/ProcessPension/GetByAadhar?aadaharNo={AEntry.AadharNo}");

                if (res.IsSuccessStatusCode)
                {
                    var result = res.Content.ReadAsStringAsync().Result;
                    Pd = JsonConvert.DeserializeObject <PensionerDetails>(result);
                    if (Pd != null)
                    {
                        ViewBag.Name = Pd.Name;
                        return(View("ViewAllDetails", Pd));
                    }
                }
                ModelState.AddModelError("", "Enterd Incorrect Aadhar Number");
                return(View());
            }
            else
            {
                TempData["LoginError"] = "Cannot Go back as User logged out";
                return(RedirectToAction("Index", "Home"));
            }
        }
        public async Task <ActionResult> UserDetailsByAdhar()
        {
            if (HttpContext.Session.GetString("User") != null)
            {
                PensionDetailApi _api   = new PensionDetailApi();
                PensionerDetails Pd     = new PensionerDetails();
                HttpClient       client = _api.Initial();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token"));
                HttpResponseMessage res = await client.GetAsync($"api/ProcessPension/GetByAadhar?aadaharNo={Convert.ToDouble(HttpContext.Session.GetString("aadhar"))}");

                if (res.IsSuccessStatusCode)
                {
                    var result = res.Content.ReadAsStringAsync().Result;
                    Pd = JsonConvert.DeserializeObject <PensionerDetails>(result);
                    if (Pd != null)
                    {
                        ViewBag.Name = Pd.Name;
                        return(View("ViewAllDetails", Pd));
                    }
                }
                ViewBag.user  = $",{HttpContext.Session.GetString("User").ToUpper()}";
                ViewBag.error = $"Pension details for this {Convert.ToDouble(HttpContext.Session.GetString("aadhar"))} not exist in our system";
                return(View());
            }
            else
            {
                TempData["LoginError"] = "Cannot Go back as User logged out";
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #4
0
        //[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
        public async Task <ActionResult> Index(LoginModel user)
        {
            HttpClient          client  = _api.Initial();
            StringContent       content = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json");
            HttpResponseMessage res     = await client.PostAsync($"api/Auth/login", content);

            if (res.IsSuccessStatusCode)
            {
                var token = res.Content.ReadAsStringAsync().Result;
                if (token != null)
                {
                    HttpContext.Session.SetString("token", token);
                    HttpContext.Session.SetString("aadhar", user.Aadhar.ToString());
                    HttpContext.Session.SetString("User", user.Username);
                    return(RedirectToAction("Home", "Pensioner"));
                }
            }
            ViewBag.LoginError = "Invalid Login Credentials";
            return(View());
        }
        public async Task <ActionResult> Index(PensionInput pension)
        {
            if (HttpContext.Session.GetString("User") != null)
            {
                Pension    pensioner = new Pension();
                HttpClient client    = _api.Initial();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token"));
                HttpResponseMessage res = await client.GetAsync($"api/ProcessPension/?name={pension.PensionerName}&pan={pension.PensionerPAN}&aadaharNo={pension.Aadhar}&type={pension.PensionType}");

                if (res.IsSuccessStatusCode)
                {
                    var result = res.Content.ReadAsStringAsync().Result;
                    pensioner = JsonConvert.DeserializeObject <Pension>(result);
                    if (pensioner != null)
                    {
                        ViewBag.Name = pension.Aadhar;
                        return(View("Details", pensioner));
                    }
                }
                ViewBag.PensionTypeId = new SelectListItem[] {
                    new SelectListItem()
                    {
                        Text = "Select", Value = string.Empty
                    },
                    new SelectListItem()
                    {
                        Text = "Self", Value = "Self"
                    },
                    new SelectListItem()
                    {
                        Text = "Family", Value = "Family"
                    }
                };
                ViewBag.ErrorMessage = "Details Not Found.Please Enter Correct Details";

                return(View());
            }
            else
            {
                TempData["LoginError"] = "Cannot Go back as User logged out";
                return(RedirectToAction("Index", "Home"));
            }
        }