Ejemplo n.º 1
0
        public void UpdateTopOne()
        {
            var queryParameters = new QueryParameters
            {
                SortSettings = SortSettingsBuilder <User>
                               .Create()
                               .DescendingBy("Rating")
                               .GetSettings()
            };

            var user = identityUnitOfWork.GetFirstOrDefault <User>(queryParameters);

            BecameTopOne(user.Id);
        }
Ejemplo n.º 2
0
        public IList <UserTopViewModel> GetTopUsers()
        {
            var parameters = new QueryParameters
            {
                SortSettings = SortSettingsBuilder <User> .Create()
                               .DescendingBy(x => x.Rating)
                               .GetSettings(),

                PageRule = new PageRule
                {
                    Count = 10,
                    Start = 0
                }
            };

            var users = unitOfWork.GetAll <User>(parameters);

            return(mapper.Map <List <UserTopViewModel> >(users));
        }
        private void PrepareQueryParameters(QueryParameters queryParameters, SortingType sortingType)
        {
            switch (sortingType)
            {
            case SortingType.Latest:
                queryParameters.SortSettings = SortSettingsBuilder <Challenge>
                                               .Create()
                                               .DescendingBy("TimeCreated")
                                               .GetSettings();

                break;

            case SortingType.Popular:
                queryParameters.SortSettings = SortSettingsBuilder <Challenge>
                                               .Create()
                                               .DescendingBy("TimesSolved")
                                               .GetSettings();

                break;

            case SortingType.Unsolved:
                queryParameters.SortSettings = SortSettingsBuilder <Challenge>
                                               .Create()
                                               .AscendingBy("TimeCreated")
                                               .GetSettings();

                break;
            }

            if (sortingType == SortingType.Unsolved)
            {
                queryParameters.FilterSettings = FilterSettingsBuilder <Challenge>
                                                 .Create()
                                                 .AddFilterRule(x => x.TimesSolved, FilterOperator.IsEqualTo, 0)
                                                 .GetSettings();
            }
        }