Example #1
0
 public CopyListingViewModel(
     SettingFacade settingFacade,
     ListingFacade listingFacade,
     IListingFactory listingFactory
     )
 {
     _settingFacade  = settingFacade;
     _listingFacade  = listingFacade;
     _listingFactory = listingFactory;
 }
Example #2
0
 public ListingViewModel(
     ListingFacade listingFacade,
     EmployerFacade employerFacade,
     IListingFactory listingFactory
     )
 {
     _listingFacade  = listingFacade;
     _employerFacade = employerFacade;
     _listingFactory = listingFactory;
 }
Example #3
0
 public EmptyListingsGenerationViewModel(
     IIODialogService filePathDialogService,
     IListingsReportFactory multipleListingReportFactory,
     IListingReportGenerator listingReportGenerator,
     IListingFactory listingFactory
     )
 {
     _filePathDialogService        = filePathDialogService;
     _multipleListingReportFactory = multipleListingReportFactory;
     _listingReportGenerator       = listingReportGenerator;
     _listingFactory = listingFactory;
 }
Example #4
0
 public CreateListingCommandHandler(
     IListingRepository listingRepository,
     IListingFactory listingFactory,
     IUserSellerRepository userSellerRepository,
     IBus publisher,
     ICurrentUserService currentUserService)
 {
     this.listingRepository    = listingRepository;
     this.listingFactory       = listingFactory;
     this.publisher            = publisher;
     this.currentUserService   = currentUserService;
     this.userSellerRepository = userSellerRepository;
 }
Example #5
0
 public RoundController(IMemoryCache cache,
                        ICacheFactoryStore cacheFactoryStore,
                        ToracGolfContext dbContext,
                        IAntiforgery antiforgery,
                        IOptions<AppSettings> configuration,
                        IListingFactory<RoundListingFactory.RoundListingSortEnum, Round, RoundListingData> roundListingFactory)
 {
     DbContext = dbContext;
     Cache = cache;
     CacheFactory = cacheFactoryStore;
     Antiforgery = antiforgery;
     Configuration = configuration;
     RoundListingFactory = roundListingFactory;
 }
Example #6
0
 public CourseController(IMemoryCache cache,
                         ICacheFactoryStore cacheFactoryStore,
                         ToracGolfContext dbContext,
                         IAntiforgery antiforgery,
                         IOptions<AppSettings> configuration,
                         IListingFactory<CourseListingFactory.CourseListingSortEnum, Course, CourseListingData> courseListingFactory)
 {
     DbContext = dbContext;
     Cache = cache;
     CacheFactory = cacheFactoryStore;
     Antiforgery = antiforgery;
     Configuration = configuration;
     CourseListingFactory = courseListingFactory;
 }
        public static IQueryable<Course> CourseSelectQueryBuilder(ToracGolfContext dbContext,
                                                                  IListingFactory<CourseListingFactory.CourseListingSortEnum, Course, CourseListingData> courseListingFactory,
                                                                  string courseNameFilter,
                                                                  int? stateFilter)
        {
            //build the queryable
            var queryable = dbContext.Course.AsNoTracking().Where(x => x.IsActive).AsQueryable();

            //go build the query
            queryable = FilterBuilder.BuildQueryFilter(dbContext, queryable, courseListingFactory,
                                    new KeyValuePair<string, object>(nameof(courseNameFilter), courseNameFilter),
                                    new KeyValuePair<string, object>(nameof(stateFilter), stateFilter));

            //return the queryable
            return queryable;
        }
Example #8
0
 public static async Task<int> TotalNumberOfRounds(ToracGolfContext dbContext, IListingFactory<RoundListingFactory.RoundListingSortEnum, Round, RoundListingData> roundListingFactory, int userId, string roundNameFilter, int? StateFilter, DateTime? roundDateStartFilter, DateTime? roundDateEndFilter, bool onlyHandicappedRounds)
 {
     return await RoundSelectQueryBuilder(dbContext, roundListingFactory, userId, roundNameFilter, StateFilter, roundDateStartFilter, roundDateEndFilter, onlyHandicappedRounds).CountAsync().ConfigureAwait(false);
 }
