public void PersonManager_Search_ShouldCall_RepositorySearch(PersonSearchCriteria personSearchCriteria)
        {
            //Arrange
            Mock <IPersonRepository> personRepository = new Mock <IPersonRepository>();


            SetupUserIdentity();
            SetupPersonRepository(personRepository);

            var criteria = new SearchCriteria();

            criteria.Add(new FilterParameter("PersonId", 123));

            PersonsManager personsManager = new PersonsManager(userManager.Object, cacheStoreManager, mockLogManager.Object, personRepository.Object, transformationManager);

            //Act
            IPaginatedList <BLL_Person> actual = personsManager.Search(criteria);

            int expectedTotalRecordCount = 1;

            //Assert
            personRepository.Verify(p => p.Search(It.IsAny <SearchCriteria>()));

            Assert.AreEqual(expectedTotalRecordCount, actual.TotalRecordCount);
        }
예제 #2
0
        private async Task UpdatePaginatorAsync(IPaginatedList <EntityT, KeyT>?fromPaginator)
        {
            var args = new PaginatorUpdateEventArgs <EntityT, KeyT>(fromPaginator);

            if (PrePageUpdateTask != null)
            {
                await PrePageUpdateTask.Invoke(args).ConfigureAwait(false);
            }

            if (fromPaginator != null)
            {
                Entities   = fromPaginator.Entities;
                PageIndex  = fromPaginator.PageIndex;
                Count      = fromPaginator.Count;
                TotalPages = fromPaginator.TotalPages;

                if (PageIndex > TotalPages)
                {
                    PageIndex = TotalPages;
                }
            }
            else
            {
                Initialize();
            }

            if (PageUpdateTask != null)
            {
                await PageUpdateTask.Invoke(args).ConfigureAwait(false);
            }
        }
예제 #3
0
 public BusinessService(AlphaHotelDbContext context, IMappingProvider mapper, IDateTimeWrapper dateTime, IPaginatedList <BusinessShortInfoDTO> paginatedList)
 {
     this.context       = context ?? throw new ArgumentNullException(nameof(context));
     this.mapper        = mapper ?? throw new ArgumentNullException(nameof(mapper));
     this.dateTime      = dateTime ?? throw new ArgumentNullException(nameof(dateTime));
     this.paginatedList = paginatedList ?? throw new ArgumentNullException(nameof(paginatedList));
 }
예제 #4
0
        public static IPaginatedList <PostViewModel> MapToViewModel(this IPaginatedList <Post> source)
        {
            var destination = new List <PostViewModel>();

            if (source != null && source.Count > 0)
            {
                foreach (var item in source)
                {
                    var post = new PostViewModel
                    {
                        Id          = item.Id,
                        Title       = item.Title,
                        CreateDate  = item.CreateDate,
                        Description = item.Description,
                        Status      = item.Status,
                        UserId      = item.UserId
                    };
                    if (item.User != null)
                    {
                        post.User = new UserInfo
                        {
                            FullName = item.User.FullName,
                            UserName = item.User.UserName
                        };
                    }
                    destination.Add(post);
                }
            }
            return(new PaginatedList <PostViewModel>(destination, source?.Count ?? 0, source?.PageIndex ?? 0, source?.TotalPages ?? 0));
        }
예제 #5
0
        protected void LinkbuttonPrev_Command(object source, System.Web.UI.WebControls.CommandEventArgs e)
        {
            IPaginatedList productList = this.WebLocalSingleton.CurrentList;

            productList.PreviousPage();
            this.CurrentController.NextView = WebViews.SEARCH_PRODUCTS;
        }
