private static void SeedProducts(ChameleonStoreContext context, ProductDto[] productDtos) { var productsToCreate = new List <Product>(); foreach (var productDto in productDtos) { var category = context.Categories.SingleOrDefault(x => x.Name == productDto.CategoryName); var brand = context.Brands.SingleOrDefault(x => x.Name == productDto.BrandName); if (category != null) { var product = new Product { Name = productDto.Name, ImageURL = productDto.ImageURL, Price = productDto.Price, Discount = productDto.Discount, Condition = productDto.Condition, Description = productDto.Description, BrandId = brand.Id, CategoryId = category.Id, Views = productDto.Views }; productsToCreate.Add(product); } } context.Products.AddRange(productsToCreate); context.SaveChanges(); }
protected BaseEFService( ChameleonStoreContext context, IMapper mapper) { this.Context = context; this.Mapper = mapper; }
public AdminProductServiceTest() { this.context = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.dropDownService = new DropDownListService(this.context, this.mapper); this.productService = new ProductService(this.context, this.mapper); this.adminProductService = new AdminProductService(this.context, this.mapper, this.productService, this.dropDownService); }
public RoleService( ChameleonStoreContext context, IMapper mapper, IDropDownListable dropDownService) : base(context, mapper) { this.dropDownService = dropDownService; }
public AdminProductService( ChameleonStoreContext context, IMapper mapper, IProductService products, IDropDownListable dropDownService) : base(context, mapper) { this.products = products; this.dropDownService = dropDownService; }
public ProductsController( ChameleonStoreContext context, IMapper mapper, IAdminProductService products, IDropDownListable dropDownService) { this.context = context; this.mapper = mapper; this.products = products; this.dropDownService = dropDownService; }
private static void SeedBrands(ChameleonStoreContext context, BrandDto[] brandDtos) { var brandsToCreate = brandDtos .Select(c => new Brand { Name = c.Name }) .ToArray(); context.Brands.AddRange(brandsToCreate); context.SaveChanges(); }
private static void SeedCategories(ChameleonStoreContext context, CategoryDto[] categoryDtos) { var categoriesToCreate = categoryDtos .Select(c => new Category { Name = c.Name }) .ToArray(); context.Categories.AddRange(categoriesToCreate); context.SaveChanges(); }
public ProductService( ChameleonStoreContext context, IMapper mapper) : base(context, mapper) { }
public OrderService( ChameleonStoreContext context, IMapper mapper) : base(context, mapper) { }
public ProductServiceTest() { this.context = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.products = new ProductService(this.context, this.mapper); }
public DropDownListService( ChameleonStoreContext context, IMapper mapper) : base(context, mapper) { }