コード例 #1
0
        public IEnumerable <EventType> BookableEvents(bool futureEventsOnly, bool withSlotsOnly, int limitBooking, bool isAdmin = false)
        {
            try
            {
                var  member       = _memberProvider.GetLoggedInMember();
                var  memberType   = member.GetValue <MembershipTypeEnum>(MemberProperty.membershipType);
                var  btfNumber    = member.GetValue <string>(MemberProperty.BTFNumber);
                bool hasBTFNumber = !string.IsNullOrEmpty(btfNumber);
                var  isGuest      = memberType == MembershipTypeEnum.Guest;

                List <EventType> eventTypes = _dataTypeProvider.GetEventTypes();
                var eventSlots = _eventSlotRepository.GetAll(futureEventsOnly, eventTypes, hasBTFNumber, limitBooking);
                if (!isAdmin)
                {
                    eventSlots = eventSlots.Where(es => es.IsGuestEvent == isGuest);
                }

                foreach (var eventType in eventTypes)
                {
                    eventType.EventSlots = eventSlots.Where(es => es.EventTypeId == eventType.Id).ToList();
                }

                return(withSlotsOnly ?  eventTypes.Where(e => e.EventSlots.Any()) : eventTypes);
            }
            catch (Exception ex)
            {
                Logger.Error(typeof(EventController), string.Format("Exception calling GetEventTypes: {0}", ex.ToString()), ex);
                return(new List <EventType>());
            }
        }
コード例 #2
0
        public ActionResult Index()
        {
            var model = new PaymentModel();

            var    member = _memberProvider.GetLoggedInMember();
            string state  = Request.QueryString["state"];
            bool   canProcessPaymentCompletion = _sessionProvider.CanProcessPaymentCompletion;

            if (member == null || !canProcessPaymentCompletion || string.IsNullOrEmpty(state))
            {
                model.HasPaymentDetails = false;
                return(View(model));
            }

            var    paymentState         = (PaymentStates)Enum.Parse(typeof(PaymentStates), state);
            string mandateId            = member.GetValue <string>(MemberProperty.directDebitMandateId);
            bool   requiresFlowRedirect = string.IsNullOrWhiteSpace(_sessionProvider.GoCardlessRedirectFlowId) == false;

            if (requiresFlowRedirect)
            {
                mandateId = _goCardlessProvider.CompleteRedirectRequest(_sessionProvider.GoCardlessRedirectFlowId, _sessionProvider.SessionId);
                member.SetValue(MemberProperty.directDebitMandateId, mandateId);
                _memberService.Save(member);
                _sessionProvider.GoCardlessRedirectFlowId = null;
            }
            else if (string.IsNullOrEmpty(mandateId))
            {
                return(RedirectToMandatePage(paymentState));
            }

            MapPaymentStateToModel(model, member, paymentState);

            return(View(model));
        }
コード例 #3
0
        public ActionResult MemberImage()
        {
            var member = _memberProvider.GetLoggedInMember();
            var model  = new MemberImageModel();

            if (member != null)
            {
                model.ProfileImageId = member.GetValue <string>(MemberProperty.ProfileImage);
            }

            return(PartialView("Member/EditMemberImage", model));
        }
コード例 #4
0
        public ActionResult RenewOptions()
        {
            var member = _memberProvider.GetLoggedInMember();

            if (member == null)
            {
                return(CurrentUmbracoPage());
            }

            var membershipType = member.GetValue <MembershipTypeEnum>(MemberProperty.membershipType);

            bool isGuest = membershipType == MembershipTypeEnum.Guest;
            var  model   = new RegistrationDetails(_membershipCostCalculator);

            model.MemberOptions.IsRenewing  = !isGuest;
            model.MemberOptions.IsUpgrading = isGuest;

            return(PartialView("Registration/MemberOptions", model.MemberOptions));
        }
コード例 #5
0
        public ActionResult Index()
        {
            var    member = _memberProvider.GetLoggedInMember();
            string state  = Request.QueryString["state"];
            bool   canProcessPaymentCompletion = _sessionProvider.CanProcessPaymentCompletion;

            if (member == null || !canProcessPaymentCompletion || string.IsNullOrEmpty(state))
            {
                return(View(false));
            }

            var    fullName   = member.Name;
            string familyName = fullName;
            string givenName  = string.Empty;

            if (fullName.Contains(" "))
            {
                var names = fullName.Split(' ');
                familyName = names.Last();
                givenName  = string.Join(" ", names.Take(names.Length - 1));
            }

            var customerDto = new CustomerDto()
            {
                GivenName    = givenName,
                FamilyName   = familyName,
                AddressLine1 = member.GetValue <string>(MemberProperty.Address1),
                City         = member.GetValue <string>(MemberProperty.City),
                PostalCode   = member.GetValue <string>(MemberProperty.Postcode),
                Email        = member.Email
            };

            string rootUrl           = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port == 80 ? string.Empty : ":" + Request.Url.Port);
            string mandateSuccessUrl = string.Format("{0}/payment?state={1}", rootUrl, state);

            var redirectResponse = _goCardlessProvider.CreateRedirectRequest(_logger, customerDto, "Mid Sussex Tri Club DD Mandate Setup", _sessionProvider.SessionId,
                                                                             mandateSuccessUrl);

            if (redirectResponse.HasError)
            {
                ModelState.AddModelError("", redirectResponse.Error);
                return(View(true));
            }

            _sessionProvider.GoCardlessRedirectFlowId = redirectResponse.Id;
            return(Redirect(redirectResponse.RedirectUrl));
        }
コード例 #6
0
        public ActionResult Unlink()
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            IMember member = _memberProvider.GetLoggedInMember();

            if (member == null)
            {
                return(CurrentUmbracoPage());
            }

            member.SetValue(MemberProperty.directDebitMandateId, "");
            Services.MemberService.Save(member);

            TempData["IsUnlinked"] = true;
            return(CurrentUmbracoPage());
        }