예제 #1
0
        public async Task <IActionResult> Dashboard()
        {
            var viewModel = new HomeDashboardViewModel();

            var loggedUser = await userManager.GetUserAsync(User);

            var activeRoll = rollsService.GetActiveRoll <HomeDashboardRoll>();

            if (activeRoll != null)
            {
                viewModel.ActiveRoll = activeRoll;
            }

            if (loggedUser != null)
            {
                var isUserJoined = this.rollsService.IsUserJoined(loggedUser.Id, activeRoll?.Id);

                var user = new HomeDashboardUser
                {
                    AlreadyJoined   = isUserJoined,
                    IsLoggedIn      = loggedUser != null,
                    IsAdministrator = await userManager.IsInRoleAsync(loggedUser, Roles.Administrator),
                    Email           = loggedUser.Email
                };

                viewModel.User = user;
            }

            return(this.View(viewModel));
        }
        public async Task <IActionResult> Profile()
        {
            var loggedUser = await userManager.GetUserAsync(User);

            var activeRoll = rollsService.GetActiveRoll();

            var user = new UsersProfileUser
            {
                Id              = loggedUser.Id,
                PhoneNumber     = loggedUser.PhoneNumber,
                Email           = loggedUser.Email,
                IsAdministrator = await userManager.IsInRoleAsync(loggedUser, Roles.Administrator)
            };

            var lastContactMessages = this.usersService.GetLastContactMessages <UsersProfileContactMessage>();

            var viewModel = new UsersProfileViewModel
            {
                HasActiveRoll   = activeRoll != null,
                User            = user,
                ContactMessages = lastContactMessages
            };

            return(this.View(viewModel));
        }
예제 #3
0
        public async Task <IActionResult> StripePaymentSessionId()
        {
            var loggedUser = await userManager.GetUserAsync(User);

            var activeRoll = rollsService.GetActiveRoll();

            if (activeRoll == null)
            {
                return(BadRequest(ErrorMessages.NoActiveRoll));
            }

            var priceStripeFormat    = Convert.ToInt64(activeRoll.EntryPrice) * 100;
            var currencyStripeFormat = activeRoll.CurrencyIsoCode;

            var itemsToPurchase = new List <SessionLineItemOptions>
            {
                new SessionLineItemOptions
                {
                    PriceData = new SessionLineItemPriceDataOptions
                    {
                        Currency    = currencyStripeFormat,
                        ProductData = new SessionLineItemPriceDataProductDataOptions
                        {
                            Description = $"CashRoll Id: {activeRoll.Id}",
                            Name        = $"Entry fee - CashRolls {activeRoll.CreatedOn.ToShortDateString()} - {activeRoll.EntryPrice:0.00}{activeRoll.CurrencySymbol}",
                        },
                        UnitAmount = priceStripeFormat,
                    },
                    Quantity = 1,
                }
            };

            var rollUser = await rollsService.PendingJoinAsync(activeRoll.Id, loggedUser.Id);

            var options = new SessionCreateOptions
            {
                PaymentMethodTypes = new List <string>
                {
                    "card",
                },
                CustomerEmail = loggedUser.Email,
                LineItems     = itemsToPurchase,
                Mode          = "payment",
                SuccessUrl    = $"Your success payment url",
                CancelUrl     = "Your cancel payment url",
            };

            var service = new SessionService();
            var session = service.Create(options);

            return(Json(session.Id));
        }