Пример #1
0
        public ActionResult EditIB(int id)
        {
            if (_workContext.CurrentVendor == null || id != _workContext.CurrentVendor.Id)
            {
                return AccessDeniedView();
            }

            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)
                && !_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel))
                return AccessDeniedView();

            var vendor = _vendorService.GetVendorById(id);
            if (vendor == null || vendor.Deleted)
                //No vendor found with the specified id
                return RedirectToAction("List");

            var model = vendor.ToModel();
            //pictuere
            model.MainPicture = _pictureService.GetPictureById(model.PictureId);
            if (model.MainPicture != null)
            {
                var m = new VendorModel.VenddorPictureModel
                {

                    ProductId = model.MainPicture.Id,
                    PictureUrl = _pictureService.GetPictureUrl(model.MainPicture),
                    OverrideAltAttribute = model.MainPicture.AltAttribute,
                    OverrideTitleAttribute = model.MainPicture.TitleAttribute,
                    DisplayOrder = 1
                };
                model.MainPictureModel = m;
            }

            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name = vendor.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description = vendor.GetLocalized(x => x.Description, languageId, false, false);
                locale.MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords, languageId, false, false);
                locale.MetaDescription = vendor.GetLocalized(x => x.MetaDescription, languageId, false, false);
                locale.MetaTitle = vendor.GetLocalized(x => x.MetaTitle, languageId, false, false);
                locale.SeName = vendor.GetSeName(languageId, false, false);
            });
            //associated customer emails
            model.AssociatedCustomerEmails = _customerService
                    .GetAllCustomers(vendorId: vendor.Id)
                    .Select(c => c.Email)
                    .ToList();

            return View(model);
        }
Пример #2
0
        public List<VendorModel.VenddorProductModel> VendorProducts(int id,int pageIndex=0)
        {
           
            var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
            var products = _productService.SearchProducts(
              vendorId: id,             
              showHidden: true,
              pageIndex: pageIndex,
              pageSize: defaultGridPageSize
             
          );
            var model = new List<VendorModel.VenddorProductModel> ();
            foreach (var p in products)
	        {
		        var vpm = new VendorModel.VenddorProductModel();
                vpm.Id = id;
                vpm.ProductId=p.Id;
                vpm.ProductName = p.Name;
                var vpic = new VendorModel.VenddorPictureModel();
                var pic = _pictureService.GetPicturesByProductId(p.Id, 1).FirstOrDefault();
                var imgUrl = _pictureService.GetPictureUrl(pic, 200);
                vpic.PictureId = pic.Id;
                vpic.PictureUrl = imgUrl;
                vpm.ProductPicture = vpic;
                vpm.DisplayOrder = p.DisplayOrder;
                vpm.TotalCount = products.TotalCount;
                model.Add(vpm);
	        }

            var items = model.OrderBy(p=>p.DisplayOrder).ToList();
            return items;

        }
Пример #3
0
        public List<VendorModel.VenddorProductModel> VendorProducts(IList<Product> productList)
        {
            var model = new List<VendorModel.VenddorProductModel>();
            foreach (var p in productList)
            {
                var vpm = new VendorModel.VenddorProductModel();
                //vpm.Id = id;
                vpm.ProductId = p.Id;
                vpm.ProductName = p.Name;
                var vpic = new VendorModel.VenddorPictureModel();
                var pic = _pictureService.GetPicturesByProductId(p.Id, 1).FirstOrDefault();
                var imgUrl = _pictureService.GetPictureUrl(pic, 200);
                if (pic != null)
                    vpic.PictureId = pic.Id;
                vpic.PictureUrl = imgUrl;
                vpm.ProductPicture = vpic;
                vpm.DisplayOrder = p.DisplayOrder;
                // vpm.TotalCount = products.TotalCount;
                model.Add(vpm);
            }

            var items = model;
            return items;
        }
