Exemplo n.º 1
1
        public void SetupController()
        {
            resultsRows = Builder<AwsEc2Status>.CreateListOfSize(totalRows).Build();
            repository = Substitute.For<IRepository<AwsEc2Status>>();
            repository.All().Returns(resultsRows.AsQueryable());

            RepositorySession.DefaultContainerType = typeof(FakeObjectContext);

            controller = new QuartzController(repository);
        }
        public void SetupController()
        {
            resultsRows = Builder<NiceLittleForm>.CreateListOfSize(TotalRows).Build();

            repository = Substitute.For<IRepository<NiceLittleForm>>();
            session = Substitute.For<IRepositorySession>();
            repository.All().Returns(resultsRows.AsQueryable());

            RepositorySession.DefaultContainerType = typeof(FakeObjectContext);

            controller = new NiceLittleFormController(repository, session);
        }
Exemplo n.º 3
0
        public CategoriesController(IRepository repository)
            : this()
        {
            _repository = repository;

            var catTree = _repository.All<CategoryTree>().FirstOrDefault();

            if (catTree != null)
              ViewBag.CategoryTree = catTree.Root;
        }
 public IQueryable <BusinessTripPlan> GetAll()
 {
     return(_monthlyBusinessTripPlanRepository.All());
 }
Exemplo n.º 5
0
        public virtual bool All(Func <T, bool> predicate)
        {
            bool Result = Entities.All(predicate);

            return(Result);
        }
Exemplo n.º 6
0
 public IEnumerable <Product> All()
 {
     return(_repository.All());
 }
 public ActionResult <IEnumerable <string> > Get()
 {
     return(Ok(_mapper.Map <List <Ogretmen> >(ogretmenRepository.All().ToList())));
 }
        public IEnumerable <TType> GetAll()
        {
            IRepository <TType> genericrepo = GenericFactory <TType> .GetInstance().GetObject();

            return(genericrepo.All());
        }
        public IEnumerable <BookLoan> getAllLoans()
        {
            var y = (from b in _loans.All() select b).ToList();

            return(y);
        }
Exemplo n.º 10
0
 public IActionResult Get()
 {
     return(Ok(_productRepository.All()));
 }
 // 获取待办 GET: /WorkFlow/GetToDo?uid=
 public ActionResult GetToDo(string uid)
 {
     return(Json(State.Success, _workFlowService.GetToDo(uid, _userRole.All(a => a.user_id == uid).Select(b => b.role_id).ToList()), false));
 }
Exemplo n.º 12
0
        public async Task AddCategory_Adds_NewCategory_When_UniqueTitle_Provided()
        {
            int    categoryId  = 4;
            string title       = "NewAddedCategory";
            string description = "NewCagetoryDescription";

            CategoryInDto categoryNew = new CategoryInDto
            {
                CategoryId  = categoryId,
                Title       = title,
                Description = description
            };

            int expectedCountAfterAdding = categoriesRepository.All().Count() + 1;
            await categoryService.AddCategoryAsync(categoryNew);

            int actualCountAfterAdding = categoriesRepository.All().Count();

            Assert.Equal(expectedCountAfterAdding, actualCountAfterAdding);
            var categoryAdded = categoriesRepository.All().Last();

            Assert.Equal(categoryId, categoryAdded.CategoryId);
            Assert.Equal(title, categoryAdded.Title);
            Assert.Equal(description, categoryAdded.Description);
        }
 public ActionResult <Participant[]> Get()
 {
     return(_datastore.All().ToArray());
 }
Exemplo n.º 14
0
 public IEnumerable <RentPoint> Ask(EmptyCriterion criterion)
 {
     return(_repository.All());
 }
Exemplo n.º 15
0
 public IEnumerable <CommentTable> GetAll()
 {
     return(repo.All());
 }
