Ejemplo n.º 1
0
        public async Task <ActionResult> MakePayment(MembershipFeeVM model)
        {
            var userId = User.Identity.GetUserId();


            var hasPayed = await db.MembershipFee.AsNoTracking().Where(x => x.ActiveMemberId.Equals(userId))
                           .FirstOrDefaultAsync();

            if (hasPayed != null)
            {
                return(RedirectToAction("RetryMembershipRegistration", new { orderId = hasPayed.OrderId }));
            }

            var member = await db.ActiveMember.AsNoTracking().Where(x => x.ActiveMemberId.Equals(userId))
                         .FirstOrDefaultAsync();

            var paylist     = new List <Paylist>();
            var paymentList = await db.MembershipFee.AsNoTracking().ToListAsync();

            foreach (var pay in paylist)
            {
                var myPay = new Paylist
                {
                    PayTypeName = pay.PayTypeName,
                    Amount      = pay.Amount,
                    Description = pay.Description
                };
                paylist.Add(myPay);
            }

            var confirmPayment = new SelectPaymentVm
            {
                ActiveMemberId = User.Identity.GetUserId(),
                FeeCategory    = model.FeeCategory,
                TotalAmount    = paymentList.Sum(s => s.PaidFee),
            };

            var paytype = from PaymentType p in Enum.GetValues(typeof(PaymentType))
                          select new { ID = p, Name = p.ToString() };

            ViewBag.PayType        = new SelectList(paytype, "Name", "Name");
            ViewBag.ActiveMemberId = new SelectList(db.ActiveMember, "ActiveMemberId", "FullName");
            return(RedirectToAction("Create", confirmPayment));
        }