Пример #4
0
        public List<VendorModel.VenddorProductModel> VendorProducts(int id, int pageIndex = 0)
        {
            var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
            var products = _productService.GetAllProducts(product => product.VendorId == id
                , x => x.StockQuantity == 0 ? 1 : 0
                , x => x.DisplayOrder);

            var total = products.Count;
            products = products.Skip(defaultGridPageSize * pageIndex).Take(defaultGridPageSize).ToList();

            var model = new List<VendorModel.VenddorProductModel>();
            foreach (var p in products)
            {
                var vpm = new VendorModel.VenddorProductModel
                {
                    Id = id,
                    ProductId = p.Id,
                    ProductName = p.Name
                };
                var vpic = new VendorModel.VenddorPictureModel();
                var pic = _pictureService.GetPicturesByProductId(p.Id, 1).FirstOrDefault();
                var imgUrl = _pictureService.GetPictureUrl(pic, 200);
                if (pic != null)
                    vpic.PictureId = pic.Id;
                vpic.PictureUrl = imgUrl;
                vpm.ProductPicture = vpic;
                vpm.DisplayOrder = p.DisplayOrder;
                vpm.TotalCount = total;
                vpm.StockQuantity = p.StockQuantity;
                vpm.CanReOrder = p.StockQuantity > 0;
                model.Add(vpm);
            }

            var items = model.OrderBy(p => p.StockQuantity == 0 ? 1 : 0).ThenBy(v => v.DisplayOrder).ToList();
            return items;
        }
Пример #5
0
        public ActionResult MyHome(int id)
        {
            if (_workContext.CurrentVendor == null || id != _workContext.CurrentVendor.Id || !_workContext.CurrentVendor.Active)
            {
                return AccessDeniedView();
            }

            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)
                && !_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel))
                return AccessDeniedView();

            var vendor = _vendorService.GetVendorById(id);
            if (vendor == null || vendor.Deleted)
                //No vendor found with the specified id
                return RedirectToAction("List");

            var model = vendor.ToModel();
            //pictuere
            model.MainPicture = _pictureService.GetPictureById(model.PictureId);
            if (model.MainPicture != null)
            {
                var m = new VendorModel.VenddorPictureModel
                {

                    ProductId = model.MainPicture.Id,
                    PictureUrl = _pictureService.GetPictureUrl(model.MainPicture, 200),
                    OverrideAltAttribute = model.MainPicture.AltAttribute,
                    OverrideTitleAttribute = model.MainPicture.TitleAttribute,
                    DisplayOrder = 1
                };
                model.MainPictureModel = m;
            }

            model.MainPicture2 = _pictureService.GetPictureById(model.PictureId2);
            if (model.MainPicture2 != null)
            {
                var m = new VendorModel.VenddorPictureModel
                {

                    ProductId = model.MainPicture2.Id,
                    PictureUrl = _pictureService.GetPictureUrl(model.MainPicture2, 200),
                    OverrideAltAttribute = model.MainPicture2.AltAttribute,
                    OverrideTitleAttribute = model.MainPicture2.TitleAttribute,
                    DisplayOrder = 2
                };
                model.MainPictureModel2 = m;
            }

            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name = vendor.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description = vendor.GetLocalized(x => x.Description, languageId, false, false);
                locale.MetaKeywords = vendor.GetLocalized(x => x.MetaKeywords, languageId, false, false);
                locale.MetaDescription = vendor.GetLocalized(x => x.MetaDescription, languageId, false, false);
                locale.MetaTitle = vendor.GetLocalized(x => x.MetaTitle, languageId, false, false);
                locale.SeName = vendor.GetSeName(languageId, false, false);
            });
            //associated customer emails
            model.AssociatedCustomerEmails = _customerService
                    .GetAllCustomers(vendorId: vendor.Id)
                    .Select(c => c.Email)
                    .ToList();
            model.Products = VendorProducts(vendor.Id);
            model.DisplayActive = _workContext.CurrentCustomer.CustomerRoles.Any(r => r.SystemName == "Administrators");
            var phones = _genericAttributeService.GetAttributesForEntity(_workContext.CurrentCustomer.Id, "Customer");
            var phone = phones.FirstOrDefault(a => a.Key == SystemCustomerAttributeNames.Phone);
            if (phone != null)
                model.Phone = phone.Value;
            return View(model);
        }