Exemplo n.º 16
0
 public virtual IEnumerable <TEntity> All(bool @readonly = false)
 {
     return(_repository.All(@readonly));
 }
        //
        // GET: /Stores

        public ViewResult Index(int?page, int?pageSize, string sortBy, bool?sortDesc)
        {
            // Defaults
            if (!page.HasValue)
            {
                page = 1;
            }
            if (!pageSize.HasValue)
            {
                pageSize = 10;
            }

            IQueryable <Store> query = repository.All();

            query = query.OrderBy(x => x.Id);

            // Paging
            int pageCount = (int)((query.Count() + pageSize - 1) / pageSize);

            if (page > 1)
            {
                query = query.Skip((page.Value - 1) * pageSize.Value);
            }
            query = query.Take(pageSize.Value);
            if (page > 1)
            {
                ViewBag.Page = page.Value;
            }
            if (pageSize != 10)
            {
                ViewBag.PageSize = pageSize.Value;
            }
            if (pageCount > 1)
            {
                int       currentPage  = page.Value;
                const int visiblePages = 5;
                const int pageDelta    = 2;
                List <Tuple <string, bool, int> > paginationData = new List <Tuple <string, bool, int> >();           // text, enabled, page index
                paginationData.Add(new Tuple <string, bool, int>("Prev", currentPage > 1, currentPage - 1));
                if (pageCount <= visiblePages * 2)
                {
                    for (int i = 1; i <= pageCount; i++)
                    {
                        paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                    }
                }
                else
                {
                    if (currentPage < visiblePages)
                    {
                        // 12345..10
                        for (int i = 1; i <= visiblePages; i++)
                        {
                            paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                        }
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        paginationData.Add(new Tuple <string, bool, int>(pageCount.ToString(), true, pageCount));
                    }
                    else if (currentPage > pageCount - (visiblePages - 1))
                    {
                        // 1..678910
                        paginationData.Add(new Tuple <string, bool, int>("1", true, 1));
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        for (int i = pageCount - (visiblePages - 1); i <= pageCount; i++)
                        {
                            paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                        }
                    }
                    else
                    {
                        // 1..34567..10
                        paginationData.Add(new Tuple <string, bool, int>("1", true, 1));
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        for (int i = currentPage - pageDelta, count = currentPage + pageDelta; i <= count; i++)
                        {
                            paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                        }
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        paginationData.Add(new Tuple <string, bool, int>(pageCount.ToString(), true, pageCount));
                    }
                }
                paginationData.Add(new Tuple <string, bool, int>("Next", currentPage < pageCount, currentPage + 1));
                ViewBag.PaginationData = paginationData;
            }

            // Sorting
            if (!string.IsNullOrEmpty(sortBy))
            {
                bool ascending = !sortDesc.HasValue || !sortDesc.Value;
                if (sortBy == "Name")
                {
                    query = OrderBy(query, x => x.Name, ascending);
                }
                if (sortBy == "Id")
                {
                    query = OrderBy(query, x => x.Id, ascending);
                }
                if (sortBy == "Active")
                {
                    query = OrderBy(query, x => x.Active, ascending);
                }
                ViewBag.SortBy = sortBy;
                if (sortDesc != null && sortDesc.Value)
                {
                    ViewBag.SortDesc = sortDesc.Value;
                }
            }

            ViewBag.Entities = query.ToList();
            return(View());
        }
Exemplo n.º 18
0
 public IQueryable <History> AllItems()
 {
     return(_sonicRepo.All <History>());
 }
Exemplo n.º 19
0
 public List <CollectedItem> All()
 {
     return(_repository.All());
 }
 public IEnumerable <Blog> Get()
 {
     return(_blogRepository.All().ToList());
 }