Ejemplo n.º 2
0
        public EA_POM Edit_Enrolment()
        {
            Web_Driver.ngWebDriver.WaitForAngular();
            //Getting Records
            Edit_Record_Previous = Edit_Record.Text;
            Console.WriteLine(Edit_Record_Previous + "Previous Record");
            Edit_Id = Search_Record_Colums.Text;
            Console.WriteLine(Edit_Id + "Id");
            Edit_En_btn.Click();
            Web_Driver.ngWebDriver.WaitForAngular();
            //  Plan_Edit_Btn.Click();
            //Getting Text of previous Fields
            Plan_Edit_strng = Plan_Edit_Text.Text;
            Console.WriteLine(Plan_Edit_strng);
            //Getting First Name
            Name_strng = Name.GetAttribute("value");
            Console.WriteLine(Name_strng);
            Name.Clear();
            Name.SendKeys("Ali");
            //Getting New Values
            Name_strng1 = Name.GetAttribute("value");
            Console.WriteLine(Name_strng1);
            //Getting Last Name
            LName_strng = LName.GetAttribute("value");
            Console.WriteLine(LName_strng);
            LName.Clear();
            LName.SendKeys("Asad");
            //Getting new Values
            LName_strng1 = LName.GetAttribute("value");
            Console.WriteLine(LName_strng1);
            //Getting MidName
            MName_strng = MName.GetAttribute("value");
            Console.WriteLine(MName_strng);
            MName.Clear();
            MName.SendKeys("Asa");
            //Getting new Values
            MName_strng1 = MName.GetAttribute("value");
            Console.WriteLine(MName_strng1);
            //Getting Date of Birth
            Dob_strng = Dob.GetAttribute("value");
            Console.WriteLine(Dob_strng);
            Dob.Clear();
            Dob.SendKeys("10/11/2022");
            //Getting new Values
            Dob_strng1 = Dob.GetAttribute("value");
            Console.WriteLine(Dob_strng1);
            //Radio btn
            male_radio = Radio_M_F.ElementAt(0).GetAttribute("value");
            Console.WriteLine(male_radio);
            Radio_M_F.ElementAt(1).Click();
            Fee_Male_radio = Radio_M_F.ElementAt(1).GetAttribute("value");
            Console.WriteLine(Fee_Male_radio);
            //Phone number
            Hphone_strng = Hphone.GetAttribute("value");
            Console.WriteLine(Hphone_strng);
            Hphone.Clear();
            Hphone.SendKeys("9878564598");
            Hpnone1_strng = Hphone.GetAttribute("value");
            Console.WriteLine(Hpnone1_strng);
            //Permanent address
            P_Address_strng = P_Address.GetAttribute("value");
            Console.WriteLine(P_Address_strng);
            //New Values
            P_Address.Clear();
            P_Address.SendKeys("878# Street no5");
            P_Address_strng1 = P_Address.GetAttribute("value");
            Console.WriteLine(P_Address_strng1);
            //Permanent City
            P_City_Strng = P_City.GetAttribute("value");
            Console.WriteLine(P_City_Strng);
            //New Values
            P_City.Clear();
            P_City.SendKeys("Karachi");
            P_City_Strng1 = P_City.GetAttribute("value");
            Console.WriteLine(P_City_Strng1);
            //Permanent County
            P_County_Strng = P_County.GetAttribute("value");
            Console.WriteLine(P_County_Strng);
            //New Values
            P_County.Clear();
            P_County.SendKeys("County");
            P_County_Strng1 = P_County.GetAttribute("value");
            Console.WriteLine(P_County_Strng1);
            //Permanent State
            P_State_Strng = P_State.GetAttribute("value");
            Console.WriteLine(P_State_Strng);
            //New Values
            P_State.Clear();
            P_State.SendKeys("USA");
            P_State_Strng1 = P_State.GetAttribute("value");
            Console.WriteLine(P_State_Strng1);
            //ZipCode
            P_Zip_Strng = P_Zip.GetAttribute("value");
            Console.WriteLine(P_Zip_Strng);
            //New Values
            P_Zip.Clear();
            P_Zip.SendKeys("453454");
            P_Zip_Strng1 = P_Zip.GetAttribute("value");
            Console.WriteLine(P_Zip_Strng1);
            //MD_Number
            Md_No_strng = MD_Number.GetAttribute("value");
            Console.WriteLine(Md_No_strng);
            //New Values
            MD_Number.Clear();
            MD_Number.SendKeys("MD_9001");
            Md_No_strng1 = P_Zip.GetAttribute("value");
            Console.WriteLine(Md_No_strng1);
            //Email Address
            Email_Strng = Email_Adress.GetAttribute("value");
            Console.WriteLine(Email_Strng);
            //New Values
            Email_Adress.Clear();
            Email_Adress.SendKeys("*****@*****.**");
            Email_Strng = Email_Adress.GetAttribute("value");
            Console.WriteLine(Email_Strng1);
            //Pay List testing unchecked CheckBox


            Paylist_bool1 = Paylist.ElementAt(0).Selected;
            Paylist_bool2 = Paylist.ElementAt(1).Selected;
            Paylist_bool3 = Paylist.ElementAt(2).Selected;
            if (Paylist_bool1 == true || Paylist_bool2 == true || Paylist_bool3 == true)
            {
                if (Paylist_bool1 == true)
                {
                    Paylist.ElementAt(0).Click();
                }
                if (Paylist_bool2 == true)
                {
                    Paylist.ElementAt(1).Click();
                }
                if (Paylist_bool3 == true)
                {
                    Paylist.ElementAt(2).Click();
                }
                Asserts.Pay_list1(true);
            }

            if (Paylist_bool1 == false && Paylist_bool2 == false & Paylist_bool3 == false)
            {
                Asserts.Pay_list1(true);
            }
            //cliking on single paylist
            Paylist.ElementAt(0).Click();
            Paylist_bool1 = Paylist.ElementAt(0).Selected;
            Paylist_bool2 = Paylist.ElementAt(1).Selected;
            Paylist_bool3 = Paylist.ElementAt(2).Selected;
            if (Paylist_bool1 == true && Paylist_bool2 == false & Paylist_bool3 == false)
            {
                Asserts.Pay_list(Paylist_bool1);
            }
            else
            {
                Asserts.Pay_list(false);
            }
            //Asertion for Records inrequired fields are changed or not
            if (Name_strng != Name_strng1 && LName_strng != LName_strng1 && MName_strng != MName_strng1 && Dob_strng != Dob_strng1 && P_Address_strng != P_Address_strng1 && P_City_Strng != P_City_Strng1 && P_State_Strng != P_State_Strng1 && male_radio != Fee_Male_radio && Md_No_strng != Md_No_strng1 && Email_Strng != Email_Strng1)
            {
                Asserts.En_Search_Create_pages_Fields_Edit(true);
            }
            else
            {
                Asserts.En_Search_Create_pages_Fields_Edit(false);
            }
            //Save Draft
            Console.WriteLine("Colorsss");

            Save_Draft_Btn_Color = SaveDraft.ElementAt(0).GetCssValue("background-color");
            Console.WriteLine(Save_Draft_Btn_Color + "Color");
            Enroment_create_page_Url = Web_Driver.driver.Url;
            Console.WriteLine(Enroment_create_page_Url);
            SaveDraft.ElementAt(0).Click();


            Save_Draft_Btn_Color1 = SaveDraft.ElementAt(0).GetCssValue("background-color");
            Console.WriteLine(Save_Draft_Btn_Color1 + "Color-");
            //Draft Button cliking verifying

            Asserts.Save_Draft(Save_Draft_Btn_Color, Save_Draft_Btn_Color1);
            Web_Driver.ngWebDriver.WaitForAngular();
            Web_Driver.driver.Navigate().Refresh();


            Enroment_Search_page_Url = Web_Driver.driver.Url;

            Console.WriteLine(Enroment_Search_page_Url);
            Asserts.En_Search_Create_pages_Url(Enroment_create_page_Url, Enroment_Search_page_Url);
            //Getting New Record
            Web_Driver.ngWebDriver.WaitForAngular();


            //Search for Updated Enrolment
            Thread.Sleep(3000);
            Hash_Drop.ElementAt(0).Click();
            //Search by Id
            Search_Records.ElementAt(0).Click();
            Thread.Sleep(3000);

            Search_Records.ElementAt(0).SendKeys(Edit_Id);

            Thread.Sleep(3000);

            Search_btn.ElementAt(0).Click();
            Thread.Sleep(3000);
            //Getting text of updated record
            Edit_Record_Updated = Edit_Record.Text;
            Console.WriteLine(Edit_Record_Updated + " Updated Record");
            //Assertion For Edit Record check
            Asserts.Edit_Record_Update(Edit_Record_Previous, Edit_Record_Updated);
            return(new EA_POM());
        }