예제 #6
0
        public override void DataBind()
        {
            IPaginatedList productList = this.WebLocalSingleton.CurrentList;

            //string keywords = this.WebLocalSingleton.CurrentAction.Data[DataViews.SEARCH_KEYWORDS] as string;

            //LiteralKeywords.Text = keywords;
            RepeaterProduct.DataSource = productList;
            RepeaterProduct.DataBind();

            if (productList.IsNextPageAvailable)
            {
                LinkbuttonNext.Visible = true;
                //LinkbuttonNext.CommandArgument = keywords;
            }
            else
            {
                LinkbuttonNext.Visible = false;
            }
            if (productList.IsPreviousPageAvailable)
            {
                LinkbuttonPrev.Visible = true;
                //LinkbuttonPrev.CommandArgument = keywords;
            }
            else
            {
                LinkbuttonPrev.Visible = false;
            }
        }
예제 #7
0
        public override void DataBind()
        {
            IPaginatedList itemList = this.NPetshopState.CurrentList as IPaginatedList;

            Domain.Catalog.Product product = itemList[0] as Domain.Catalog.Product;

            foreach (Domain.Catalog.Item item in itemList)
            {
                product = item.Product;
            }

            LabelProduct.Text        = product.Name;
            RepeaterItems.DataSource = itemList;
            RepeaterItems.DataBind();

            if (itemList.IsNextPageAvailable)
            {
                LinkbuttonNext.Visible         = true;
                LinkbuttonNext.CommandArgument = product.Id;
            }
            else
            {
                LinkbuttonNext.Visible = false;
            }
            if (itemList.IsPreviousPageAvailable)
            {
                LinkbuttonPrev.Visible         = true;
                LinkbuttonPrev.CommandArgument = product.Id;
            }
            else
            {
                LinkbuttonPrev.Visible = false;
            }
        }
예제 #8
0
        public void ShowProductsByCategory(string categoryId)
        {
            IPaginatedList productList = _catalogService.GetProductListByCategory(categoryId);

            this.NState.CurrentList = productList;
            this.Navigate();
        }
예제 #9
0
        protected void LinkbuttonNext_Command(object source, System.Web.UI.WebControls.CommandEventArgs e)
        {
            IPaginatedList productList = this.NPetshopState.CurrentList;

            productList.NextPage();
            DataBind();
        }
예제 #10
0
 public FeedbackService(AlphaHotelDbContext context, IPaginatedList <FeedbackDTO> paginatedList, IDateTimeWrapper dateTime, ICensor censor)
 {
     this.context       = context ?? throw new ArgumentNullException(nameof(context));
     this.paginatedList = paginatedList ?? throw new ArgumentNullException(nameof(paginatedList));
     this.dateTime      = dateTime ?? throw new ArgumentNullException(nameof(dateTime));
     this.censor        = censor ?? throw new ArgumentNullException(nameof(censor));
 }
예제 #11
0
        public async Task <PaginatedList <TItem, TSearch> > GetPaginatedAsync <TItem, TSearch>(
            IPaginatedList <TSearch> page,
            List <Expression <Func <TItem, bool> > > predicates,
            string includes = "",
            Expression <Func <TItem, decimal> > summaryValue = null) where TItem : class
        {
            var query = context.Set <TItem>().AsNoTracking();

            if (!string.IsNullOrWhiteSpace(includes))
            {
                foreach (var include in includes.Split(','))
                {
                    query = query.Include(include);
                }
            }
            if (predicates != null)
            {
                foreach (var predicate in predicates)
                {
                    query = query.Where(predicate);
                }
            }
            query = query.OrderBy(page.OrderBy, !page.OrderByDesc);
            decimal?summary = null;

            if (summaryValue != null)
            {
                summary = await query.SumAsync(summaryValue);
            }
            var count = await query.CountAsync();

            var items = await query.Skip((page.PageIndex - 1) *page.PageSize).Take(page.PageSize).ToListAsync();

            return(new PaginatedList <TItem, TSearch>(page, items, count, summary));
        }
