public ActionResult LatestBoutique()
        {
            // var vendors2 = _vendorService.GetAllVendors()
            var vendors = _vendorService.GetAllVendorsByDateRange(datefromUtc: DateTime.Now.AddMonths(-6), dateToUtc: DateTime.Now);

            var selectedvendors = vendors.OrderBy(v => Guid.NewGuid()).ToList().Take(12);

            var shops = new List<VendorModel>();
            foreach (var vendor in selectedvendors)
            {
                var vendorModel = new VendorModel
                {
                    Id = vendor.Id,
                    Name = vendor.GetLocalized(x => x.Name),
                    Description = vendor.GetLocalized(x => x.Description),
                    MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                    MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                    MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                    SeName = vendor.GetSeName(),
                    ImageUrl = _pictureService.GetPictureUrl(vendor.PictureId, 200),
                    ImageUrl2 = vendor.PictureId2 > 0 ? _pictureService.GetPictureUrl(vendor.PictureId2, 200) : _pictureService.GetPictureUrl(vendor.PictureId, 200)
                };

                shops.Add(vendorModel);

            }

            return View("_LatestBoutique", shops);
        }
        public ActionResult LatestBoutique()
        {
            var vendors = _vendorService.GetAllVendors();
            var customers = _customerService.GetAllCustomers(createdFromUtc: DateTime.Now.AddMonths(-2), createdToUtc: DateTime.Now);
            var shops = new List<VendorModel>();
            foreach (var c in customers)
            {
                if(c.VendorId>0)
                {

                    var vendor = _vendorService.GetVendorById(c.VendorId);
                    var vendorModel = new VendorModel
                    {
                        Id = vendor.Id,
                        Name = vendor.GetLocalized(x => x.Name),
                        Description = vendor.GetLocalized(x => x.Description),
                        MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                        MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                        MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                        SeName = vendor.GetSeName(),                       
                        ImageUrl = _pictureService.GetPictureUrl(vendor.PictureId, 200)
                    };
                    shops.Add(vendorModel);
                }
                
            }

            return View("_LatestBoutique", shops);
        }
Example #3
0
        public ActionResult VendorAll()
        {
            //we don't allow viewing of vendors if "vendors" block is hidden
            if (_vendorSettings.VendorsBlockItemsToDisplay == 0)
                return RedirectToRoute("HomePage");

            var model = new List<VendorModel>();
            var vendors = _vendorService.GetAllVendors();
            foreach (var vendor in vendors)
            {
                var vendorModel = new VendorModel()
                {
                    Id = vendor.Id,
                    Name = vendor.GetLocalized(x => x.Name),
                    Description = vendor.GetLocalized(x => x.Description),
                    MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                    MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                    MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                    SeName = vendor.GetSeName(),
                };
                model.Add(vendorModel);
            }

            return View(model);
        }
