Ejemplo n.º 1
0
        public async Task <IActionResult> PensionerValues(PensionerInput input)
        {
            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    StringContent content = new StringContent(JsonConvert.SerializeObject(input), Encoding.UTF8, "application/json");

                    client.BaseAddress = new Uri("http://52.143.250.249/");
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                    client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                    using (var response = await client.GetAsync("https://localhost:44317/api/CustomerCareService/" + content))    //Get Post Mai check kar lena
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        pen = JsonConvert.DeserializeObject <PensionDetail>(apiResponse);
                    }
                }
                return(RedirectToAction("PensionervaluesDisplayed"));
            }

            else
            {
                ViewBag.invalid = "Pensioner Values are Invalid";
                return(View());
            }
        }
Ejemplo n.º 2
0
        public Pension GetPension(PensionerInput pensionerInput)
        {
            double?pensionamount = 0;

            Pension         pension   = new();
            PensionerDetail pensioner = provider.GetPensionerInfo(pensionerInput.AadhaarNo);

            if (pensioner.PensionType == 1)
            {
                pensionamount = pensioner.Salary * 0.8 + pensioner.Allowance;
            }
            else if (pensioner.PensionType == 2)
            {
                pensionamount = pensioner.Salary * 0.5 + pensioner.Allowance;
            }
            if (pensioner.BankType == 1)
            {
                pensionamount -= 500;
            }
            if (pensioner.BankType == 2)
            {
                pensionamount -= 550;
            }
            pension.Name          = pensioner.Name;
            pension.DOB           = pensioner.Dob;
            pension.PAN           = pensioner.Pan;
            pension.PensionAmount = pensionamount;
            pension.PensionType   = pensioner.PensionType;
            return(pension);
        }
        public async Task <ActionResult> PensionPortal(PensionerInput input)
        {
            if (HttpContext.Session.GetString("token") == null)
            {
                _log4net.Info("Pensioner is not logged in");
                ViewBag.Message = "Please Login First";
                return(View("Login"));
            }

            _log4net.Info("Processing the pension began");


            string processValue = configuration.GetValue <string>("MyLinkValue:processUri");

            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    StringContent content = new StringContent(JsonConvert.SerializeObject(input), Encoding.UTF8, "application/json");
                    client.BaseAddress = new Uri(processValue);

                    try
                    {
                        using (var response = await client.PostAsync("api/ProcessPension/ProcessPension/", content))
                        {
                            var apiResponse = await response.Content.ReadAsStringAsync();

                            ProcessResponse res = JsonConvert.DeserializeObject <ProcessResponse>(apiResponse);
                            penDetailObj.Status        = res.Result.Status;
                            penDetailObj.PensionAmount = res.Result.PensionAmount;

                            ResDetails.PensionAmount = penDetailObj.PensionAmount;
                            ResDetails.Status        = penDetailObj.Status;
                        }
                    }
                    catch (Exception e)
                    {
                        _log4net.Error("Some Microservice is Down!!");
                        penDetailObj = null;
                    }
                }

                if (penDetailObj == null)
                {
                    _log4net.Error("Some Microservice is Down!!");
                    ViewBag.erroroccured = "Some Error Occured";
                    return(View());
                }
                if (penDetailObj.Status.Equals(21))
                {
                    _log4net.Error("Some Microservice is Down!!");
                    ViewBag.erroroccured = "Some Error Occured";
                    return(View());
                }
                if (penDetailObj.Status.Equals(10))
                {
                    // Storing the Values in Database
                    _log4net.Info("Pensioner details have been matched with the Csv and data is successfully saved in local Database!!");
                    repo.AddResponse(ResDetails);
                    repo.Save();
                    return(RedirectToAction("PensionervaluesDisplayed", ResDetails));
                }
                else
                {
                    _log4net.Error("Persioner details does not match with the Csv!!");
                    ViewBag.notmatch = "Pensioner Values not match";
                    return(View());
                }
            }
            _log4net.Warn("Proper details are not given by the Admin!!");
            ViewBag.invalid = "Pensioner Values are Invalid";
            return(View());
        }
        public IActionResult ProcessPension(PensionerInput processPensionInput)
        {
            _log4net.Info("Pensioner details invoked from Client Input");
            PensionerInput client = new PensionerInput();

            client.Name          = processPensionInput.Name;
            client.AadhaarNumber = processPensionInput.AadhaarNumber;
            client.PAN           = processPensionInput.PAN;
            client.DateOfBirth   = processPensionInput.DateOfBirth;
            client.PensionType   = processPensionInput.PensionType;

            //repo = new ProcessRepo(pro);
            PensionDetail pensionDetail = _repo.GetClientInfo(client.AadhaarNumber);

            if (pensionDetail == null)
            {
                PensionDetail mvc = new PensionDetail();
                mvc.Name          = "";
                mvc.Pan           = "";
                mvc.PensionAmount = 0;
                mvc.DateOfBirth   = new DateTime(2000, 01, 01);
                mvc.BankType      = 1;
                mvc.AadharNumber  = "***";
                mvc.Status        = 20;

                return(NotFound());
            }



            double pensionAmount;

            ValueforCalCulation pensionerInfo = _repo.GetCalculationValues(client.AadhaarNumber);

            pensionAmount = CalculatePensionAmount(pensionerInfo.SalaryEarned, pensionerInfo.Allowances, pensionerInfo.BankType, pensionerInfo.PensionType);

            int statusCode;

            PensionDetail mvcClientOutput = new PensionDetail();

            if (client.AadhaarNumber.Equals(pensionDetail.AadharNumber))
            {
                mvcClientOutput.Name          = pensionDetail.Name;
                mvcClientOutput.Pan           = pensionDetail.Pan;
                mvcClientOutput.PensionAmount = pensionAmount;
                mvcClientOutput.DateOfBirth   = pensionDetail.DateOfBirth.Date;
                mvcClientOutput.PensionType   = pensionerInfo.PensionType;
                mvcClientOutput.BankType      = pensionerInfo.BankType;
                mvcClientOutput.AadharNumber  = pensionDetail.AadharNumber;
                mvcClientOutput.Status        = 20;
            }
            else
            {
                mvcClientOutput.Name          = "";
                mvcClientOutput.Pan           = "";
                mvcClientOutput.PensionAmount = 0;
                mvcClientOutput.DateOfBirth   = new DateTime(2000, 01, 01);
                mvcClientOutput.PensionType   = pensionerInfo.PensionType;
                mvcClientOutput.BankType      = 1;
                mvcClientOutput.AadharNumber  = "****";
                mvcClientOutput.Status        = 21;

                //return mvcClientOutput;
            }

            ProcessPensionInput input = new ProcessPensionInput();

            input.AadhaarNumber = mvcClientOutput.AadharNumber;
            input.PensionAmount = mvcClientOutput.PensionAmount;
            if (mvcClientOutput.BankType == 1)
            {
                input.BankCharge = 500;
            }
            else
            {
                input.BankCharge = 550;
            }



            HttpResponseMessage response = _repo.GetDisbursementMessage(input);

            if (response != null)
            {
                string status = response.Content.ReadAsStringAsync().Result;
                //statusCode = Int32.Parse(status);
                ProcessPensionResponse res = JsonConvert.DeserializeObject <ProcessPensionResponse>(status);

                statusCode      = res.processPensionStatusCode;
                processResponse = new ProcessResponse()
                {
                    Status        = statusCode,
                    PensionAmount = mvcClientOutput.PensionAmount
                };

                return(Ok(processResponse));
            }
            return(Ok(processResponse));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PensionerValues(PensionerInput input)
        {
            // string status;

            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    StringContent content = new StringContent(JsonConvert.SerializeObject(input), Encoding.UTF8, "application/json");

                    client.BaseAddress = new Uri("https://localhost:44394/");
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                    client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                    try
                    {
                        using (var response = await client.PostAsync("api/ProcessPension/GetClient", content))    //Get Post Mai check kar lena
                        {
                            //var response = await client.GetAsync("api/ProcessPension/");
                            string apiResponse = await response.Content.ReadAsStringAsync();

                            penDetailObj = JsonConvert.DeserializeObject <PensionDetail>(apiResponse);
                        }
                    }
                    catch (Exception e)
                    {
                        penDetailObj = null;
                    }
                }

                //return RedirectToAction("PensionervaluesDisplayed",pen);


                if (penDetailObj == null)
                {
                    ViewBag.erroroccured = "Some Error Occured";
                    return(View());
                }
                if (penDetailObj.status.Equals(20))
                {
                    ViewBag.erroroccured = "Some Error Occured";
                    return(View());
                }
                if (penDetailObj.status.Equals(10))
                {
                    // ViewBag.invalid = "Pensioner Values are Invalid";
                    _context.pensionDetails.Add(penDetailObj);
                    _context.SaveChanges();
                    return(RedirectToAction("PensionervaluesDisplayed", penDetailObj));
                }
                else
                {
                    ViewBag.notmatch = "Pensioner Values not match";
                    return(View());
                }
            }

            else
            {
                ViewBag.invalid = "Pensioner Values are Invalid";
                return(View());
            }
        }
        public async Task <IActionResult> PensionerValues(PensionerInput input)
        {
            // string status;
            string processValue = configuration.GetValue <string>("MyLinkValue:processUri");

            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    StringContent content = new StringContent(JsonConvert.SerializeObject(input), Encoding.UTF8, "application/json");

                    client.BaseAddress = new Uri(processValue);
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                    client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                    try
                    {
                        using (var response = await client.PostAsync("api/ProcessPension/ProcessPension", content))    //Get Post Mai check kar lena
                        {
                            string apiResponse = await response.Content.ReadAsStringAsync();

                            Result res = JsonConvert.DeserializeObject <Result>(apiResponse);
                            penDetailObj = res.result;
                        }
                    }
                    catch (Exception e)
                    {
                        _log4net.Error("Some Microservice is Down!!");
                        penDetailObj = null;
                    }
                }

                if (penDetailObj == null)
                {
                    _log4net.Error("Some Microservice is Down!!");
                    ViewBag.erroroccured = "Some Error Occured";
                    return(View());
                }
                if (penDetailObj.Status.Equals(20))
                {
                    _log4net.Error("Some Microservice is Down!!");
                    ViewBag.erroroccured = "Some Error Occured";
                    return(View());
                }
                if (penDetailObj.Status.Equals(10))
                {
                    // Storing the Values in Database
                    _log4net.Info("Pensioner details have been matched with the Csv and data is successfully saved in local Database!!");
                    _context.pensionDetails.Add(penDetailObj);
                    _context.SaveChanges();
                    return(RedirectToAction("PensionervaluesDisplayed", penDetailObj));
                }
                else
                {
                    _log4net.Error("Persioner details does not match with the Csv!!");
                    ViewBag.notmatch = "Pensioner Values not match";
                    return(View());
                }
            }

            else
            {
                _log4net.Warn("Proper details are not given by the Admin!!");
                ViewBag.invalid = "Pensioner Values are Invalid";
                return(View());
            }
        }
        public Pension GetPensioner(PensionerInput pensionerInput)
        {
            _log4net.Info("PensionDetail post method is invoked for aadhaar" + pensionerInput.AadhaarNo);

            return(repo.GetPension(pensionerInput));
        }