예제 #12
0
        public override void DataBind()
        {
            NPetshop.Domain.Catalog.Product product = this.WebLocalSingleton.CurrentAction.Data[DataViews.PRODUCT] as NPetshop.Domain.Catalog.Product;
            IPaginatedList paginatedList            = this.WebLocalSingleton.CurrentList as IPaginatedList;

            LabelProduct.Text       = product.Name;
            RepeaterItem.DataSource = paginatedList;
            RepeaterItem.DataBind();

            if (paginatedList.IsNextPageAvailable)
            {
                LinkbuttonNext.Visible         = true;
                LinkbuttonNext.CommandArgument = product.Id;
            }
            else
            {
                LinkbuttonNext.Visible = false;
            }
            if (paginatedList.IsPreviousPageAvailable)
            {
                LinkbuttonPrev.Visible         = true;
                LinkbuttonPrev.CommandArgument = product.Id;
            }
            else
            {
                LinkbuttonPrev.Visible = false;
            }
        }
예제 #13
0
        public override void DataBind()
        {
            IPaginatedList productList = this.NPetshopState.CurrentList;
            string         keywords    = this.NPetshopState.CurrentObject as string;

            LiteralKeywords.Text       = keywords;
            RepeaterProduct.DataSource = productList;
            RepeaterProduct.DataBind();

            if (productList.IsNextPageAvailable)
            {
                LinkbuttonNext.Visible = true;
            }
            else
            {
                LinkbuttonNext.Visible = false;
            }
            if (productList.IsPreviousPageAvailable)
            {
                LinkbuttonPrev.Visible = true;
            }
            else
            {
                LinkbuttonPrev.Visible = false;
            }
        }
예제 #14
0
        private async Task <List <CiCdBuildDto> > GetBuildsByRepository(RepositoryDto repository)
        {
            List <CiCdBuildDto> builds = new List <CiCdBuildDto>();

            IPaginatedList <CiCdDto> cicds = await ciCdService.GetAsync(pageIndex : 1, pageSize : 1000);

            foreach (var cicd in cicds)
            {
                encryption.Decrypt(cicd);
            }

            foreach (ICiCdProvider provider in providers)
            {
                foreach (CiCdDto cicd in cicds.Where(cicd => provider.Supports(cicd.Kind)))
                {
                    try
                    {
                        List <CiCdBuildDto> results = await provider.GetBuildsAsync(repository, cicd);

                        builds.AddRange(results);
                    }
                    catch (Exception e)
                    {
                        logger.LogError(e, $"{nameof(GetBuildsByRepositoryIdAsync)}::[{repository.Url}]::[{cicd.Endpoint}]::ERROR");
                    }
                }
            }

            logger.LogInformation($"{nameof(GetBuildsByRepositoryIdAsync)}::[{repository.WebUrl}]::CICD::SEARCH::RESULTS::[{builds.Count}]");

            cache.Set(repository.RepositoryId, builds, absoluteExpiration: DateTimeOffset.Now.AddHours(2));

            return(builds);
        }
예제 #15
0
        public EventViewModelsList(IPaginatedList <EventObject> l, string sortOrder = null)
        {
            if (l is null)
            {
                return;
            }
            PageIndex  = l.PageIndex;
            TotalPages = l.TotalPages;
            var newEvent = new List <EventViewModel>();
            IOrderedEnumerable <EventViewModel> ordered;

            foreach (var e in l)
            {
                Add(EventViewModelFactory.Create(e));
            }

            switch (sortOrder)
            {
            case "name_desc":
                ordered = newEvent.OrderByDescending(s => s.Name);
                break;

            case "id":
                ordered = newEvent.OrderByDescending(s => s.ID);
                break;

            case "id_desc":
                ordered = newEvent.OrderBy(s => s.ID);
                break;

            case "date":
                ordered = newEvent.OrderByDescending(s => s.Date);
                break;

            case "date_desc":
                ordered = newEvent.OrderBy(s => s.Date);
                break;

            case "location":
                ordered = newEvent.OrderBy(s => s.Location);
                break;

            case "location_desc":
                ordered = newEvent.OrderByDescending(s => s.Location);
                break;

            case "organizer":
                ordered = newEvent.OrderBy(s => s.Organizer);
                break;

            case "organizer_desc":
                ordered = newEvent.OrderByDescending(s => s.Organizer);
                break;

            default:
                ordered = newEvent.OrderBy(s => s.Name);
                break;
            }
            AddRange(ordered);
        }