Exemplo n.º 21
0
        //
        // GET: /ItemStores

        public ViewResult Index(int?page, int?pageSize, string sortBy, bool?sortDesc, long?ItemId, int?StoreId)
        {
            // Defaults
            if (!page.HasValue)
            {
                page = 1;
            }
            if (!pageSize.HasValue)
            {
                pageSize = 10;
            }

            IQueryable <ItemStore> query = repository.All();

            query = query.OrderBy(x => x.Id);
            // Filtering
            List <SelectListItem> selectList;

            if (ItemId != null)
            {
                query          = query.Where(x => x.ItemId == ItemId);
                ViewBag.ItemId = ItemId;
            }
            selectList = new List <SelectListItem>();
            selectList.Add(new SelectListItem()
            {
                Text = null, Value = null, Selected = ItemId == null
            });
            selectList.AddRange(ItemRepository.All().ToList().Select(x => new SelectListItem()
            {
                Text = x.EnDescription.ToString(), Value = x.Id.ToString(), Selected = ItemId != null && ItemId == x.Id
            }));
            ViewBag.Items        = selectList;
            ViewBag.SelectedItem = selectList.Where(x => x.Selected).Select(x => x.Text).FirstOrDefault();
            if (StoreId != null)
            {
                query           = query.Where(x => x.StoreId == StoreId);
                ViewBag.StoreId = StoreId;
            }
            selectList = new List <SelectListItem>();
            selectList.Add(new SelectListItem()
            {
                Text = null, Value = null, Selected = StoreId == null
            });
            selectList.AddRange(StoreRepository.All().ToList().Select(x => new SelectListItem()
            {
                Text = x.Name.ToString(), Value = x.Id.ToString(), Selected = StoreId != null && StoreId == x.Id
            }));
            ViewBag.Stores        = selectList;
            ViewBag.SelectedStore = selectList.Where(x => x.Selected).Select(x => x.Text).FirstOrDefault();

            // Paging
            int pageCount = (int)((query.Count() + pageSize - 1) / pageSize);

            if (page > 1)
            {
                query = query.Skip((page.Value - 1) * pageSize.Value);
            }
            query = query.Take(pageSize.Value);
            if (page > 1)
            {
                ViewBag.Page = page.Value;
            }
            if (pageSize != 10)
            {
                ViewBag.PageSize = pageSize.Value;
            }
            if (pageCount > 1)
            {
                int       currentPage  = page.Value;
                const int visiblePages = 5;
                const int pageDelta    = 2;
                List <Tuple <string, bool, int> > paginationData = new List <Tuple <string, bool, int> >();           // text, enabled, page index
                paginationData.Add(new Tuple <string, bool, int>("Prev", currentPage > 1, currentPage - 1));
                if (pageCount <= visiblePages * 2)
                {
                    for (int i = 1; i <= pageCount; i++)
                    {
                        paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                    }
                }
                else
                {
                    if (currentPage < visiblePages)
                    {
                        // 12345..10
                        for (int i = 1; i <= visiblePages; i++)
                        {
                            paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                        }
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        paginationData.Add(new Tuple <string, bool, int>(pageCount.ToString(), true, pageCount));
                    }
                    else if (currentPage > pageCount - (visiblePages - 1))
                    {
                        // 1..678910
                        paginationData.Add(new Tuple <string, bool, int>("1", true, 1));
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        for (int i = pageCount - (visiblePages - 1); i <= pageCount; i++)
                        {
                            paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                        }
                    }
                    else
                    {
                        // 1..34567..10
                        paginationData.Add(new Tuple <string, bool, int>("1", true, 1));
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        for (int i = currentPage - pageDelta, count = currentPage + pageDelta; i <= count; i++)
                        {
                            paginationData.Add(new Tuple <string, bool, int>(i.ToString(), true, i));
                        }
                        paginationData.Add(new Tuple <string, bool, int>("...", false, -1));
                        paginationData.Add(new Tuple <string, bool, int>(pageCount.ToString(), true, pageCount));
                    }
                }
                paginationData.Add(new Tuple <string, bool, int>("Next", currentPage < pageCount, currentPage + 1));
                ViewBag.PaginationData = paginationData;
            }

            // Sorting
            if (!string.IsNullOrEmpty(sortBy))
            {
                bool ascending = !sortDesc.HasValue || !sortDesc.Value;
                if (sortBy == "Id")
                {
                    query = OrderBy(query, x => x.Id, ascending);
                }
                if (sortBy == "MinLimit")
                {
                    query = OrderBy(query, x => x.MinLimit, ascending);
                }
                if (sortBy == "MaxLimit")
                {
                    query = OrderBy(query, x => x.MaxLimit, ascending);
                }
                if (sortBy == "Quantity")
                {
                    query = OrderBy(query, x => x.Quantity, ascending);
                }
                if (sortBy == "ItemId")
                {
                    query = OrderBy(query, x => x.ItemId, ascending);
                }
                if (sortBy == "StoreId")
                {
                    query = OrderBy(query, x => x.StoreId, ascending);
                }
                ViewBag.SortBy = sortBy;
                if (sortDesc != null && sortDesc.Value)
                {
                    ViewBag.SortDesc = sortDesc.Value;
                }
            }

            ViewBag.Entities = query.ToList();
            return(View());
        }
        public IEnumerable <User> getAllUsers()
        {
            var y = (from b in _users.All() select b).ToList();

            return(y);
        }
 public void WhenSystemRequestsAllRecords()
 {
     _result = _repository.All();
 }
