本文整理汇总了C#中Nop.Core.Domain.Catalog.Manufacturer类的典型用法代码示例。如果您正苦于以下问题:C# Manufacturer类的具体用法?C# Manufacturer怎么用?C# Manufacturer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Manufacturer类属于Nop.Core.Domain.Catalog命名空间,在下文中一共展示了Manufacturer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteManufacturer
/// <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);
}
示例2: Can_save_and_load_manufacturer
public void Can_save_and_load_manufacturer()
{
var manufacturer = new Manufacturer
{
Name = "Name",
Description = "Description 1",
ManufacturerTemplateId = 1,
MetaKeywords = "Meta keywords",
MetaDescription = "Meta description",
MetaTitle = "Meta title",
PictureId = 3,
PageSize = 4,
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "4, 2, 8, 12",
PriceRanges = "1-3;",
HasDiscountsApplied = true,
Published = true,
SubjectToAcl = 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.ManufacturerTemplateId.ShouldEqual(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.HasDiscountsApplied.ShouldEqual(true);
fromDb.Published.ShouldEqual(true);
fromDb.SubjectToAcl.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));
}
示例3: Can_save_and_load_manufacturer_with_productManufacturers
public void Can_save_and_load_manufacturer_with_productManufacturers()
{
var manufacturer = new Manufacturer
{
Name = "Name",
Description = "Description 1",
MetaKeywords = "Meta keywords",
MetaDescription = "Meta description",
MetaTitle = "Meta title",
SeName = "SE name",
PictureId = 3,
PageSize = 4,
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "4, 2, 8, 12",
PriceRanges = "1-3;",
Published = true,
Deleted = false,
DisplayOrder = 5,
CreatedOnUtc = new DateTime(2010, 01, 01),
UpdatedOnUtc = new DateTime(2010, 01, 02)
};
manufacturer.ProductManufacturers.Add
(
new ProductManufacturer
{
IsFeaturedProduct = true,
DisplayOrder = 1,
Product = new Product()
{
Name = "Name 1",
Published = true,
Deleted = false,
CreatedOnUtc = new DateTime(2010, 01, 01),
UpdatedOnUtc = new DateTime(2010, 01, 02)
}
}
);
var fromDb = SaveAndLoadEntity(manufacturer);
fromDb.ShouldNotBeNull();
fromDb.Name.ShouldEqual("Name");
fromDb.ProductManufacturers.ShouldNotBeNull();
(fromDb.ProductManufacturers.Count == 1).ShouldBeTrue();
fromDb.ProductManufacturers.First().IsFeaturedProduct.ShouldEqual(true);
}
示例4: PrepareDiscountModel
protected virtual void PrepareDiscountModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableDiscounts = _discountService
.GetAllDiscounts(DiscountType.AssignedToManufacturers, showHidden: true)
.Select(d => d.ToModel())
.ToList();
if (!excludeProperties && manufacturer != null)
{
model.SelectedDiscountIds = manufacturer.AppliedDiscounts.Select(d => d.Id).ToArray();
}
}
示例5: InstallManufacturers
protected virtual void InstallManufacturers()
{
var pictureService = EngineContext.Current.Resolve<IPictureService>();
var sampleImagesPath = _webHelper.MapPath("~/content/samples/");
var manufacturerTemplateInGridAndLines =
_manufacturerTemplateRepository.Table.FirstOrDefault(pt => pt.Name == "Products in Grid or Lines");
if (manufacturerTemplateInGridAndLines == null)
throw new Exception("Manufacturer template cannot be loaded");
var allManufacturers = new List<Manufacturer>();
var manufacturerAsus = new Manufacturer
{
Id = 1,
Name = "Apple",
ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
PageSize = 6,
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "6, 3, 9",
Published = true,
PictureId = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "manufacturer_apple.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Apple")).Id,
DisplayOrder = 1,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc = DateTime.UtcNow
};
_manufacturerRepository.Insert(manufacturerAsus);
allManufacturers.Add(manufacturerAsus);
var manufacturerHp = new Manufacturer
{
Id = 2,
Name = "HP",
ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
PageSize = 6,
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "6, 3, 9",
Published = true,
PictureId = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "manufacturer_hp.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Hp")).Id,
DisplayOrder = 5,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc = DateTime.UtcNow
};
_manufacturerRepository.Insert(manufacturerHp);
allManufacturers.Add(manufacturerHp);
var manufacturerNike = new Manufacturer
{
Id = 3,
Name = "Nike",
ManufacturerTemplateId = manufacturerTemplateInGridAndLines.Id,
PageSize = 6,
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "6, 3, 9",
Published = true,
PictureId = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "manufacturer_nike.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Nike")).Id,
DisplayOrder = 5,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc = DateTime.UtcNow
};
_manufacturerRepository.Insert(manufacturerNike);
allManufacturers.Add(manufacturerNike);
//search engine names
foreach (var manufacturer in allManufacturers)
{
manufacturer.SeName = manufacturer.ValidateSeName("", manufacturer.Name, true);
_urlRecordRepository.Insert(new UrlRecord
{
EntityId = manufacturer.Id,
EntityName = "Manufacturer",
LanguageId = 0,
IsActive = true,
Slug = manufacturer.SeName
});
_manufacturerRepository.Update(manufacturer);
}
}
示例6: PrepareAclModel
protected virtual void PrepareAclModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableCustomerRoles = _customerService
.GetAllCustomerRoles(true)
.Select(cr => cr.ToModel())
.ToList();
if (!excludeProperties)
{
if (manufacturer != null)
{
model.SelectedCustomerRoleIds = manufacturer.CustomerRoles.ToArray();
}
}
}
示例7: UpdateLocales
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);
_urlRecordService.SaveSlug(manufacturer, seName, localized.LanguageId);
}
}
示例8: PrepareStoresMappingModel
private void PrepareStoresMappingModel(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];
}
}
}
示例9: PrepareAclModel
private void PrepareAclModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableCustomerRoles = _customerService
.GetAllCustomerRoles(true)
.Select(cr => cr.ToModel())
.ToList();
if (!excludeProperties)
{
if (manufacturer != null)
{
model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(manufacturer);
}
else
{
model.SelectedCustomerRoleIds = new int[0];
}
}
}
示例10: ResolveBrand
private Manufacturer ResolveBrand(string brandName)
{
Manufacturer brand = _manufacturerService.GetAllManufacturers(brandName).FirstOrDefault();
if (brand != null) return brand;
brand = new Manufacturer
{
Name = brandName,
AllowCustomersToSelectPageSize = true,
//Description = brandName,
MetaDescription = brandName,
MetaKeywords = brandName,
MetaTitle = brandName,
ManufacturerTemplateId = 1,
LimitedToStores = false,
DisplayOrder = 1,
PageSize = 8,
PageSizeOptions = "4,8,12",
SubjectToAcl = false,
Published = true,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc = DateTime.UtcNow
};
_manufacturerService.InsertManufacturer(brand);
_urlRecordService.SaveSlug(brand, brand.ValidateSeName(brandName, brandName, true), 0);
return _manufacturerService.GetAllManufacturers(brandName).First();
}
示例11: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && manufacturer != null)
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(manufacturer).ToList();
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
model.AvailableStores.Add(new SelectListItem
{
Text = store.Name,
Value = store.Id.ToString(),
Selected = model.SelectedStoreIds.Contains(store.Id)
});
}
}
示例12: PrepareAclModel
protected virtual void PrepareAclModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && manufacturer != null)
model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(manufacturer).ToList();
var allRoles = _customerService.GetAllCustomerRoles(true);
foreach (var role in allRoles)
{
model.AvailableCustomerRoles.Add(new SelectListItem
{
Text = role.Name,
Value = role.Id.ToString(),
Selected = model.SelectedCustomerRoleIds.Contains(role.Id)
});
}
}
示例13: PrepareDiscountModel
protected virtual void PrepareDiscountModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && manufacturer != null)
model.SelectedDiscountIds = manufacturer.AppliedDiscounts.Select(d => d.Id).ToList();
foreach (var discount in _discountService.GetAllDiscounts(DiscountType.AssignedToManufacturers, showHidden: true))
{
model.AvailableDiscounts.Add(new SelectListItem
{
Text = discount.Name,
Value = discount.Id.ToString(),
Selected = model.SelectedDiscountIds.Contains(discount.Id)
});
}
}
示例14: UpdateLocales
protected virtual List<LocalizedProperty> UpdateLocales(Manufacturer manufacturer, ManufacturerModel model)
{
List<LocalizedProperty> localized = new List<LocalizedProperty>();
foreach (var local in model.Locales)
{
if (!(String.IsNullOrEmpty(local.Description)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "Description",
LocaleValue = local.Description,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
if (!(String.IsNullOrEmpty(local.MetaDescription)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "MetaDescription",
LocaleValue = local.MetaDescription,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
if (!(String.IsNullOrEmpty(local.MetaKeywords)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "MetaKeywords",
LocaleValue = local.MetaKeywords,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
if (!(String.IsNullOrEmpty(local.MetaTitle)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "MetaTitle",
LocaleValue = local.MetaTitle,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
if (!(String.IsNullOrEmpty(local.Name)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "Name",
LocaleValue = local.Name,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
//search engine name
var seName = manufacturer.ValidateSeName(local.SeName, local.Name, false);
_urlRecordService.SaveSlug(manufacturer, seName, local.LanguageId);
if (!(String.IsNullOrEmpty(seName)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "SeName",
LocaleValue = seName,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
}
return localized;
}
示例15: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(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 = manufacturer.Stores.ToArray();
}
}
}