public IndexPaginatorModel GetAll(bool Right, bool Left, string Name, int Page = 1) { using (var uow = UnitOfWorkFactory.CreateUnitOfWork()) { var Model = new IndexPaginatorModel(); var Shops = uow.Shops.GetFullShops(); Model.Page = Page; if (Page == 0) { Model.Page = 1; } else if (Right && Model.CurrentElementCount < Shops.Count) { Model.Page++; } else if (Right && Model.CurrentElementCount > Shops.Count) { Model.Page = Shops.Count / Model.ElementCount; } else if (Left && Model.Left) { Model.Page--; } if (Name != null) { Model.Models = GetShops(Model, Shops).Where(i => i.Name.Contains(Name)).ToList(); } else { Model.Models = GetShops(Model, Shops); } return(Model); } }
private List <ShopIndexModel> GetShops(IndexPaginatorModel model, List <Shop> shops) { var Shops = new List <Shop>(); for (int i = (model.Page - 1) * model.ElementCount; i < model.Page * model.ElementCount && i < shops.Count; i++) { Shops.Add(shops[i]); } return(Mapper.Map <List <ShopIndexModel> >(Shops)); }