/// <summary>
 /// Deletes a manufacturer
 /// </summary>
 /// <param name="manufacturer">Manufacturer</param>
 public virtual void DeleteManufacturer(Manufacturer manufacturer)
 {
     if (manufacturer == null)
         throw new ArgumentNullException("manufacturer");
     
     manufacturer.Deleted = true;
     UpdateManufacturer(manufacturer);
 }
        public void Can_save_and_load_manufacturer()
        {
            var manufacturer = new Manufacturer
            {
                Name = "Name",
                Description = "Description 1",
                MetaKeywords = "Meta keywords",
                MetaDescription = "Meta description",
                MetaTitle = "Meta title",
                PictureId = 3,
                PageSize = 4,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "4, 2, 8, 12",
                PriceRanges = "1-3;",
                Published = true,
                LimitedToStores = true,
                Deleted = false,
                DisplayOrder = 5,
                CreatedOnUtc = new DateTime(2010, 01, 01),
                UpdatedOnUtc = new DateTime(2010, 01, 02),
            };

            var fromDb = SaveAndLoadEntity(manufacturer);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Name");
            fromDb.Description.ShouldEqual("Description 1");
            fromDb.MetaKeywords.ShouldEqual("Meta keywords");
            fromDb.MetaDescription.ShouldEqual("Meta description");
            fromDb.PictureId.ShouldEqual(3);
            fromDb.PageSize.ShouldEqual(4);
            fromDb.AllowCustomersToSelectPageSize.ShouldEqual(true);
            fromDb.PageSizeOptions.ShouldEqual("4, 2, 8, 12");
            fromDb.PriceRanges.ShouldEqual("1-3;");
            fromDb.Published.ShouldEqual(true);
            fromDb.LimitedToStores.ShouldEqual(true);
            fromDb.Deleted.ShouldEqual(false);
            fromDb.DisplayOrder.ShouldEqual(5);
            fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
            fromDb.UpdatedOnUtc.ShouldEqual(new DateTime(2010, 01, 02));
        }
		public IList<Manufacturer> Manufacturers()
		{
			//pictures
			var sampleImagesPath = this._sampleImagesPath;

			var manufacturerTemplateInGridAndLines =
				this.ManufacturerTemplates().Where(pt => pt.ViewPath == "ManufacturerTemplate.ProductsInGridOrLines").FirstOrDefault();

			//var categoryTemplateInGridAndLines =
			//    this.CategoryTemplates().Where(pt => pt.Name == "Products in Grid or Lines").FirstOrDefault();

			//categories

			#region Apple

			var manufacturerApple = new Manufacturer
			{
				Name = "Apple",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0000746_apple_125.jpeg"), "image/pjpeg", GetSeName("Apple")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Apple

			#region Samsung

			var manufacturerSamsung = new Manufacturer
			{
				Name = "Samsung",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0000904_samsung_125.jpeg"), "image/pjpeg", GetSeName("Samsung")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Samsung

			#region LG

			var manufacturerLG = new Manufacturer
			{
				Name = "LG",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0000900_lg.jpeg"), "image/pjpeg", GetSeName("LG")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion LG

			#region HP

			var manufacturerHP = new Manufacturer
			{
				Name = "HP",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "HP_Logo_2012.svg.png"), "image/png", GetSeName("HP")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion HP

			#region Acer

			var manufacturerAcer = new Manufacturer
			{
				Name = "Acer",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "acer-logo.jpg"), "image/pjpeg", GetSeName("Acer")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Acer


			#region TrekStor

			var manufacturerTrekStor = new Manufacturer
			{
				Name = "TrekStor",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0000993_trekstor.jpeg"), "image/pjpeg", GetSeName("TrekStor")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion TrekStor

			#region Western Digital

			var manufacturerWesternDigital = new Manufacturer
			{
				Name = "Western Digital",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0000994_western-digital.jpeg"), "image/pjpeg", GetSeName("Western Digital")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Western Digital

			#region Dell

			var manufacturerDell = new Manufacturer
			{
				Name = "Dell",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "Dell_Logo.png"), "image/pjpeg", GetSeName("Dell")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Dell

			#region MSI

			var manufacturerMSI = new Manufacturer
			{
				Name = "MSI",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "msi_logo1.jpg"), "image/pjpeg", GetSeName("MSI")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion MSI

			#region Canon

			var manufacturerCanon = new Manufacturer
			{
				Name = "Canon",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0001085_canon.jpeg"), "image/pjpeg", GetSeName("Canon")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Canon

			#region Casio

			var manufacturerCasio = new Manufacturer
			{
				Name = "Casio",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0001086_casio.jpeg"), "image/pjpeg", GetSeName("Casio")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Casio

			#region Panasonic

			var manufacturerPanasonic = new Manufacturer
			{
				Name = "Panasonic",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0001087_panasonic.jpeg"), "image/pjpeg", GetSeName("Panasonic")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Panasonic

			#region BlackBerry

			var manufacturerBlackBerry = new Manufacturer
			{
				Name = "BlackBerry",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0000898_blackberry.jpeg"), "image/pjpeg", GetSeName("BlackBerry")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion BlackBerry

			#region HTC

			var manufacturerHTC = new Manufacturer
			{
				Name = "HTC",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0000899_htc.png"), "image/pjpeg", GetSeName("HTC")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion HTC

			#region Festina

			var manufacturerFestina = new Manufacturer
			{
				Name = "Festina",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0001591_festina.jpeg"), "image/pjpeg", GetSeName("Festina")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Festina

			#region Certina

			var manufacturerCertina = new Manufacturer
			{
				Name = "Certina",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "0001328_certina_125.jpeg"), "image/pjpeg", GetSeName("Certina")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Certina

			#region Sony

			var manufacturerSony = new Manufacturer
			{
				Name = "Sony",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "sony-logo.jpg"), "image/pjpeg", GetSeName("Sony")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Sony

			#region Ubisoft

			var manufacturerUbisoft = new Manufacturer
			{
				Name = "Ubisoft",
				ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
				PageSize = 12,
				AllowCustomersToSelectPageSize = true,
				PageSizeOptions = "12,18,36,72,150",
				Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "ubisoft-logo.jpg"), "image/pjpeg", GetSeName("Ubisoft")),
				Published = true,
				DisplayOrder = 2,
				CreatedOnUtc = DateTime.UtcNow,
				UpdatedOnUtc = DateTime.UtcNow
			};

			#endregion Ubisoft

			var entities = new List<Manufacturer>
			{
			  manufacturerApple,manufacturerSamsung,manufacturerLG,manufacturerTrekStor, manufacturerWesternDigital,manufacturerDell, manufacturerMSI,
			  manufacturerCanon, manufacturerCasio, manufacturerPanasonic, manufacturerBlackBerry, manufacturerHTC, manufacturerFestina, manufacturerCertina, 
			  manufacturerHP, manufacturerAcer, manufacturerSony, manufacturerUbisoft
			};

			this.Alter(entities);
			return entities;
		}
        private void PrepareManufacturerModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            model.AvailableStores = _storeService
                .GetAllStores()
                .Select(s => s.ToModel())
                .ToList();

            if (!excludeProperties)
            {
                if (manufacturer != null)
                {
                    model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(manufacturer);
                }
                else
                {
                    model.SelectedStoreIds = new int[0];
                }
            }

            if (manufacturer != null)
            {
                model.CreatedOn = _dateTimeHelper.ConvertToUserTime(manufacturer.CreatedOnUtc, DateTimeKind.Utc);
                model.UpdatedOn = _dateTimeHelper.ConvertToUserTime(manufacturer.UpdatedOnUtc, DateTimeKind.Utc);
            }
        }
 protected void UpdatePictureSeoNames(Manufacturer manufacturer)
 {
     var picture = _pictureService.GetPictureById(manufacturer.PictureId.GetValueOrDefault());
     if (picture != null)
         _pictureService.SetSeoFilename(picture.Id, _pictureService.GetPictureSeName(manufacturer.Name));
 }
        protected void UpdateLocales(Manufacturer manufacturer, ManufacturerModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(manufacturer,
                                                               x => x.Name,
                                                               localized.Name,
                                                               localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(manufacturer,
                                                           x => x.Description,
                                                           localized.Description,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(manufacturer,
                                                           x => x.MetaKeywords,
                                                           localized.MetaKeywords,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(manufacturer,
                                                           x => x.MetaDescription,
                                                           localized.MetaDescription,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(manufacturer,
                                                           x => x.MetaTitle,
                                                           localized.MetaTitle,
                                                           localized.LanguageId);

                //search engine name
                var seName = manufacturer.ValidateSeName(localized.SeName, localized.Name, false, localized.LanguageId);
                _urlRecordService.SaveSlug(manufacturer, seName, localized.LanguageId);
            }
        }
Пример #7
0
        public IList<Manufacturer> Manufacturers()
        {
            //pictures
            var sampleImagesPath = this._sampleImagesPath;

            var manufacturerTemplateInGridAndLines =
                this.ManufacturerTemplates().Where(pt => pt.ViewPath == "ManufacturerTemplate.ProductsInGridOrLines").FirstOrDefault();

            //var categoryTemplateInGridAndLines =
            //    this.CategoryTemplates().Where(pt => pt.Name == "Products in Grid or Lines").FirstOrDefault();

            //categories

            #region Apple

            var manufacturerApple = new Manufacturer
            {
                Name = "Apple",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer_apple.png"), "image/png", GetSeName("Apple")),
                Published = true,
                DisplayOrder = 1,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Apple

            #region Android

            var manufacturerAndroid = new Manufacturer
            {
                Name = "Android",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-android.png"), "image/png", GetSeName("Android")),
                Published = true,
                DisplayOrder = 2,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Android

            #region LG

            var manufacturerLG = new Manufacturer
            {
                Name = "LG",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-lg.png"), "image/png", GetSeName("LG")),
                Published = true,
                DisplayOrder = 3,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion LG

            #region Dell

            var manufacturerDell = new Manufacturer
            {
                Name = "Dell",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-dell.png"), "image/png", GetSeName("Dell")),
                Published = true,
                DisplayOrder = 4,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Dell

            #region HP

            var manufacturerHP = new Manufacturer
            {
                Name = "HP",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-hp.png"), "image/png", GetSeName("HP")),
                Published = true,
                DisplayOrder = 5,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion HP

            #region Microsoft

            var manufacturerMicrosoft = new Manufacturer
            {
                Name = "Microsoft",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-microsoft.png"), "image/png", GetSeName("Microsoft")),
                Published = true,
                DisplayOrder = 6,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Microsoft

            #region Samsung

            var manufacturerSamsung = new Manufacturer
            {
                Name = "Samsung",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-samsung.png"), "image/png", GetSeName("Samsung")),
                Published = true,
                DisplayOrder = 7,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Samsung

            #region Acer

            var manufacturerAcer = new Manufacturer
            {
                Name = "Acer",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "acer-logo.jpg"), "image/pjpeg", GetSeName("Acer")),
                Published = true,
                DisplayOrder = 8,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Acer

            #region TrekStor

            var manufacturerTrekStor = new Manufacturer
            {
                Name = "TrekStor",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-trekstor.png"), "image/png", GetSeName("TrekStor")),
                Published = true,
                DisplayOrder = 9,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion TrekStor

            #region Western Digital

            var manufacturerWesternDigital = new Manufacturer
            {
                Name = "Western Digital",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-westerndigital.png"), "image/png", GetSeName("Western Digital")),
                Published = true,
                DisplayOrder = 10,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Western Digital

            #region MSI

            var manufacturerMSI = new Manufacturer
            {
                Name = "MSI",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-msi.png"), "image/png", GetSeName("MSI")),
                Published = true,
                DisplayOrder = 11,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion MSI

            #region Canon

            var manufacturerCanon = new Manufacturer
            {
                Name = "Canon",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-canon.png"), "image/png", GetSeName("Canon")),
                Published = true,
                DisplayOrder = 12,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Canon

            #region Casio

            var manufacturerCasio = new Manufacturer
            {
                Name = "Casio",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-casio.png"), "image/png", GetSeName("Casio")),
                Published = true,
                DisplayOrder = 13,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Casio

            #region Panasonic

            var manufacturerPanasonic = new Manufacturer
            {
                Name = "Panasonic",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-panasonic.png"), "image/png", GetSeName("Panasonic")),
                Published = true,
                DisplayOrder = 14,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Panasonic

            #region BlackBerry

            var manufacturerBlackBerry = new Manufacturer
            {
                Name = "BlackBerry",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-blackberry.png"), "image/png", GetSeName("BlackBerry")),
                Published = true,
                DisplayOrder = 15,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion BlackBerry

            #region HTC

            var manufacturerHTC = new Manufacturer
            {
                Name = "HTC",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-htc.png"), "image/png", GetSeName("HTC")),
                Published = true,
                DisplayOrder = 16,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion HTC

            #region Festina

            var manufacturerFestina = new Manufacturer
            {
                Name = "Festina",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer_festina.png"), "image/png", GetSeName("Festina")),
                Published = true,
                DisplayOrder = 17,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Festina

            #region Certina

            var manufacturerCertina = new Manufacturer
            {
                Name = "Certina",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer-certina.png"), "image/png", GetSeName("Certina")),
                Published = true,
                DisplayOrder = 18,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Certina

            #region Sony

            var manufacturerSony = new Manufacturer
            {
                Name = "Sony",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer_sony.png"), "image/png", GetSeName("Sony")),
                Published = true,
                DisplayOrder = 19,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Sony

            #region Ubisoft

            var manufacturerUbisoft = new Manufacturer
            {
                Name = "Ubisoft",
                ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
                PageSize = 12,
                AllowCustomersToSelectPageSize = true,
                PageSizeOptions = "12,18,36,72,150",
                Picture = CreatePicture(File.ReadAllBytes(sampleImagesPath + "manufacturer_ubisoft.png"), "image/png", GetSeName("Ubisoft")),
                Published = true,
                DisplayOrder = 20,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow
            };

            #endregion Ubisoft

            var entities = new List<Manufacturer>
            {
              manufacturerApple,manufacturerSamsung,manufacturerLG,manufacturerTrekStor, manufacturerWesternDigital,manufacturerDell, manufacturerMSI,
              manufacturerCanon, manufacturerCasio, manufacturerPanasonic, manufacturerBlackBerry, manufacturerHTC, manufacturerFestina, manufacturerCertina,
              manufacturerHP, manufacturerAcer, manufacturerSony, manufacturerUbisoft
            };

            this.Alter(entities);
            return entities;
        }
        public PictureModel PrepareManufacturerPictureModel(Manufacturer manufacturer, string localizedName)
        {
            var model = new PictureModel();

            var pictureSize = _mediaSettings.ManufacturerThumbPictureSize;
            var manufacturerPictureCacheKey = string.Format(ModelCacheEventConsumer.MANUFACTURER_PICTURE_MODEL_KEY,
                manufacturer.Id,
                pictureSize,
                !_catalogSettings.HideManufacturerDefaultPictures,
                _services.WorkContext.WorkingLanguage.Id,
                _services.WebHelper.IsCurrentConnectionSecured(),
                _services.StoreContext.CurrentStore.Id);

            model = _services.Cache.Get(manufacturerPictureCacheKey, () =>
            {
                var pictureModel = new PictureModel
                {
                    PictureId = manufacturer.PictureId.GetValueOrDefault(),
                    //FullSizeImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId.GetValueOrDefault()),
                    ImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId.GetValueOrDefault(), pictureSize, !_catalogSettings.HideManufacturerDefaultPictures),
                    Title = string.Format(T("Media.Manufacturer.ImageLinkTitleFormat"), localizedName),
                    AlternateText = string.Format(T("Media.Manufacturer.ImageAlternateTextFormat"), localizedName)
                };
                return pictureModel;
            });

            return model;
        }
 public static Manufacturer ToEntity(this ManufacturerModel model, Manufacturer destination)
 {
     return Mapper.Map(model, destination);
 }
        /// <summary>
        /// Updates the manufacturer
        /// </summary>
        /// <param name="manufacturer">Manufacturer</param>
        public virtual void UpdateManufacturer(Manufacturer manufacturer)
        {
            if (manufacturer == null)
                throw new ArgumentNullException("manufacturer");

            _manufacturerRepository.Update(manufacturer);

            //cache
            _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY);
            _cacheManager.RemoveByPattern(PRODUCTMANUFACTURERS_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(manufacturer);
        }
		protected void SaveStoreMappings(Manufacturer manufacturer, ManufacturerModel model)
		{
			var existingStoreMappings = _storeMappingService.GetStoreMappings(manufacturer);
			var allStores = _storeService.GetAllStores();
			foreach (var store in allStores)
			{
				if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.Id))
				{
					//new role
					if (existingStoreMappings.Where(sm => sm.StoreId == store.Id).Count() == 0)
						_storeMappingService.InsertStoreMapping(manufacturer, store.Id);
				}
				else
				{
					//removed role
					var storeMappingToDelete = existingStoreMappings.Where(sm => sm.StoreId == store.Id).FirstOrDefault();
					if (storeMappingToDelete != null)
						_storeMappingService.DeleteStoreMapping(storeMappingToDelete);
				}
			}
		}