Example #9
0
        public static async Task<RoundSelectModel> RoundSelect(IListingFactory<RoundListingFactory.RoundListingSortEnum, Round, RoundListingData> roundListingFactory,
                                                               ToracGolfContext dbContext,
                                                               int userId,
                                                               int pageId,
                                                               RoundListingFactory.RoundListingSortEnum sortBy,
                                                               string courseNameFilter,
                                                               int? seasonFilter,
                                                               int recordsPerPage,
                                                               DateTime? roundDateStartFilter,
                                                               DateTime? roundDateEndFilter,
                                                               ImageFinder courseImageFinder,
                                                               bool handicappedRoundOnly)
        {
            //go grab the query
            var queryable = RoundSelectQueryBuilder(dbContext, roundListingFactory, userId, courseNameFilter, seasonFilter, roundDateStartFilter, roundDateEndFilter, handicappedRoundOnly);

            //go sort the data
            var sortedQueryable = roundListingFactory.SortByConfiguration[sortBy](queryable, new ListingFactoryParameters(dbContext, userId)).ThenBy(x => x.RoundId);

            //go return the queryable
            var selectableQuery = sortedQueryable.Select(x => new RoundListingData
            {
                RoundId = x.RoundId,
                CourseId = x.CourseId,
                CourseName = x.Course.Name,
                RoundDate = x.RoundDate,
                Score = x.Score,
                SeasonId = x.SeasonId,
                TeeBoxLocation = x.CourseTeeLocation,
                HandicapBeforeRound = x.Handicap.HandicapBeforeRound,

                Putts = x.Putts,
                FairwaysHit = x.FairwaysHit,
                GreensInRegulation = x.GreensInRegulation,

                RoundHandicap = x.RoundHandicap
            });

            //go run the query now
            var dataSet = await EFPaging.PageEfQuery(selectableQuery, pageId, recordsPerPage).ToListAsync().ConfigureAwait(false);

            //let's loop through the rounds and display the starts
            foreach (var round in dataSet)
            {
                //calculate the adjusted score
                round.AdjustedScore = Convert.ToInt32(Math.Round(round.Score - round.HandicapBeforeRound, 0));

                //go calculate the round performance
                round.RoundPerformance = (int)RoundPerformance.CalculateRoundPerformance(round.TeeBoxLocation.Front9Par + round.TeeBoxLocation.Back9Par, round.AdjustedScore);

                //set the image path
                round.CourseImagePath = courseImageFinder.FindImage(round.CourseId);
            }

            //go return the lookup now
            return new RoundSelectModel(dataSet);
        }
Example #10
0
        public static IQueryable<Round> RoundSelectQueryBuilder(ToracGolfContext dbContext,
                                                                IListingFactory<RoundListingFactory.RoundListingSortEnum, Round, RoundListingData> roundListingFactory,
                                                                int userId,
                                                                string courseNameFilter,
                                                                int? seasonFilter,
                                                                DateTime? roundDateStartFilter,
                                                                DateTime? roundDateEndFilter,
                                                                bool handicappedRoundsOnly)
        {
            //build the queryable
            var queryable = dbContext.Rounds.AsNoTracking().Where(x => x.UserId == userId).AsQueryable();

            //go build the query filters
            queryable = FilterBuilder.BuildQueryFilter(dbContext, queryable, roundListingFactory,
                                    new KeyValuePair<string, object>(nameof(courseNameFilter), courseNameFilter),
                                    new KeyValuePair<string, object>(nameof(seasonFilter), seasonFilter),
                                    new KeyValuePair<string, object>(nameof(roundDateStartFilter), roundDateStartFilter),
                                    new KeyValuePair<string, object>(nameof(roundDateStartFilter), roundDateStartFilter),
                                    new KeyValuePair<string, object>(nameof(handicappedRoundsOnly), handicappedRoundsOnly));

            //if (handicappedRoundsOnly)
            //{
            //    //how many rounds do we have?
            //    int roundsWeHaveInQuery = queryable.Count();

            //    //now check how many are in the calculation
            //    var howManyToCalculateWith = Handicapper.HowManyRoundsToUseInFormula(roundsWeHaveInQuery > 20 ? 20 : roundsWeHaveInQuery);

            //    //now just grab the last 20
            //    var last20RoundIds = queryable.OrderByDescending(x => x.RoundDate)
            //                                  .ThenByDescending(x => x.RoundId)
            //                                  .Take(20) //we only ever get the last 20...
            //                                  .OrderBy(x => x.RoundHandicap) //now grab the lowest rated rounds of how many we are going to calculate with
            //                                  .Take(howManyToCalculateWith) //then grab just those
            //                                  .Select(x => x.RoundId).ToArray();

            //    //add the round id's to the query
            //    queryable = queryable.Where(x => last20RoundIds.Contains(x.RoundId));
            //}

            //return the query
            return queryable;
        }
