public ReviewsController(IItemRepository repoItem, IStoreRepository repoStore, IOrderRepository repoOrd, ITopicOptionRepository repoTopi, ISellerRepository repoSell, IPersonRepository repoPers, IReviewRepository repoRev)
 {
     RepoItem  = repoItem ?? throw new ArgumentNullException(nameof(repoItem));
     RepoStore = repoStore ?? throw new ArgumentNullException(nameof(repoStore));
     RepoOrd   = repoOrd ?? throw new ArgumentNullException(nameof(repoOrd));
     RepoTopi  = repoTopi ?? throw new ArgumentNullException(nameof(repoTopi));
     RepoSell  = repoSell ?? throw new ArgumentNullException(nameof(repoSell));
     RepoPers  = repoPers ?? throw new ArgumentNullException(nameof(repoPers));
     RepoRev   = repoRev ?? throw new ArgumentNullException(nameof(repoRev));
 }
        public static ItemAnLogInViewModel Populate(IItemRepository repoItem, IStoreRepository repoStore, IOrderRepository repoOrd, ITopicOptionRepository repoTopi, ISellerRepository repoSell, IPersonRepository repoPers, IReviewRepository repoRev, IOrder order)
        {
            List <Domain.Model.Item> items     = repoItem.GetItemsByName();
            List <ItemViewModel>     realItems = new List <ItemViewModel>();

            foreach (var val in items)
            {
                if (val.StoreId == (repoPers.GetPeopleByName(order.Username).First(p => p.Username.ToLower() == order.Username.ToLower())).StoreId)
                {
                    if (!(val.OrderId == null || val.OrderId == 0))
                    {
                        continue;
                    }
                    if (order.itemsInOrder.Contains(val.Id))
                    {
                        continue;
                    }
                    realItems.Add(new ItemViewModel
                    {
                        ItemId          = val.Id,
                        ItemName        = val.Name,
                        ItemDescription = val.Description,
                        ItemPrice       = val.Price,
                        StoreName       = repoStore.GetStoreById(val.StoreId).Name,
                        OrderId         = val.OrderId,
                        SellerName      = repoSell.GetSellerById(val.SellerId).Name,
                        TopicName       = repoTopi.GetTopicById(val.TopicId).Topic
                    });
                }
            }

            var itemlogin = new ItemAnLogInViewModel
            {
                Items          = realItems,
                LogInViewModel = null,
                selectedItems  = new List <ItemViewModel>()
            };

            return(itemlogin);
        }
Example #3
0
 public ItemsController(IItemRepository repo, IStoreRepository repoStore, IOrderRepository repoOrd, ITopicOptionRepository repoTopi, ISellerRepository repoSell)
 {
     Repo      = repo ?? throw new ArgumentNullException(nameof(repo));
     RepoStore = repoStore ?? throw new ArgumentNullException(nameof(repoStore));
     RepoOrd   = repoOrd ?? throw new ArgumentNullException(nameof(repoOrd));
     RepoTopi  = repoTopi ?? throw new ArgumentNullException(nameof(repoTopi));
     RepoSell  = repoSell ?? throw new ArgumentNullException(nameof(repoSell));
 }
        public static ItemViewModel Suggest(IItemRepository repoItem, IStoreRepository repoStore, IOrderRepository repoOrd, ITopicOptionRepository repoTopi, ISellerRepository repoSell, IPersonRepository repoPers, IReviewRepository repoRev, IOrder order)
        {
            List <Domain.Model.Item> items     = repoItem.GetItemsByName();
            List <ItemViewModel>     realItems = new List <ItemViewModel>();

            foreach (var val in items)
            {
                if (val.StoreId == (repoPers.GetPeopleByName(order.Username).First(p => p.Username.ToLower() == order.Username.ToLower())).StoreId)
                {
                    if (!(val.OrderId == null || val.OrderId == 0))
                    {
                        continue;
                    }
                    if (order.itemsInOrder.Contains(val.Id))
                    {
                        continue;
                    }
                    realItems.Add(new ItemViewModel
                    {
                        ItemId          = val.Id,
                        ItemName        = val.Name,
                        ItemDescription = val.Description,
                        ItemPrice       = val.Price,
                        StoreName       = repoStore.GetStoreById(val.StoreId).Name,
                        OrderId         = val.OrderId,
                        SellerName      = repoSell.GetSellerById(val.SellerId).Name,
                        TopicName       = repoTopi.GetTopicById(val.TopicId).Topic
                    });
                }
            }

            Random rand = new Random();
            int    i    = rand.Next(0, realItems.Count);

            if (realItems.Count > 0)
            {
                return(realItems[i]);
            }
            return(null);
        }