Beispiel #1
0
        public async Task <CountryResponseViewModel> GetAll()
        {
            var SiteId = _siteIdProvider.GetSiteId();

            if (SiteId == Site.DevelopmentSite)
            {
                SiteId = Site.feelaplaceSite;
            }

            if (!_memoryCache.TryGetValue($"{SiteId}_countries", out List <FIL.Contracts.Models.Country> Countries))
            {
                var queryResult = await _querySender.Send(new CountryQuery());

                if (queryResult.Countries != null)
                {
                    _memoryCache.Set($"{SiteId}_countries", queryResult.Countries, DateTime.Now.AddMinutes(120));
                    return(new CountryResponseViewModel {
                        Countries = queryResult.Countries
                    });
                }
                else
                {
                    return(null);
                }
            }
            return(new CountryResponseViewModel
            {
                Countries = Countries
            });
        }
Beispiel #2
0
        public async Task StripeConnectTransfersControllerApi()
        {
            _logger.Log(LogCategory.Debug, "Starting job");
            try
            {
                //start job here.
                var currenyList = await _querySender.Send(new CurrencyTypesQuery { });

                var queryResults = await _querySender.Send(new TransactionStripeConnectTransfersQuery { TransferDate = DateTime.Today });

                foreach (TransactionStripeConnectTransfer transactionStripeConnectTransfer in queryResults.transactionStripeConnectTransfers)
                {
                    var currency = currenyList.currencyTypes.Where(x => x.Id == transactionStripeConnectTransfer.CurrencyId).First().Code;
                    if (currency.ToUpper() == "AUD" || currency.ToUpper() == "USD")
                    {
                        _logger.Log(LogCategory.Debug, "starting transfer for " + transactionStripeConnectTransfer.Id.ToString());
                        // Create a PaymentIntent:
                        Transfer transfer = new Transfer();
                        try
                        {
                            var transferService = new TransferService();
                            var transferOption  = new TransferCreateOptions
                            {
                                Amount            = (long)(transactionStripeConnectTransfer.Amount),
                                Currency          = currenyList.currencyTypes.Where(x => x.Id == transactionStripeConnectTransfer.CurrencyId).First().Code,
                                Destination       = transactionStripeConnectTransfer.StripeConnectedAccount,
                                SourceTransaction = transactionStripeConnectTransfer.SourceTransactionChargeId
                            };

                            var apiKey = _settings.GetConfigSetting(FIL.Configuration.Utilities.SettingKeys.PaymentGateway.Stripe.SecretKey).Value;
                            if (currency.ToUpper() == "AUD")
                            {
                                apiKey = _settings.GetConfigSetting(FIL.Configuration.Utilities.SettingKeys.PaymentGateway.Stripe.FeelAustralia.SecretKey).Value;
                            }
                            transfer = transferService.Create(transferOption, new RequestOptions
                            {
                                ApiKey = apiKey
                            });
                            _logger.Log(LogCategory.Debug, "transfer completed for " + transactionStripeConnectTransfer.Id.ToString());
                            await _commandSender.Send <TransactionStripeConnectTransfersCommand>(new TransactionStripeConnectTransfersCommand { Id = transactionStripeConnectTransfer.Id, TransferApiResponse = transfer.ToString(), TransferDateActual = DateTime.Today });
                        }
                        catch (Exception ex)
                        {
                            _logger.Log(LogCategory.Error, ex);
                            await _commandSender.Send <TransactionStripeConnectTransfersCommand>(new TransactionStripeConnectTransfersCommand { Id = transactionStripeConnectTransfer.Id, TransferApiResponse = ex.ToString(), TransferDateActual = DateTime.Today });
                        }
                    }
                    else
                    {
                        await _commandSender.Send <TransactionStripeConnectTransfersCommand>(new TransactionStripeConnectTransfersCommand { Id = transactionStripeConnectTransfer.Id, TransferApiResponse = "cross region account.", TransferDateActual = DateTime.Today });
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log(LogCategory.Error, ex);
            }
            _logger.Log(LogCategory.Debug, "Finishing Job.");
        }
Beispiel #3
0
        public async Task <CitySearchResponseViewModel> GetByName(string name)
        {
            var queryResult = await _querySender.Send(new CitySearchQuery { Name = name });

            return(new CitySearchResponseViewModel {
                IsExisting = queryResult.IsExisting
            });
        }
Beispiel #4
0
        public async Task <CountryResponseViewModel> GetAll()
        {
            var queryResult = await _querySender.Send(new CountryQuery());

            return(queryResult.Countries != null ? new CountryResponseViewModel {
                Countries = queryResult.Countries
            } : null);
        }
Beispiel #5
0
        public async Task <ZipcodeSearchResponseViewModel> GetByZipcode(string zipcode)
        {
            var queryResult = await _querySender.Send(new ZipcodeSearchQuery { Zipcode = zipcode });

            return(new ZipcodeSearchResponseViewModel {
                IsExisting = queryResult.IsExisting
            });
        }
Beispiel #6
0
        public async Task <SearchResponseViewModel> GetByName(string searchString, SiteLevel?siteLevel = null)
        {
            if (searchString.IsNullOrBlank() || searchString.Trim().Length < 2)
            {
                return(new SearchResponseViewModel());
            }

            // TODO: XXX: NSP: aggregate both searches into parallel queries
            var siteId = _siteIdProvider.GetSiteId();

            siteLevel = siteLevel ?? SiteLevel.Global;
            // TODO: XXX: NSP: Search / Site level caching in Redis (not local) - can also derive all locations from IA
            var queryResult = await _querySender.Send(new FeelSearchQuery
            {
                Name      = searchString,
                SiteId    = siteId,
                SiteLevel = siteLevel.Value
            });

            IList <EventSearchResult> searchResults = new List <EventSearchResult>();

            try
            {
                //searchResults = await _searchProvider.Search(searchString, siteId, siteLevel.Value, false);
                if (!searchResults.Any())
                {
                    _logger.Log(LogCategory.Warn, "No IA results returned", new Dictionary <string, object>
                    {
                        ["SearchString"] = searchString
                    });
                    //var categoryEventQueryResult = await _querySender.Send(new CategoryEventSearchQuery
                    //{
                    //    Name = searchString,
                    //    SiteId = siteId
                    //});

                    //searchResults = categoryEventQueryResult
                    //       .CategoryEvents?
                    //       .Select(_eventSearchResultBuilder.Build)
                    //       .ToList() ?? new List<EventSearchResult>();
                    searchResults = new List <EventSearchResult>();
                }
            }
            catch (Exception e)
            {
                _logger.Log(LogCategory.Error, e);
            }
            return(new SearchResponseViewModel
            {
                CategoryEvents = searchResults.ToList(),
                Cities = queryResult.Cities,
                States = queryResult.States,
                Countries = queryResult.Countries,
            });
        }
Beispiel #7
0
        public async Task <InviteResponseViewModel> GetAll()
        {
            var queryResult = await _querySender.Send(new SearchUserWebsiteInviteQuery()
            {
                IsUsed = false
            });

            return(queryResult.UsersWebsiteInvite != null ? new InviteResponseViewModel {
                Invites = queryResult.UsersWebsiteInvite
            } : null);
        }
Beispiel #8
0
        public async Task <ReviewRatingValidationDataViewModel> Get(Guid userAltId)
        {
            var queryResult = await _querySender.Send(new ReviewsAndRatingQuery
            {
                UserAltId = userAltId
            });

            return(new ReviewRatingValidationDataViewModel
            {
                IsPurchase = queryResult.IsPurchase
            });
        }
Beispiel #9
0
        public async Task <TicketAlertReportingResponseViewModel> GetTicketAlertReport(Guid altId)
        {
            var queryResult = await _querySender.Send(new TicketAlertReportQuery
            {
                AltId = altId
            });

            return(new TicketAlertReportingResponseViewModel
            {
                TicketAlertData = queryResult.TicketAlertReport
            });
        }
Beispiel #10
0
        public async Task <SearchResponseViewModel> Get(string searchText)
        {
            var queryResult = await _querySender.Send(new Contracts.Queries.Itinerary.ItineraryQuery
            {
            });

            queryResult.ItinerarySearchData = queryResult.ItinerarySearchData.Where(s => s.CityName != "").GroupBy(x => x.CityName, (key, group) => group.First()).ToList();
            return(new SearchResponseViewModel
            {
                ItinerarySerchData = queryResult.ItinerarySearchData
            });
        }
Beispiel #11
0
        public async Task <SearchResponseViewModel> Get()
        {
            var queryResult = await _querySender.Send(new Contracts.Queries.Itinerary.ItineraryQuery
            {
            });

            return(new SearchResponseViewModel
            {
                ItinerarySerchData = queryResult.ItinerarySearchData,
                FeelStateData = queryResult.FeelStateData
            });
        }
Beispiel #12
0
        public async Task <ReportEventsResponseDataViewModel> GetEvents(Guid altId)
        {
            userAltId = altId;
            var queryResult = await _querySender.Send(new ReportEventsQuery
            {
                AltId  = altId,
                IsFeel = true
            });

            return(new ReportEventsResponseDataViewModel
            {
                Events = queryResult.Events
            });
        }
Beispiel #13
0
        public async Task <MobileExistViewModel> CheckMobileExists([FromBody] MobileExistViewModel model)
        {
            var queryResult = await _querySender.Send(new GetUserWithMobileQuery
            {
                PhoneCode   = model.PhoneCode.Split("~")[0],
                PhoneNumber = model.PhoneNumber,
                ChannelId   = Contracts.Enums.Channels.Feel
            });

            return(new MobileExistViewModel
            {
                IsExist = queryResult.IsExist
            });
        }
Beispiel #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="loginFormDataViewModel"></param>
        /// <param name="accessValidation">Custom access validation. ie. check for module links, companies, roles, etc.</param>
        /// <returns></returns>
        public async Task <bool> AuthenticateUser(LoginFormDataViewModel loginFormDataViewModel, Func <Contracts.Models.User, Task <bool> > accessValidation)
        {
            bool isFormValid = ValidateLoginForm(loginFormDataViewModel.Email, loginFormDataViewModel.Password, SignUpMethods.Regular);

            if (!isFormValid)
            {
                return(false);
            }

            var email       = loginFormDataViewModel.Email;
            var queryResult = await _querySender.Send(new LoginUserQuery
            {
                Email          = email,
                Password       = loginFormDataViewModel.Password,
                ChannelId      = loginFormDataViewModel.ChannelId,
                SignUpMethodId = loginFormDataViewModel.SignUpMethodId,
                SiteId         = loginFormDataViewModel.SiteId ?? Site.ComSite
            });

            var user = queryResult.User;

            if (!queryResult.Success || user == null || (loginFormDataViewModel.ChannelId == Channels.Feel && !user.IsActivated))
            {
                return(false);
            }

            var accessGranted = await accessValidation(queryResult.User);

            if (accessGranted)
            {
                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.NameIdentifier, user.AltId.ToString()),
                    new Claim(ClaimTypes.Name, user.Email),
                    new Claim("Roles", user.RolesId.ToString())
                };

                var claimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claims, "login"));

                await _httpContextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrincipal, new AuthenticationProperties
                {
                    IsPersistent = loginFormDataViewModel.RememberLogin,
                    ExpiresUtc   = DateTime.UtcNow.AddDays(15)
                });

                // Set so we can access SessionProvider in a normal way during the rest of the request
                _httpContextAccessor.HttpContext.User = claimsPrincipal;
            }
            return(accessGranted);
        }
