Exemple #1
0
        public ActionResult Index()
        {
            ShopIndexViewModel model = new ShopIndexViewModel();

            model.series = SeriesService.GetSeries().ToArray();
            return(View(model));
        }
Exemple #2
0
        public ActionResult Index(int id = 1)
        {
            var page          = id;
            var allItemsCount = this.sellingItems
                                .GetAll()
                                .Count(x => x.SellerId == this.UserProfile.Id);
            var totalPages = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage);

            var items = this.sellingItems
                        .GetByUserId(this.UserProfile.Id)
                        .OrderByDescending(x => x.CreatedOn)
                        .Skip((page - 1) * ItemsPerPage)
                        .Take(ItemsPerPage)
                        .To <SellingItemViewModel>()
                        .ToList();

            var paginationModel = new PaginationViewModel()
            {
                CurrentPage = page,
                TotalPages  = totalPages,
                Path        = "/Users/SellingItems/Index/"
            };

            var model = new ShopIndexViewModel()
            {
                PaginationModel = paginationModel,
                ItemsForSale    = items
            };

            return(this.View(model));
        }
        public IActionResult Index(int id = 1)
        {
            if (id <= 0)
            {
                return(this.NotFound());
            }

            const int ItemsPerPage = 9;
            //var productsViewModel = new ProductsListViewModel
            //{
            //    ItemsPerPage = ItemsPerPage,
            //    PageNumber = id,
            //    ProductsCount = this.productsService.GetCount(),
            //    Products = this.productsService.GetAll<ProductInListViewModel>(id, ItemsPerPage),
            //};
            var categoriesViewModel = new CategoriesListViewModel
            {
                Categories = this.categoriesService.GetAll <CategoryInListViewModel>(),
            };
            var viewModel = new ShopIndexViewModel
            {
                //Products = productsViewModel,
                Categories = categoriesViewModel,
            };

            return(this.View("ShopIndex", viewModel));
        }
Exemple #4
0
        public IActionResult Index()
        {
            ShopIndexViewModel shopIndex = new ShopIndexViewModel
            {
                CategoryList = categoryRepository.GetCategoryList()
            };

            return(View(shopIndex));
        }
Exemple #5
0
        // GET: Shop
        public ActionResult Index(int?id, int?catId)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Market"));
            }
            ViewBag.storeId = id;
            var model = new ShopIndexViewModel {
                IsLeafDict = new Dictionary <Entities.Category, bool>(),
                Breadcrum  = new Dictionary <string, int>()
            };
            var store = db.Stores.FirstOrDefault(m => m.Id == id);

            if (store == null)
            {
                return(View("Error"));
            }
            model.Breadcrum.Add(store.Name, store.Id);
            if (catId == null)
            {
                model.Categories = db.Categories.OrderBy("Name")
                                   .Where(m => m.StoreId == id && m.IsBase == true).ToList();
            }
            else
            {
                var parentCat = db.Categories.FirstOrDefault(m => m.Id == catId);
                if (parentCat == null)
                {
                    return(View("Error"));
                }
                model.Breadcrum.Add(parentCat.Name, parentCat.Id);
                model.Categories = db.Categories.OrderBy("Name")
                                   .Where(m => m.CategoryId == catId).ToList();
            }
            foreach (var cat in model.Categories)
            {
                if (db.Categories.Where(m => m.CategoryId == cat.Id).ToList().Count == 0)
                {
                    model.IsLeafDict.Add(cat, true);
                }
                else
                {
                    model.IsLeafDict.Add(cat, false);
                }
            }
            ViewBag.Vendor = db.EcomUsers
                             .FirstOrDefault(m => m.Id == store.EcomUserId)
                             .ApplicationUserId;

            return(View(model));
        }
Exemple #6
0
        public async Task <IActionResult> ShopByMasterCategory(string mastercategory, int pageIndex = 1)
        {
            using var context = new EsramDbContext();
            ShopIndexViewModel vm = new ShopIndexViewModel();

            vm.Products = await context.Products.Where(x => x.Category.MasterCategory.Name == mastercategory).OrderByDescending(x => x.Id).Skip((pageIndex - 1) * 12).Take(12).ToListAsync();

            vm.MasterCategories = await context.MasterCategories.Include(x => x.Categories).OrderByDescending(x => x.Id).ToListAsync();

            ViewBag.MasterCategory = mastercategory;
            ViewBag.PageIndex      = pageIndex;
            ViewBag.PageCount      = Math.Ceiling(Convert.ToDouble(await context.Products.Where(x => x.Category.MasterCategory.Name == mastercategory).CountAsync()) / Convert.ToDouble(12));
            return(View("~/Views/Shop/Index.cshtml", vm));
        }
        public async Task <IActionResult> Index()
        {
            List <ShopItem>      items          = _repository.GetAllItems();
            List <ItemViewModel> itemViewModels = new List <ItemViewModel>();

            foreach (var item in items)
            {
                ItemViewModel itemViewModel = new ItemViewModel(item.Id, item.Name, item.Price);
                itemViewModels.Add(itemViewModel);
            }

            ShopIndexViewModel indexViewModel = new ShopIndexViewModel(itemViewModels);

            return(View(indexViewModel));
        }
        public async Task <IActionResult> ItemsByCategory(Guid categoryId)
        {
            List <ItemViewModel> itemViewModels = new List <ItemViewModel>();

            ShopItemCategory category = _repository.GetCategoryById(categoryId);
            List <ShopItem>  items    = _repository.GetFilteredByCategory(category);

            foreach (var item in items)
            {
                ItemViewModel itemViewModel = new ItemViewModel(item.Id, item.Name, item.Price);
                itemViewModels.Add(itemViewModel);
            }

            ShopIndexViewModel filteredIndexViewModel = new ShopIndexViewModel(itemViewModels);

            return(View(filteredIndexViewModel));
        }
Exemple #9
0
        // GET: Dashboard/Shops
        public ActionResult Index(string SearchString, String city, double from = 0.0, double to = 0.0, int page = 1, int numberofDoor = 1)
        {
            var shops = db.Shops.OfType <Shop>()
                        .Where(w => w.Ad.User.Confirmed)
                        .Include(l => l.Ad);

            ViewBag.Views     = db.Views;
            ViewBag.Wishlists = db.Wishlists;
            if (!String.IsNullOrEmpty(SearchString))
            {
                shops = shops.Where(a => a.Ad.City.Name.ToUpper().Contains(SearchString.ToUpper()) ||
                                    a.Ad.AdDescribtion.ToUpper().Contains(SearchString.ToUpper()) ||
                                    a.Ad.AdTitle.ToUpper().Contains(SearchString.ToUpper()));
            }
            if (!String.IsNullOrEmpty(city))
            {
                shops = shops.Where(a => a.Ad.City.Name.ToUpper().Equals(city));
            }

            if (to >= from && to > 1 && from >= 0.0)
            {
                shops = shops.Where(a => a.Ad.AdPrice >= from && a.Ad.AdPrice <= to);
            }
            var cities = shops.Select(c => c.Ad.City.Name).Distinct();

            ViewBag.city = new SelectList(cities);
            //pagination steps
            int pageSize = 6;
            var pager    = new Pager(shops.Count(), page, pageSize);
            ShopIndexViewModel vModel = new ShopIndexViewModel()
            {
                Shops        = shops.OrderBy(a => a.Ad.AdPrice).Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize),
                Pager        = pager,
                SearchString = SearchString,
                City         = city,
                NumberofDoor = numberofDoor,
                From         = from,
                To           = to
            };

            return(View(vModel));
        }