예제 #16
0
        private void LinkbuttonNext_Command(object source, CommandEventArgs e)
        {
            IPaginatedList productList = this.NPetshopState.CurrentList;

            productList.NextPage();
            DataBind();
        }
예제 #17
0
        public override void DataBind()
        {
            IPaginatedList productList = this.NPetshopState.CurrentList;

            Domain.Catalog.Category category = ((Domain.Catalog.Product)productList[0]).Category;

            RepeaterProducts.DataSource = productList;
            RepeaterProducts.DataBind();

            if (productList.IsNextPageAvailable)
            {
                LinkbuttonNext.Visible         = true;
                LinkbuttonNext.CommandArgument = category.Id;
            }
            else
            {
                LinkbuttonNext.Visible = false;
            }
            if (productList.IsPreviousPageAvailable)
            {
                LinkbuttonPrev.Visible         = true;
                LinkbuttonPrev.CommandArgument = category.Id;
            }
            else
            {
                LinkbuttonPrev.Visible = false;
            }

            LabelCategory.Text = category.Name;
        }
예제 #18
0
        public CurrencyViewModelsList(IPaginatedList <CurrencyObject> l, string sortOrder = null)
        {
            if (l is null)
            {
                return;
            }
            PageIndex  = l.PageIndex;
            TotalPages = l.TotalPages;
            var currencies = new List <CurrencyViewModel>();
            IOrderedEnumerable <CurrencyViewModel> ordered;

            foreach (var e in l)
            {
                currencies.Add(CurrencyViewModelFactory.Create(e));
            }

            switch (sortOrder)
            {
            case "currency_desc":
                ordered = currencies.OrderByDescending(s => s.Name);
                break;

            case "alpha3":
                ordered = currencies.OrderBy(s => s.Alpha3Code);
                break;

            case "alpha3_desc":
                ordered = currencies.OrderByDescending(s => s.Alpha3Code);
                break;

            case "symbol":
                ordered = currencies.OrderBy(s => s.CurrencySymbol);
                break;

            case "symbol_desc":
                ordered = currencies.OrderByDescending(s => s.CurrencySymbol);
                break;

            case "validFrom":
                ordered = currencies.OrderBy(s => s.ValidFrom);
                break;

            case "validFrom_desc":
                ordered = currencies.OrderByDescending(s => s.ValidFrom);
                break;

            case "validTo":
                ordered = currencies.OrderBy(s => s.ValidTo);
                break;

            case "validTo_desc":
                ordered = currencies.OrderByDescending(s => s.ValidTo);
                break;

            default:
                ordered = currencies.OrderBy(s => s.Name);
                break;
            }
            AddRange(ordered);
        }
예제 #19
0
        private void LinkbuttonNext_Command(object source, System.Web.UI.WebControls.CommandEventArgs e)
        {
            IPaginatedList productList = this.WebLocalSingleton.CurrentList;

            productList.NextPage();
            this.CurrentController.NextView = WebViews.PRODUCTS_BY_CATEGORY;
        }
예제 #20
0
 public IViewComponentResult Invoke(IPaginatedList values, Dictionary <string, string> routeData = null)
 {
     return(View("Default", new PaginationViewModel()
     {
         List = values, RouteData = routeData
     }));
 }