Example #11
0
        /// <param name="pageId">0 base index that holds what page we are on</param>
        public static async Task<IEnumerable<CourseListingData>> CourseSelect(IListingFactory<CourseListingFactory.CourseListingSortEnum, Course, CourseListingData> courseListingFactory,
                                                                              ToracGolfContext dbContext,
                                                                              int pageId,
                                                                              CourseListingFactory.CourseListingSortEnum sortBy,
                                                                              string courseNameFilter,
                                                                              int? stateFilter,
                                                                              int recordsPerPage,
                                                                              int userId,
                                                                              ImageFinder courseImageFinder)
        {
            //go grab the query
            var queryable = CourseSelectQueryBuilder(dbContext, courseListingFactory, courseNameFilter, stateFilter);

            //go sort the data
            var sortedQueryable = courseListingFactory.SortByConfiguration[sortBy](queryable, new ListingFactoryParameters(dbContext, userId)).ThenBy(x => x.CourseId);

            //go run the query now
            var query = sortedQueryable.Select(x => new CourseListingData
            {
                CourseData = x,
                StateDescription = x.State.Description,
                TeeLocationCount = x.CourseTeeLocations.Count,

                NumberOfRounds = x.Rounds.Count(y => y.UserId == userId),
                TopScore = x.Rounds.Where(y => y.UserId == userId).Min(y => y.Score),
                WorseScore = x.Rounds.Where(y => y.UserId == userId).Max(y => y.Score),
                AverageScore = x.Rounds.Where(y => y.UserId == userId).Average(y => y.Score),

                FairwaysHit = x.Rounds.Where(y => y.UserId == userId).Sum(y => y.FairwaysHit),
                FairwaysHitAttempted = x.Rounds.Where(y => y.UserId == userId).Sum(y => y.CourseTeeLocation.FairwaysOnCourse),
                GreensInRegulation = x.Rounds.Where(y => y.UserId == userId).Average(y => y.GreensInRegulation),
                NumberOfPutts = x.Rounds.Where(y => y.UserId == userId).Average(y => y.Putts)
            });

            //go execute it and return it
            var data = await EFPaging.PageEfQuery(query, pageId, recordsPerPage).ToListAsync().ConfigureAwait(false);

            //go find the course paths
            data.ForEach(x => x.CourseImageLocation = courseImageFinder.FindImage(x.CourseData.CourseId));

            //return the data set
            return data;
        }
Example #12
0
 public static async Task<int> TotalNumberOfCourses(ToracGolfContext dbContext, IListingFactory<CourseListingFactory.CourseListingSortEnum, Course, CourseListingData> courseListingFactory, string courseNameFilter, int? StateFilter)
 {
     return await CourseSelectQueryBuilder(dbContext, courseListingFactory, courseNameFilter, StateFilter).CountAsync().ConfigureAwait(false);
 }