Example #4
0
        public ActionResult Vendor(int vendorId, CatalogPagingFilteringModel command)
        {
            var vendor = _vendorService.GetVendorById(vendorId);
            if (vendor == null || vendor.Deleted || !vendor.Active)
                return InvokeHttp404();

            //Vendor is active?
            if (!vendor.Active)
                return InvokeHttp404();

            //'Continue shopping' URL
            _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer,
                SystemCustomerAttributeNames.LastContinueShoppingPage,
                _webHelper.GetThisPageUrl(false),
                _storeContext.CurrentStore.Id);
            
            var model = new VendorModel()
            {
                Id = vendor.Id,
                Name = vendor.GetLocalized(x => x.Name),
                Description = vendor.GetLocalized(x => x.Description),
                MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                SeName = vendor.GetSeName(),
            };



            //sorting
            PrepareSortingOptions(model.PagingFilteringContext, command);
            //view mode
            PrepareViewModes(model.PagingFilteringContext, command);
            //page size
            PreparePageSizeOptions(model.PagingFilteringContext, command,
                vendor.AllowCustomersToSelectPageSize,
                vendor.PageSizeOptions,
                vendor.PageSize);

            //products
            IList<int> filterableSpecificationAttributeOptionIds = null;
            var products = _productService.SearchProducts(out filterableSpecificationAttributeOptionIds, true,
                vendorId: vendor.Id,
                storeId: _storeContext.CurrentStore.Id,
                visibleIndividuallyOnly: true,
                orderBy: (ProductSortingEnum)command.OrderBy,
                pageIndex: command.PageNumber - 1,
                pageSize: command.PageSize);
            model.Products = PrepareProductOverviewModels(products).ToList();

            model.PagingFilteringContext.LoadPagedList(products);

            return View(model);
        }
        public ActionResult VendorAll()
        {
            //we don't allow viewing of vendors if "vendors" block is hidden
            if (_vendorSettings.VendorsBlockItemsToDisplay == 0)
                return RedirectToRoute("HomePage");

            var model = new List<VendorModel>();
            var vendors = _vendorService.GetAllVendors();
            foreach (var vendor in vendors)
            {
                var vendorModel = new VendorModel
                {
                    Id = vendor.Id,
                    Name = vendor.GetLocalized(x => x.Name),
                    Description = vendor.GetLocalized(x => x.Description),
                    MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                    MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                    MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                    SeName = vendor.GetSeName(),
                    AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors
                };
                //prepare picture model
                int pictureSize = _mediaSettings.VendorThumbPictureSize;
                var pictureCacheKey = string.Format(ModelCacheEventConsumer.VENDOR_PICTURE_MODEL_KEY, vendor.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id);
                vendorModel.PictureModel = _cacheManager.Get(pictureCacheKey, () =>
                {
                    var picture = _pictureService.GetPictureById(vendor.PictureId);
                    var pictureModel = new PictureModel
                    {
                        FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
                        ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize),
                        Title = string.Format(_localizationService.GetResource("Media.Vendor.ImageLinkTitleFormat"), vendorModel.Name),
                        AlternateText = string.Format(_localizationService.GetResource("Media.Vendor.ImageAlternateTextFormat"), vendorModel.Name)
                    };
                    return pictureModel;
                });
                model.Add(vendorModel);
            }

            return View(model);
        }