예제 #21
0
        public PersonViewModelsList(IPaginatedList <PersonObject> list, string sortOrder = null)
        {
            if (list is null)
            {
                return;
            }
            PageIndex  = list.PageIndex;
            TotalPages = list.TotalPages;
            var catalogues = new List <PersonViewModel>();
            IOrderedEnumerable <PersonViewModel> ordered;

            foreach (var e in list)
            {
                catalogues.Add(PersonViewModelFactory.Create(e));
            }
            switch (sortOrder)
            {
            case "firstName_desc":
                ordered = catalogues.OrderByDescending(s => s.FirstName);
                break;

            case "lastName":
                ordered = catalogues.OrderBy(s => s.LastName);
                break;

            case "lastName_desc":
                ordered = catalogues.OrderByDescending(s => s.LastName);
                break;

            case "idcode":
                ordered = catalogues.OrderBy(s => s.IDCode);
                break;

            case "idcode_desc":
                ordered = catalogues.OrderByDescending(s => s.IDCode);
                break;

            case "validFrom":
                ordered = catalogues.OrderBy(s => s.ValidFrom);
                break;

            case "validFrom_desc":
                ordered = catalogues.OrderByDescending(s => s.ValidFrom);
                break;

            case "validTo":
                ordered = catalogues.OrderBy(s => s.ValidTo);
                break;

            case "validTo_desc":
                ordered = catalogues.OrderByDescending(s => s.ValidTo);
                break;

            default:
                ordered = catalogues.OrderBy(s => s.FirstName);
                break;
            }
            AddRange(ordered);
        }
예제 #22
0
        public static void Restore <TModel>(this IPaginatedList <TModel> list, int pageIndex, int pageSize)
        {
            list.PageIndex = pageIndex;
            var count = list.Items.Count;

            list.TotalPages = (int)Math.Ceiling(count / (double)pageSize);
            list.TotalCount = count;
        }
예제 #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PaginatedResultModel"/> class.
 /// </summary>
 /// <param name="paginatedList">The paginated list.</param>
 public PaginatedResultModel(IPaginatedList paginatedList)
 {
     ShowingStartRange = paginatedList.StartRange;
     ShowingEndRange   = paginatedList.EndRange;
     TotalRecords      = paginatedList.TotalItemCount;
     PageSize          = paginatedList.PageSize;
     LastPage          = (TotalRecords + PageSize - 1) / PageSize;
 }
예제 #24
0
        public IPaginatedList GetItemListByProduct(string productId)
        {
            IPaginatedList itemList = null;

            itemList = _itemDao.GetItemListByProduct(productId);

            return(itemList);
        }
예제 #25
0
        public void ShowItemsByProduct(string productId)
        {
            Product        product  = _catalogService.GetProduct(productId);
            IPaginatedList itemList = _catalogService.GetItemListByProduct(product);

            this.NState.CurrentList = itemList;
            this.Navigate();
        }
예제 #26
0
        public IPaginatedList SearchProductList(string keywords)
        {
            IPaginatedList productList = null;

            productList = _productDao.SearchProductList(keywords);

            return(productList);
        }
예제 #27
0
        public IPaginatedList GetProductListByCategory(string categoryId)
        {
            IPaginatedList productList = null;

            productList = _productDao.GetProductListByCategory(categoryId);

            return(productList);
        }
예제 #28
0
 public PaginationModel(IPaginatedList paginatedList)
 {
     PageIndex  = paginatedList.PageIndex;
     TotalPages = paginatedList.TotalPages;
     TotalCount = paginatedList.TotalCount;
     PageSize   = paginatedList.PageSize;
     WindowSize = paginatedList.WindowSize;
 }
예제 #29
0
        public void SearchProducts(string keywords)
        {
            IPaginatedList productList = null;

            productList               = _catalogService.SearchProductList(keywords.ToLower());
            this.NState.CurrentList   = productList;
            this.NState.CurrentObject = keywords;
            this.Navigate();
        }
예제 #30
0
        public async Task MapAsync(IPaginatedList <ConversationDto> list)
        {
            var conversations = list.Items;

            foreach (var conversation in conversations)
            {
                await MapAsync(conversation);
            }
        }
예제 #31
0
 public PaginateInfo(IPaginatedList list)
     : this(list.PageIndex, list.PageSize, list.TotalCount)
 {
 }