Esempio n. 1
0
        public PensionDetail ProcessPension(ProcessPensionInput processPensionInput)
        {
            _log4net.Info("Pensioner details invoked from Client Input");
            ProcessPensionInput client = new ProcessPensionInput();

            client.Name         = processPensionInput.Name;
            client.AadharNumber = processPensionInput.AadharNumber;
            client.Pan          = processPensionInput.Pan;
            client.DateOfBirth  = processPensionInput.DateOfBirth;
            client.PensionType  = processPensionInput.PensionType;

            PensionDetailCall   pension       = new PensionDetailCall(configuration);
            ProcessPensionInput pensionDetail = pension.GetClientInfo(client.AadharNumber);

            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(mvc);
            }



            double pensionAmount;

            ValueforCalCulation pensionerInfo = pension.GetCalculationValues(client.AadharNumber);

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

            int statusCode;

            PensionDetail mvcClientOutput = new PensionDetail();

            if (client.Pan.Equals(pensionDetail.Pan) && client.Name.Equals(pensionDetail.Name) && client.PensionType.Equals(pensionDetail.PensionType) && client.DateOfBirth.Equals(pensionDetail.DateOfBirth))
            {
                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);
            }


            string uriConn2 = configuration.GetValue <string>("MyUriLink:PensionDisbursementLink");
            HttpResponseMessage response = new HttpResponseMessage();

            using (var client1 = new HttpClient())
            {
                client1.BaseAddress = new Uri(uriConn2);
                StringContent content = new StringContent(JsonConvert.SerializeObject(mvcClientOutput), Encoding.UTF8, "application/json");
                client1.DefaultRequestHeaders.Clear();
                client1.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                try
                {
                    response = client1.PostAsync("api/PensionDisbursement", content).Result;
                }
                catch (Exception e)
                {
                    _log4net.Error("Exception Occured" + e);
                    response = null;
                }
            }
            if (response != null)
            {
                string status = response.Content.ReadAsStringAsync().Result;
                //statusCode = Int32.Parse(status);
                Result result = JsonConvert.DeserializeObject <Result>(status);
                statusCode             = result.result;
                mvcClientOutput.Status = statusCode;

                return(mvcClientOutput);
            }
            return(mvcClientOutput);
        }
Esempio n. 2
0
        public MVCClientOutput GetClient(ClientInput _client)
        {
            _log4net.Info("Pensioner details invoked from Client Input");

            ClientInput client = new ClientInput();

            client.name         = _client.name;
            client.aadharNumber = _client.aadharNumber;
            client.pan          = _client.pan;
            client.dateOfBirth  = _client.dateOfBirth;
            client.pensionType  = _client.pensionType;

            PensionDetailCall pension       = new PensionDetailCall();
            ClientInput       pensionDetail = pension.GetClientInfo(client.aadharNumber);

            if (pensionDetail == null)
            {
                MVCClientOutput mvc = new MVCClientOutput();
                mvc.name          = "";
                mvc.pan           = "";
                mvc.pensionAmount = 0;
                mvc.dateOfBirth   = new DateTime(2000, 01, 01);
                mvc.message       = new HttpResponseMessage(HttpStatusCode.NoContent);
                mvc.bankType      = 1;
                mvc.aadharNumber  = "***";
                mvc.status        = 1;

                return(mvc);
            }


            int bankType = pension.GetCalculationValues(client.aadharNumber).bankType;


            int bankServiceCharge;

            if (bankType == 1)
            {
                bankServiceCharge = 500;
            }
            else
            {
                bankServiceCharge = 550;
            }



            int    pensionType = pension.GetCalculationValues(client.aadharNumber).pensionType;
            double pensionAmount;


            double salary     = pension.GetCalculationValues(client.aadharNumber).salaryEarned;
            double allowances = pension.GetCalculationValues(client.aadharNumber).allowances;

            if (pensionType == 1)
            {
                pensionAmount = (0.8 * salary) + allowances;
            }
            else
            {
                pensionAmount = (0.5 * salary) + allowances;
            }



            if (pension.GetCalculationValues(client.aadharNumber).bankType == 1)
            {
                pensionAmount = pensionAmount + 500;
            }
            else
            {
                pensionAmount = pensionAmount + 550;
            }

            int statusCode;

            MVCClientOutput mvcClientOutput = new MVCClientOutput();

            if (client.pan.Equals(pensionDetail.pan) && client.name.Equals(pensionDetail.name) && client.pensionType.Equals(pensionDetail.pensionType) && client.dateOfBirth.Equals(pensionDetail.dateOfBirth))
            {
                mvcClientOutput.name          = pensionDetail.name;
                mvcClientOutput.pan           = pensionDetail.pan;
                mvcClientOutput.pensionAmount = pensionAmount;
                mvcClientOutput.dateOfBirth   = pensionDetail.dateOfBirth.Date;
                mvcClientOutput.pensionType   = pension.GetCalculationValues(client.aadharNumber).pensionType;
                mvcClientOutput.message       = new HttpResponseMessage(HttpStatusCode.OK);
                mvcClientOutput.bankType      = bankType;
                mvcClientOutput.aadharNumber  = pensionDetail.aadharNumber;
                mvcClientOutput.status        = 0;
            }
            else
            {
                mvcClientOutput.name          = "";
                mvcClientOutput.pan           = "";
                mvcClientOutput.pensionAmount = 0;
                mvcClientOutput.dateOfBirth   = new DateTime(2000, 01, 01);
                mvcClientOutput.pensionType   = pension.GetCalculationValues(client.aadharNumber).pensionType;
                mvcClientOutput.message       = new HttpResponseMessage(HttpStatusCode.NotFound);
                mvcClientOutput.bankType      = 1;
                mvcClientOutput.aadharNumber  = "****";
                mvcClientOutput.status        = 0;
            }



            HttpResponseMessage response = new HttpResponseMessage();

            using (var client1 = new HttpClient())
            {
                client1.BaseAddress = new Uri("https://localhost:44312/");
                StringContent content = new StringContent(JsonConvert.SerializeObject(mvcClientOutput), Encoding.UTF8, "application/json");
                client1.DefaultRequestHeaders.Clear();
                client1.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                try
                {
                    response = client1.PostAsync("api/PensionDisbursement", content).Result;
                }
                catch (Exception e)
                { response = null; }
            }
            if (response != null)
            {
                string status = response.Content.ReadAsStringAsync().Result;
                statusCode = Int32.Parse(status);
            }
            else
            {
                statusCode = 0;
            }

            mvcClientOutput.status = statusCode;


            return(mvcClientOutput);
        }