Example #6
0
        //add by hz
        //vendor
        public static VendorModel ToModel(this Vendor entity)
        {
            if (entity == null)
                return null;

            var model = new VendorModel()
            {
                Id = entity.Id,
                Name = entity.GetLocalized(x => x.Name),
                Description = entity.GetLocalized(x => x.Description),
                MetaKeywords = entity.GetLocalized(x => x.MetaKeywords),
                MetaDescription = entity.GetLocalized(x => x.MetaDescription),
                MetaTitle = entity.GetLocalized(x => x.MetaTitle),
                SeName = entity.GetSeName(),
            };
            return model;
        }
        public ActionResult HomepageVenderProducts(int? productThumbPictureSize, CatalogPagingFilteringModel command)
        {

            //IList<int> filterableSpecificationAttributeOptionIds;
            //var products = _productService.SearchProducts(out filterableSpecificationAttributeOptionIds, true,
            //    vendorId: vendor.Id,
            //    storeId: _storeContext.CurrentStore.Id,
            //    visibleIndividuallyOnly: true,
            //    orderBy: (ProductSortingEnum)command.OrderBy,
            //    pageIndex: command.PageNumber - 1,
            //    pageSize: command.PageSize);
            //var models = PrepareProductOverviewModels(products).ToList();

            var model = new List<VendorModel>();
            var vendors = _vendorService.GetAllVendors();

            foreach (var vendor in vendors.Where(v => v.ShowOnHomePage))
            {



                var vendorModel = new VendorModel
                {
                    Id = vendor.Id,
                    Name = vendor.GetLocalized(x => x.Name),
                    Description = vendor.GetLocalized(x => x.Description),
                    MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                    MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                    MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                    SeName = vendor.GetSeName(),
                    AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors
                };

                PrepareSortingOptions(vendorModel.PagingFilteringContext, command);
                //view mode
                PrepareViewModes(vendorModel.PagingFilteringContext, command);
                //page size
                PreparePageSizeOptions(vendorModel.PagingFilteringContext, command,
                    vendor.AllowCustomersToSelectPageSize,
                    vendor.PageSizeOptions,
                    vendor.PageSize);

                IList<int> filterableSpecificationAttributeOptionIds;
                var products = _productService.SearchProducts(out filterableSpecificationAttributeOptionIds, true,
                    vendorId: vendor.Id,
                    storeId: _storeContext.CurrentStore.Id,
                    visibleIndividuallyOnly: true,
                    orderBy: (ProductSortingEnum)command.OrderBy,
                    pageIndex: command.PageNumber - 1,
                    pageSize: command.PageSize);
                vendorModel.Products = PrepareProductOverviewModels(products).ToList();



                model.Add(vendorModel);
            }

            return PartialView(model);



        }
        public ActionResult BoutiqueShops()
        {
            var vendors = _vendorService.GetAllVendors();
            var shops = new List<VendorModel>();
            foreach (var vendor in vendors)
            {
                var vendorModel = new VendorModel
                {
                    Id = vendor.Id,
                    Name = vendor.GetLocalized(x => x.Name),
                    Description = vendor.GetLocalized(x => x.Description),
                    MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                    MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                    MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                    SeName = vendor.GetSeName(),
                    AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors,
                    ImageUrl = _pictureService.GetPictureUrl(vendor.PictureId,200)
                };
                shops.Add(vendorModel);
            }

            return View(shops);
        }
        public ActionResult VendorAll()
        {
            //we don't allow viewing of vendors if "vendors" block is hidden
            if (_vendorSettings.VendorsBlockItemsToDisplay == 0)
                return RedirectToRoute("HomePage");

            var model = new List<VendorModel>();
            var vendors = _vendorService.GetAllVendors();
            foreach (var vendor in vendors)
            {
                var vendorModel = new VendorModel()
                {
                    Id = vendor.Id,
                    Name = vendor.Name,
                    Description = vendor.Description,
                    SeName = SeoExtensions.GetSeName(vendor.Name)
                };
                model.Add(vendorModel);
            }

            return View(model);
        }
        public ActionResult Vendor(int vendorId, CatalogPagingFilteringModel command)
        {
            var vendor = _vendorService.GetVendorById(vendorId);
            if (vendor == null || vendor.Deleted)
                return InvokeHttp404();

            //Vendor is active?
            if (!vendor.Active)
                return InvokeHttp404();

            //'Continue shopping' URL
            _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer,
                SystemCustomerAttributeNames.LastContinueShoppingPage,
                _webHelper.GetThisPageUrl(false),
                _storeContext.CurrentStore.Id);

            if (command.PageNumber <= 0) command.PageNumber = 1;

            var model = new VendorModel()
            {
                Id = vendor.Id,
                Name = vendor.Name,
                Description = vendor.Description,
                SeName = SeoExtensions.GetSeName(vendor.Name)
            };

            //sorting
            model.PagingFilteringContext.AllowProductSorting = _catalogSettings.AllowProductSorting;
            if (model.PagingFilteringContext.AllowProductSorting)
            {
                foreach (ProductSortingEnum enumValue in Enum.GetValues(typeof(ProductSortingEnum)))
                {
                    var currentPageUrl = _webHelper.GetThisPageUrl(true);
                    var sortUrl = _webHelper.ModifyQueryString(currentPageUrl, "orderby=" + ((int)enumValue).ToString(), null);

                    var sortValue = enumValue.GetLocalizedEnum(_localizationService, _workContext);
                    model.PagingFilteringContext.AvailableSortOptions.Add(new SelectListItem()
                    {
                        Text = sortValue,
                        Value = sortUrl,
                        Selected = enumValue == (ProductSortingEnum)command.OrderBy
                    });
                }
            }

            //view mode
            model.PagingFilteringContext.AllowProductViewModeChanging = _catalogSettings.AllowProductViewModeChanging;
            var viewMode = !string.IsNullOrEmpty(command.ViewMode)
                ? command.ViewMode
                : _catalogSettings.DefaultViewMode;
            if (model.PagingFilteringContext.AllowProductViewModeChanging)
            {
                var currentPageUrl = _webHelper.GetThisPageUrl(true);
                //grid
                model.PagingFilteringContext.AvailableViewModes.Add(new SelectListItem()
                {
                    Text = _localizationService.GetResource("Vendors.ViewMode.Grid"),
                    Value = _webHelper.ModifyQueryString(currentPageUrl, "viewmode=grid", null),
                    Selected = viewMode == "grid"
                });
                //list
                model.PagingFilteringContext.AvailableViewModes.Add(new SelectListItem()
                {
                    Text = _localizationService.GetResource("Vendors.ViewMode.List"),
                    Value = _webHelper.ModifyQueryString(currentPageUrl, "viewmode=list", null),
                    Selected = viewMode == "list"
                });
            }

            //page size
            model.PagingFilteringContext.AllowCustomersToSelectPageSize = false;
            if (_vendorSettings.AllowCustomersToSelectPageSize && _vendorSettings.PageSizeOptions != null)
            {
                var pageSizes = _vendorSettings.PageSizeOptions.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                if (pageSizes.Any())
                {
                    // get the first page size entry to use as the default (manufacturer page load) or if customer enters invalid value via query string
                    if (command.PageSize <= 0 || !pageSizes.Contains(command.PageSize.ToString()))
                    {
                        int temp = 0;

                        if (int.TryParse(pageSizes.FirstOrDefault(), out temp))
                        {
                            if (temp > 0)
                            {
                                command.PageSize = temp;
                            }
                        }
                    }

                    var currentPageUrl = _webHelper.GetThisPageUrl(true);
                    var sortUrl = _webHelper.ModifyQueryString(currentPageUrl, "pagesize={0}", null);
                    sortUrl = _webHelper.RemoveQueryString(sortUrl, "pagenumber");

                    foreach (var pageSize in pageSizes)
                    {
                        int temp = 0;
                        if (!int.TryParse(pageSize, out temp))
                        {
                            continue;
                        }
                        if (temp <= 0)
                        {
                            continue;
                        }

                        model.PagingFilteringContext.PageSizeOptions.Add(new SelectListItem()
                        {
                            Text = pageSize,
                            Value = String.Format(sortUrl, pageSize),
                            Selected = pageSize.Equals(command.PageSize.ToString(), StringComparison.InvariantCultureIgnoreCase)
                        });
                    }

                    model.PagingFilteringContext.PageSizeOptions = model.PagingFilteringContext.PageSizeOptions.OrderBy(x => int.Parse(x.Text)).ToList();

                    if (model.PagingFilteringContext.PageSizeOptions.Any())
                    {
                        model.PagingFilteringContext.PageSizeOptions = model.PagingFilteringContext.PageSizeOptions.OrderBy(x => int.Parse(x.Text)).ToList();
                        model.PagingFilteringContext.AllowCustomersToSelectPageSize = true;

                        if (command.PageSize <= 0)
                        {
                            command.PageSize = int.Parse(model.PagingFilteringContext.PageSizeOptions.FirstOrDefault().Text);
                        }
                    }
                }
            }
            else
            {
                //customer is not allowed to select a page size
                command.PageSize = _vendorSettings.PageSize;
            }

            if (command.PageSize <= 0) command.PageSize = _vendorSettings.PageSize;

            //products
            IList<int> filterableSpecificationAttributeOptionIds = null;
            var products = _productService.SearchProducts(out filterableSpecificationAttributeOptionIds, true,
                vendorId: vendor.Id,
                storeId: _storeContext.CurrentStore.Id,
                visibleIndividuallyOnly: true,
                featuredProducts: null,
                priceMin: null,
                priceMax: null,
                orderBy: (ProductSortingEnum)command.OrderBy,
                pageIndex: command.PageNumber - 1,
                pageSize: command.PageSize);
            model.Products = PrepareProductOverviewModels(products).ToList();

            model.PagingFilteringContext.LoadPagedList(products);
            model.PagingFilteringContext.ViewMode = viewMode;

            return View(model);
        }
        public ActionResult BoutiqueShopDetails(int vendorId, string s, string q, int? pageNo)
        {
            Expression<Func<Product, bool>> predicate = x => x.VendorId == vendorId && x.Published && x.ProductPictures.Count > 0;

            if (!string.IsNullOrWhiteSpace(q))
            {
                predicate = x => x.VendorId == vendorId && x.Published && x.Name.Equals(q);
            }

            IList<Product> products = new List<Product>();

            if (string.IsNullOrWhiteSpace(s) || s == "0")
            {
                products = _productService.GetAllProducts(predicate , x => x.StockQuantity == 0 ? 1 : 0 , x => x.DisplayOrder);
            }
            else if (s == "1")
            {
                products = _productService.GetAllProducts(predicate, x => x.CreatedOnUtc, false);
            }
            else if (s == "2")
            {
                products = _productService.GetAllProducts(predicate, x => x.Name);
            }

            ProductOverviewModel model = new ProductOverviewModel();
            var pageSize = _catalogSettings.SearchPageProductsPerPage;
            if (pageNo == null)
                pageNo = 1;

            int skip = (pageNo.Value - 1) * pageSize;

            model.Id = vendorId;

            var vendor = _vendorService.GetVendorById(vendorId);

            ViewBag.PageCount = (products.Count() % pageSize) > 1 ? (1 + (products.Count() / pageSize)) : Convert.ToInt32((products.Count() / pageSize));

            products = products.Skip(skip).Take(pageSize).ToList();

            var productOverviewModel = PrepareProductOverviewModelsIB(products).ToList();

            var firstCustomer = _customerService
                .GetAllCustomers(vendorId: vendor.Id)
                .OrderBy(v => v.CreatedOnUtc)
                .FirstOrDefault();

            var phone = string.Empty;
            if (firstCustomer != null)
            {
                var attribs = _genericAttributeService.GetAttributesForEntity(firstCustomer.Id, "Customer");
                var phoneAttribute = attribs.FirstOrDefault(a => a.Key == SystemCustomerAttributeNames.Phone);
                if (phoneAttribute != null)
                {
                    phone = phoneAttribute.Value;
                }
            }

            var vendorModel = new VendorModel
            {
                Id = vendor.Id,
                ImageUrl = _pictureService.GetPictureUrl(vendor.PictureId),
                Name = vendor.Name,
                SeName = vendor.GetSeName(),
                Description = vendor.Description,
                Coutry = vendor.Country,
                City = vendor.City,
                Web = vendor.Web,
                Products = productOverviewModel,
                PhoneOfTheFirstCustomer = phone
            };

            model.Vendor = vendorModel;

            return View(model);
        }
        public ActionResult BoutiqueShops(int?pageNo,string q="",string s="")
        {
            //var q="";

            //if (f["q"] != null)
            //    q = f["q"].ToString();
            if (s == "")
                s="0";
            if (string.IsNullOrWhiteSpace(q))
                q = "";

            List<Vendor> vendors = _vendorService.GetAllVendors(name: q).ToList();
            if (s == "0")
                vendors = _vendorService.GetAllVendorsOrderByDate(name: q).ToList();
            else if(s=="1")
                vendors = vendors.OrderBy(v => v.Name).ToList();

            var pageSize = _catalogSettings.SearchPageProductsPerPage;

            if (pageNo == null)
                pageNo = 1;

            int skip = (pageNo.Value - 1) * pageSize;

            ViewBag.PageCount = (vendors.Count() % pageSize) > 1 ? (1 + (vendors.Count() / pageSize)) : Convert.ToInt32((vendors.Count() / pageSize));

            var lstvendors = vendors.Skip(skip).Take(pageSize).ToList();
            var shops = new List<VendorModel>();
            foreach (var vendor in lstvendors)
            {
                var vendorModel = new VendorModel
                {
                    Id = vendor.Id,
                    Name = vendor.GetLocalized(x => x.Name),
                    Description = vendor.GetLocalized(x => x.Description),
                    MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords),
                    MetaDescription = vendor.GetLocalized(x => x.MetaDescription),
                    MetaTitle = vendor.GetLocalized(x => x.MetaTitle),
                    SeName = vendor.GetSeName(),
                    AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors,
                    ImageUrl = _pictureService.GetPictureUrl(vendor.PictureId),
                    ImageUrl2 = vendor.PictureId2 > 0 ? _pictureService.GetPictureUrl(vendor.PictureId2) : _pictureService.GetPictureUrl(vendor.PictureId)
                };
                shops.Add(vendorModel);
            }

            return View(shops);
        }