Ejemplo n.º 3
0
        //GET
        public async Task <ActionResult> Create(MembershipFeeVM model)
        {
            if (model.FeeCategory.Equals(PaymentType.MembershipRegistration.ToString()) && _IsPayedMembershipRegistration.Equals(true))
            {
                return(RedirectToAction("Index"));
            }
            if (model.FeeCategory.Equals(PaymentType.MonthlyDues.ToString()) && _IsPayedMonthlyDues.Equals(true))
            {
                return(RedirectToAction("Index"));
            }
            var memberId     = User.Identity.GetUserId();
            var hasPayedList = await db.MembershipFee.AsNoTracking().Where(x => x.ActiveMemberId == memberId &&
                                                                           x.FeeCategory == model.FeeCategory)
                               .ToListAsync();


            var member = await db.ActiveMember.AsNoTracking()
                         .Where(x => x.ActiveMemberId == memberId).FirstOrDefaultAsync();

            var paymentList = await db.MemberFeeType.AsNoTracking()
                              .Where(x => x.FeeCategory == model.FeeCategory)
                              .ToListAsync();

            var fullName = $"{member.Fullname}";
            var paylist  = new List <Paylist>();

            foreach (var fee in paymentList)
            {
                var myFee = new Paylist
                {
                    PayTypeName = fee.FeeName,
                    Amount      = fee.Amount,
                    Description = fee.Description
                };
                paylist.Add(myFee);
            }
            System.Threading.Thread.Sleep(1);
            long milliseconds = DateTime.Now.Ticks;
            var  url          = Url.Action("ConfrimPayment", "MembershipFee", new { }, protocol: Request.Url.Scheme);

            if (hasPayedList != null)
            {
                foreach (var hasPayed in hasPayedList)
                {
                    if (hasPayed.Status.Equals(false))
                    {
                        string serviceTypeId = string.Empty;
                        if (hasPayed.FeeCategory.Equals(PaymentType.MembershipRegistration.ToString()))
                        {
                            serviceTypeId = RemitaConfigParam.MEMBERSHIPREGISTRATION;
                        }
                        else if (hasPayed.FeeCategory.Equals(PaymentType.MonthlyDues.ToString()))
                        {
                            serviceTypeId = RemitaConfigParam.MONTHLYDUES;
                        }
                        //var amount = paymentList.Sum(s => s.Amount).ToString();

                        var    hashed   = _query.HashRemitedValidate(hasPayed.OrderId, RemitaConfigParam.APIKEY, RemitaConfigParam.MERCHANTID);
                        string checkurl = RemitaConfigParam.CHECKSTATUSURL + "/" + RemitaConfigParam.MERCHANTID + "/" + hasPayed.OrderId + "/" + hashed + "/" + "orderstatus.reg";
                        string jsondata = new WebClient().DownloadString(checkurl);
                        var    result   = JsonConvert.DeserializeObject <RemitaResponse>(jsondata);
                        if (string.IsNullOrEmpty(result.Rrr))
                        {
                            var entry = db.Entry(hasPayed);
                            if (entry.State == EntityState.Detached)
                            {
                                db.MembershipFee.Attach(hasPayed);
                            }
                            db.MembershipFee.Remove(hasPayed);
                            await db.SaveChangesAsync();
                        }
                        else
                        {
                            return(RedirectToAction("ConfrimPayment", new { orderID = hasPayed.OrderId }));
                        }
                    }
                }
            }

            var confirmPaymentVm = new ConfirmPaymentVM();

            confirmPaymentVm.Paylist        = paylist;
            confirmPaymentVm.MemberName     = fullName;
            confirmPaymentVm.ActiveMemberId = memberId;
            confirmPaymentVm.FeeCategory    = model.FeeCategory;
            confirmPaymentVm.TotalAmount    = paymentList.Sum(s => s.Amount);

            confirmPaymentVm.payerName  = fullName;
            confirmPaymentVm.payerPhone = member.PhoneNumber;
            if (model.FeeCategory.Equals(PaymentType.MembershipRegistration.ToString()))
            {
                confirmPaymentVm.amt         = paymentList.Sum(s => s.Amount).ToString();
                confirmPaymentVm.TotalAmount = paymentList.Sum(s => s.Amount);
            }
            if (model.FeeCategory.Equals(PaymentType.MonthlyDues.ToString()))
            {
                confirmPaymentVm.amt         = paymentList.Sum(s => s.Amount).ToString();
                confirmPaymentVm.TotalAmount = paymentList.Sum(s => s.Amount);
            }
            confirmPaymentVm.merchantId    = RemitaConfigParam.MERCHANTID;
            confirmPaymentVm.orderId       = $"NACCPlateau{milliseconds}";
            confirmPaymentVm.responseurl   = url;
            confirmPaymentVm.serviceTypeId = RemitaConfigParam.MEMBERSHIPREGISTRATION;
            confirmPaymentVm.paymentType   = model.MemberFeeType;

            return(View(confirmPaymentVm));
        }