Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            var auth0UserId = User.FindFirstValue("sub");

            var customerResult = await _mediator.Send(new GetCustomerForAuth0UserRequest(auth0UserId));

            if (customerResult.HasError)
            {
                ViewData["ErrorMessage"] = customerResult.Message;
            }

            Customer = customerResult.Value;

            if (Customer.CurrentMembershipSubscription != null || SubmitAction.Equals("cancel", StringComparison.OrdinalIgnoreCase))
            {
                return(Redirect("/membership"));
            }

            var plansResult = await _mediator.Send(new ListMembershipPlansRequest());

            MembershipPlans = plansResult.Value;

            var selectedMembership = MembershipPlans.First(mp => mp.Id == MembershipPlanId);

            Customer.MembershipSubscriptions.Add(new MembershipSubscription
            {
                Plan      = selectedMembership,
                Quantity  = selectedMembership.HasQuantityBasedRates ? Quantity : 1,
                StartDate = DateTime.Now
            });

            await _mediator.Send(new SaveCustomerRequest(Customer));

            return(Redirect("/membership/payment-methods/add-initial"));
        }
        public ActionResult ViewEditPlanByID(int id, string editDetail)
        {
            if (Request.Cookies["PageSetting"] != null)
            {
                var             data = context.tbl_MembershipPlans.SingleOrDefault(s => s.ID == id);
                MembershipPlans plan = new MembershipPlans();
                plan.ID                    = data.ID;
                plan.PlanName              = data.PlanName;
                plan.PlanDetails           = data.PlanDetails;
                plan.NoOfStays             = data.NoOfStays;
                plan.PlanAmount            = data.PlanAmount;
                plan.MembershipPlanForYear = data.MembershipPlanForYear;
                if (Request.Cookies["PageSetting"]["MembershipPlanPermission"] == "All")
                {
                    if (editDetail == "Details")
                    {
                        return(View("~/Views/MembershipPlans/ViewEditPlanByID.cshtml", plan));
                    }
                    else
                    {
                        return(View("~/Views/MembershipPlans/EditPlanByID.cshtml", plan));
                    }
                }
                else if (Request.Cookies["PageSetting"]["MembershipPlanPermission"] == "View")
                {
                    if (editDetail == "Details")
                    {
                        return(View("~/Views/MembershipPlans/ViewEditPlanByID.cshtml", plan));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Login"));
                    }
                }

                else
                {
                    return(RedirectToAction("Index", "Login"));
                }
            }
            else
            {
                var             data = context.tbl_MembershipPlans.SingleOrDefault(s => s.ID == id);
                MembershipPlans plan = new MembershipPlans();
                plan.ID                    = data.ID;
                plan.PlanName              = data.PlanName;
                plan.PlanDetails           = data.PlanDetails;
                plan.NoOfStays             = data.NoOfStays;
                plan.PlanAmount            = data.PlanAmount;
                plan.MembershipPlanForYear = data.MembershipPlanForYear;
                if (editDetail == "Details")
                {
                    return(View("~/Views/MembershipPlans/ViewEditPlanByID.cshtml", plan));
                }
                else
                {
                    return(View("~/Views/MembershipPlans/EditPlanByID.cshtml", plan));
                }
            }
        }
Exemplo n.º 3
0
 public bool ProducstWereLoadedVerified(CommerceServiceEvents.ProductsLoaded pl)
 {
     if (pl.Success)
     {
         if (Service.Get<MixLoginCreateService>().RegistrationAgeBand != null)
         {
             membershipPlans = new MembershipPlans(Service.Get<MixLoginCreateService>().RegistrationAgeBand.CountryCode);
         }
         Service.Get<MixLoginCreateService>().OnRegistrationConfigUpdated += onRegistrationConfigUpdated;
     }
     productsLoaded = pl.Success;
     productsLoading = false;
     return false;
 }
        public JsonResult EditMembershipPlan(MembershipPlans newPlan)
        {
            var data = context.tbl_MembershipPlans.SingleOrDefault(s => s.ID == newPlan.ID);

            if (data != null)
            {
                data.ID                    = newPlan.ID;
                data.PlanName              = newPlan.PlanName;
                data.PlanDetails           = newPlan.PlanDetails;
                data.NoOfStays             = newPlan.NoOfStays;
                data.PlanAmount            = newPlan.PlanAmount;
                data.MembershipPlanForYear = newPlan.MembershipPlanForYear;
                context.Entry(data).State  = EntityState.Modified;
                context.SaveChanges();
            }
            return(Json("Updated."));
        }
        public ActionResult NewDelMembershipDetailByID(int id, string editDetail)
        {
            var             data = context.tbl_MembershipPlans.SingleOrDefault(s => s.ID == id);
            MembershipPlans plan = new MembershipPlans();

            plan.ID          = data.ID;
            plan.PlanName    = data.PlanName;
            plan.PlanDetails = data.PlanDetails;
            plan.NoOfStays   = data.NoOfStays;
            if (editDetail == "New")
            {
                ViewBag.NewDelPlan = true;
            }
            else
            {
                ViewBag.NewDelPlan = false;
            }
            return(View(plan));
        }
        public JsonResult AddNewMembershipPlan(MembershipPlans newPlan)
        {
            int currentUserTypeLoggedin  = Convert.ToInt32(Request.Cookies["UserType"].Value);
            tbl_MembershipPlans tblPlans = new tbl_MembershipPlans();

            tblPlans.PlanName              = newPlan.PlanName;
            tblPlans.PlanDetails           = newPlan.PlanDetails;
            tblPlans.NoOfStays             = newPlan.NoOfStays;
            tblPlans.AddedBy               = Request.Cookies["AddedBy"].Value;
            tblPlans.PlanAmount            = newPlan.PlanAmount;
            tblPlans.MembershipPlanForYear = newPlan.MembershipPlanForYear;
            if (currentUserTypeLoggedin != 1)
            {
                tblPlans.MemShipApprvFrmSuperAdm = false;
            }
            else
            {
                tblPlans.MemShipApprvFrmSuperAdm = true;
            }
            tblPlans.IsDeleted = false;
            context.tbl_MembershipPlans.Add(tblPlans);
            context.SaveChanges();
            return(Json(currentUserTypeLoggedin));
        }
Exemplo n.º 7
0
 private void onRegistrationConfigUpdated(IRegistrationConfiguration registrationConfig)
 {
     membershipPlans = new MembershipPlans(Service.Get<MixLoginCreateService>().RegistrationAgeBand.CountryCode);
 }