Exemplo n.º 24
0
 public ActionResult Index()
 {
     return(View(presentations.All()));
 }
 public IQueryable <Genre> GetAllGenres()
 {
     return(genres.All());
 }
Exemplo n.º 26
0
 public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                    Yupi.Protocol.IRouter router)
 {
     router.GetComposer <FlatCategoriesMessageComposer>()
     .Compose(session, NavigatorRepository.All().ToList(), session.Info.Rank);
 }
Exemplo n.º 27
0
 public IActionResult Get()
 {
     return(Ok(_customerRepository.All()));
 }
Exemplo n.º 28
0
 public IActionResult GetAll(long id)
 {
     return(Ok(_repository.All()));
 }
Exemplo n.º 29
0
        private static void ClearDatabase(IRepository<News> repository)
        {
            foreach (var news in repository.All())
            {
                repository.Delete(news.Id);
            }

            repository.SaveChanges();
        }
Exemplo n.º 30
0
 private User GetUserByUsername(string username)
 {
     return(repo.All <User>().FirstOrDefault(u => u.Username == username));
 }
Exemplo n.º 31
0
 public List <Portfolio> GetList()
 {
     return(_repository.All <Portfolio>().ToList());
 }
Exemplo n.º 32
0
        public async Task <ICollection <TransactionViewModel> > SearchTransactionAsync(string username, int?min, int?max, ICollection <string> types, string sortProp, bool descending = false)
        {
            IQueryable <Transaction> transactions = transactionRepo.All()
                                                    .Include(tr => tr.Balance)
                                                    .ThenInclude(b => b.User)
                                                    .Include(tr => tr.Type);

            if (username != null)
            {
                transactions = transactions.Where(tr => tr.Balance.User.UserName.ToLower().Contains(username.ToLower()));
            }

            if (min == null && max != null)
            {
                transactions = transactions.Where(tr => Math.Abs(tr.Amount) < (decimal)max);
            }
            if (max == null && min != null)
            {
                transactions = transactions.Where(tr => Math.Abs(tr.Amount) > (decimal)min);
            }
            if (min != null && max != null)
            {
                if (max < min)
                {
                    return(new List <TransactionViewModel>());
                }
                transactions = transactions.Where(tr => tr.Amount > min && tr.Amount < max);
            }
            if (!(types is null) && types.Count != 0)
            {
                transactions = transactions.Where(tr => types.Any(type => tr.Type.Name.ToLower() == type.ToLower()));
            }

            if (!(sortProp is null))
            {
                if (descending)
                {
                    if (sortProp == "Username")
                    {
                        transactions = transactions.OrderByDescending(tr => tr.Balance.User);
                    }
                    else
                    {
                        transactions = transactions.OrderByDescending(tr => tr.GetType().GetProperty(sortProp).GetValue(tr, null));
                    }
                }
                else
                {
                    if (sortProp == "Username")
                    {
                        transactions = transactions.OrderByDescending(tr => tr.Balance.User);
                    }
                    else
                    {
                        transactions = transactions.OrderBy(tr => tr.GetType().GetProperty(sortProp).GetValue(tr, null));
                    }
                }
            }

            var foundTrnasaciton = await transactions.ToListAsync();

            return(mappingProvider.MapTo <ICollection <TransactionViewModel> >(foundTrnasaciton));
        }
Exemplo n.º 33
0
 public List <Post> GetPosts() => repository.All();
 public IEnumerable <PersonaViewModel> GetAll()
 {
     return(mapper.Map <IEnumerable <PersonaViewModel> >(repository.All()).OrderBy(x => x.Name));
 }
Exemplo n.º 35
0
 protected bool CanDeleteUser(User user, IRepository repository)
 {
     var results = repository.All<MatchResult>().Any(r => r.Player.Id == user.Id);
       return !results;
 }