public CatalogServiceMock()
 {
     catalogItems      = new List <CatalogItem>(PreconfiguredData.GetPreconfiguredCatalogItems());
     catalogBrands     = new List <CatalogBrand>(PreconfiguredData.GetPreconfiguredCatalogBrands());
     catalogTypes      = new List <CatalogType>(PreconfiguredData.GetPreconfiguredCatalogTypes());
     catalogItemsStock = new List <CatalogItemsStock>(PreconfiguredData.GetPreconfiguredCatalogItemsStock());
 }
        private List <CatalogItem> ComposeCatalogItems(List <CatalogItem> items)
        {
            var catalogTypes  = PreconfiguredData.GetPreconfiguredCatalogTypes();
            var catalogBrands = PreconfiguredData.GetPreconfiguredCatalogBrands();

            items.ForEach(i => i.CatalogBrand = catalogBrands.First(b => b.Id == i.CatalogBrandId));
            items.ForEach(i => i.CatalogType  = catalogTypes.First(b => b.Id == i.CatalogTypeId));

            return(items);
        }
Пример #3
0
        public void Configure(EntityTypeBuilder <CatalogBrand> builder)
        {
            builder.ToTable("CatalogBrand");

            builder.HasKey(ci => ci.Id);

            builder.Property(ci => ci.Id)
            .IsRequired();

            builder.Property(cb => cb.Brand)
            .IsRequired()
            .HasMaxLength(100);

            builder.HasData(
                PreconfiguredData.GetPreconfiguredCatalogBrands()
                );
        }
    private void AddCatalogBrands(CatalogDBContext context)
    {
        var preconfiguredBrands = useCustomizationData
            ? GetCatalogBrandsFromFile()
            : PreconfiguredData.GetPreconfiguredCatalogBrands();

        int sequenceId = GetSequenceIdFromSelectedDBSequence(context, DBBrandSequenceName);

        foreach (var brand in preconfiguredBrands)
        {
            brand.Id = sequenceId;
            context.CatalogBrands.Add(brand);
            sequenceId++;
        }

        context.SaveChanges();
    }
    IEnumerable <CatalogBrand> GetCatalogBrandsFromFile()
    {
        var    contentRootPath      = GetContentRootPath();
        string csvFileCatalogBrands = Path.Combine(contentRootPath, "Setup", "CatalogBrands.csv");

        if (!File.Exists(csvFileCatalogBrands))
        {
            return(PreconfiguredData.GetPreconfiguredCatalogBrands());
        }

        string[] csvheaders;

        string[] requiredHeaders = { "catalogbrand" };
        csvheaders = GetHeaders(csvFileCatalogBrands, requiredHeaders);

        return(File.ReadAllLines(csvFileCatalogBrands)
               .Skip(1)                      // skip header row
               .Select(x => CreateCatalogBrand(x))
               .Where(x => x != null));
    }
 public IEnumerable <CatalogBrand> GetCatalogBrands()
 {
     return(PreconfiguredData.GetPreconfiguredCatalogBrands());
 }