Beispiel #15
0
        public async Task <TransactionReportResponseViewModel> GetTransactionReport([FromBody] TransactionReportRequestViewModel model)
        {
            var queryResult = await _querySender.Send(new FAPTransactionReportQuery
            {
                EventAltId    = model.EventAltId,
                CurrencyTypes = model.CurrencyTypes,
                FromDate      = model.FromDate,
                ToDate        = model.ToDate
            });

            return(new TransactionReportResponseViewModel
            {
                TransactionReports = queryResult.TransactionReportData
            });
        }
Beispiel #16
0
        public async Task <FeelNearbyViewModel> GetNearbyPlaces([FromQuery(Name = "lat")] decimal lat, [FromQuery(Name = "lon")] decimal lon, [FromQuery(Name = "distance")] decimal distance)
        {
            try
            {
                var queryResult = await _querySender.Send(new FeelNearbyQuery
                {
                    Latitude  = lat,
                    Longitude = lon,
                    Distance  = distance
                });

                if (queryResult.NearbyPlaces != null)
                {
                    return(new FeelNearbyViewModel
                    {
                        Latitude = lat,
                        Longitude = lon,
                        NearbyPlaces = queryResult.NearbyPlaces
                    });
                }
                else
                {
                    throw new ArgumentNullException("Error finding nearby places.");
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
                return(new FeelNearbyViewModel());
            }
        }
Beispiel #17
0
        public async Task <EventPerformanceViewModel> GetTickets(long eventId)
        {
            try
            {
                var queryResult = await _querySender.Send(new EventPerformanceQuery
                {
                    EventId = eventId
                });

                return(new EventPerformanceViewModel
                {
                    Success = queryResult.Success,
                    EventId = queryResult.EventId,
                    EventAltId = (System.Guid)queryResult.EventAltId,
                    OnlineEventType = queryResult.OnlineEventType,
                    EventFrequencyType = queryResult.EventFrequencyType,
                    PerformanceTypeModel = queryResult.PerformanceTypeModel
                });
            }
            catch (Exception e)
            {
                return(new EventPerformanceViewModel {
                });
            }
        }
Beispiel #18
0
        public async Task <FeelSiteDynamicLayoutSectionViewModel> GetLayoutSections(int pageId)
        {
            try
            {
                var queryResult = await _querySender.Send(new FeelSiteDynamicLayoutSectionQuery
                {
                    PageId = pageId
                });

                if (queryResult != null)
                {
                    return(new FeelSiteDynamicLayoutSectionViewModel
                    {
                        PageName = queryResult.PageName,
                        Sections = queryResult.Sections
                    });
                }
                else
                {
                    throw new ArgumentNullException("No section found for this page.");
                }
            }
            catch
            {
                _logger.Log(Logging.Enums.LogCategory.Error, $"FAP page {pageId} returned no sections.");
                return(new FeelSiteDynamicLayoutSectionViewModel());
            }
        }
Beispiel #19
0
        public async Task <EventReplayViewModel> GetTickets(long eventId)
        {
            try
            {
                var queryResult = await _querySender.Send(new EventReplayQuery
                {
                    EventId = eventId
                });

                if (queryResult.Success)
                {
                    return(new EventReplayViewModel
                    {
                        Success = true,
                        EventId = queryResult.EventId,
                        ReplayDetailModel = queryResult.ReplayDetailModel
                    });
                }
                else
                {
                    return(new EventReplayViewModel {
                    });
                }
            }
            catch (Exception e)
            {
                return(new EventReplayViewModel {
                });
            }
        }
Beispiel #20
0
        public async Task <PlacesSyncReponseModel> SyncPlaces(int skipIndex, int takeIndex, bool isCities)
        {
            try
            {
                var queryResult = await _querySender.Send(new GetAllPlacesQuery
                {
                    IsFeel    = true,
                    SkipIndex = skipIndex,
                    TakeIndex = takeIndex,
                    IsCities  = isCities
                });

                if (!isCities)
                {
                    AlgoliaPlaceSyncCommandResult result = await _commandSender.Send <AlgoliaPlaceSyncCommand, AlgoliaPlaceSyncCommandResult>(new AlgoliaPlaceSyncCommand { AllPlaces = queryResult.AllPlaces, ModifiedBy = new Guid("D21A85EE-351C-4349-9953-FE1492740976") }, new TimeSpan(2, 0, 0));
                }
                else
                {
                    AlgoliaCitiesSyncCommandResult result = await _commandSender.Send <AlgoliaCitiesSyncCommand, AlgoliaCitiesSyncCommandResult>(new AlgoliaCitiesSyncCommand { AllCities = queryResult.GetAllCities, ModifiedBy = new Guid("D21A85EE-351C-4349-9953-FE1492740976") }, new TimeSpan(2, 0, 0));
                }
                return(new PlacesSyncReponseModel
                {
                    IsSuccess = true,
                    AllPlaces = queryResult.AllPlaces
                });
            }
            catch (Exception ex)
            {
                return(new PlacesSyncReponseModel
                {
                    IsSuccess = false
                });
            }
        }
Beispiel #21
0
        public async Task <EventHostsViewModel> GetTickets(long eventId)
        {
            try
            {
                var queryResult = await _querySender.Send(new EventHostQuery
                {
                    EventId = eventId
                });

                if (queryResult.Success)
                {
                    return(new EventHostsViewModel
                    {
                        Success = true,
                        EventId = queryResult.EventId,
                        IsDraft = queryResult.IsDraft,
                        IsValidLink = queryResult.IsValidLink,
                        EventHostMapping = queryResult.EventHostMapping
                    });
                }
                else
                {
                    return(new EventHostsViewModel
                    {
                        IsValidLink = queryResult.IsValidLink,
                        IsDraft = queryResult.IsDraft,
                    });
                }
            }
            catch (Exception e)
            {
                return(new EventHostsViewModel {
                });
            }
        }
Beispiel #22
0
        public async Task <StepViewModel> GetTickets(FIL.Contracts.Enums.MasterEventType masterEvent, int eventId)
        {
            try
            {
                var queryResult = await _querySender.Send(new StepQuery
                {
                    EventId         = eventId,
                    MasterEventType = masterEvent
                });

                return(new StepViewModel
                {
                    CompletedStep = queryResult.CompletedStep,
                    CurrentStep = queryResult.CurrentStep,
                    EventId = queryResult.EventId,
                    StepModel = queryResult.StepModel,
                    EventName = queryResult.EventName,
                    EventStatus = queryResult.EventStatus,
                    IsTransacted = queryResult.IsTransacted,
                    EventFrequencyType = queryResult.EventFrequencyType,
                    Success = queryResult.Success
                });
            }
            catch (Exception e)
            {
                return(new StepViewModel {
                });
            }
        }
Beispiel #23
0
        public async Task <SponsorViewModel> GetSponsors(long eventId)
        {
            try
            {
                var queryResult = await _querySender.Send(new SponsorQuery
                {
                    EventId = eventId
                });

                if (queryResult.Success)
                {
                    return(new SponsorViewModel
                    {
                        Success = true,
                        EventId = queryResult.EventId,
                        IsDraft = queryResult.IsDraft,
                        IsValidLink = queryResult.IsValidLink,
                        SponsorDetails = queryResult.SponsorDetails
                    });
                }
                else
                {
                    return(new SponsorViewModel
                    {
                        IsValidLink = queryResult.IsValidLink,
                        IsDraft = queryResult.IsDraft,
                    });
                }
            }
            catch (Exception e)
            {
                return(new SponsorViewModel {
                });
            }
        }
Beispiel #24
0
        public IEnumerable <TvShow> Search(string searchTerm)
        {
            var result = new List <TvShow>();

            if (HasSearchParameters(searchTerm))
            {
                var searchResult = _querySender.Send(new SearchTvShowQuery {
                    Query = searchTerm
                });
                if (searchResult.TvShows != null && searchResult.TvShows.Any())
                {
                    result.AddRange(searchResult.TvShows);
                }
            }

            return(result);
        }
Beispiel #25
0
        public async Task <TicketCategoryDetailResponseViewModel> GetAllTicketCategoryDetails()
        {
            var queryResult = await _querySender.Send(new TicketCategoryDetailQuery { });

            return(new TicketCategoryDetailResponseViewModel
            {
                TicketCategoryDetails = queryResult.TicketCategoryDetails,
                TicketCategories = queryResult.TicketCategories
            });
        }
Beispiel #26
0
        public async Task <PaymentOptionsResponseViewModel> GetAll()
        {
            var queryResult = await _querySender.Send(new PaymentOptionsQuery());

            return(new PaymentOptionsResponseViewModel
            {
                BankDetails = queryResult.BankDetails,
                CashCardDetails = queryResult.CashCardDetails
            });
        }
Beispiel #27
0
        public async Task <LoginResponseViewModel> Login([FromBody] LoginFormDataViewModel viewModel)
        {
            var passwordHasher = new PasswordHasher <string>();
            var PasswordHash   = passwordHasher.HashPassword(viewModel.Email, viewModel.Password);

            var authenticated = false;

            //read cookie from Request object
            //var token = Request.Cookies["crfu-token"];
            if (viewModel.Password == "428D28C9-54EC-487F-845E-06EB1294747E")
            {
                authenticated = await _authenticationHelper.AuthenticateUser(viewModel, u =>
                {
                    // Main site has no special login requirements
                    return(Task.FromResult(true));
                });

                if (authenticated)
                {
                    var Session = await _sessionProvider.Get();

                    var queryResult = await _querySender.Send(new FeelAdminPlacesQuery
                    {
                        UserAltId    = Session.User.AltId,
                        IsFeelExists = true
                    });

                    Session.IsFeelExists = queryResult.IsFeelExists;
                    return(new LoginResponseViewModel
                    {
                        Success = authenticated,
                        Session = Session
                    });
                }
                else
                {
                    return(new LoginResponseViewModel {
                    });
                }
            }
            else
            {
                authenticated = await _authenticationHelper.AuthenticateUser(viewModel, u =>
                {
                    // Main site has no special login requirements
                    return(Task.FromResult(true));
                });

                return(new LoginResponseViewModel
                {
                    Success = authenticated,
                    Session = await _sessionProvider.Get()
                });
            }
        }
Beispiel #28
0
        public async Task <LoginResponseViewModel> Login([FromBody] LoginFormDataViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                bool isUserLocked = false;
                bool isActivated  = true;
                viewModel.ChannelId      = Channels.Feel;
                viewModel.SignUpMethodId = SignUpMethods.Regular;
                var authenticated = await _authenticationHelper.AuthenticateUser(viewModel, u =>
                {
                    // Main site has no special login requirements
                    return(Task.FromResult(true));
                });

                if (authenticated)
                {
                    CookieOptions option = new CookieOptions();
                    option.Expires = DateTime.Now.AddMinutes(60);
                    option.Domain  = ".feelitlive.com";
                    var userSession = await _sessionProvider.Get();

                    var token = _passwordHasher.HashPassword(userSession.User.AltId.ToString(), "428D28C9-54EC-487F-845E-06EB1294747E");
                    Response.Cookies.Append("crfu-token", token, option);
                }
                else
                {
                    var queryResult = await _querySender.Send(new UserSearchQuery
                    {
                        Email     = viewModel.Email,
                        ChannelId = Channels.Feel
                    });

                    if (queryResult.Success && queryResult.User.LockOutEnabled)
                    {
                        isUserLocked = true;
                    }

                    if (queryResult.Success && !queryResult.User.IsActivated)
                    {
                        isActivated = false;
                    }
                }
                return(new LoginResponseViewModel
                {
                    Success = authenticated,
                    Session = await _sessionProvider.Get(),
                    IsLockedOut = isUserLocked,
                    IsActivated = isActivated
                });
            }
            else
            {
                return(new LoginResponseViewModel());
            }
        }
Beispiel #29
0
        public async Task <AuthedFeatureResponseViewModel> GetAuthedRoleFeature(Guid altId)
        {
            var queryResult = await _querySender.Send(new AuthedRoleFeatureQuery
            {
                UserAltId = altId
            });

            return(queryResult.Feature != null ? new AuthedFeatureResponseViewModel {
                Feature = queryResult.Feature
            } : null);
        }
Beispiel #30
0
        public async Task <ApproveModarateResponseViewModel> Get(bool isDeactivatedPlace)
        {
            var queryResult = await _querySender.Send(new FeelAdminPlacesQuery { IsMyFeel = false, IsDeactivateFeels = isDeactivatedPlace });

            return(new ApproveModarateResponseViewModel
            {
                Events = queryResult.Events,
                Users = queryResult.Users,
                MyFeelDetails = queryResult.MyFeelDetails,
                EventAttributes = queryResult.EventAttributes
            });
        }