Beispiel #1
0
        public static KeyValuePair<FashionProduct, FashionProductViewModel> ComplexMap()
        {
            var sizes = new List<Size>();
            var sizesViewModels = new List<SizeViewModel>();

            var random = new Random();
            var sizeCount = random.Next(3, 10);
            var cityCount = random.Next(4, 10);

            for (var i = 0; i < sizeCount; i++)
            {
                var newGuid = Guid.NewGuid();
                var name = string.Format("Size {0}", i);
                var alias = string.Format("Alias Size {0}", i);
                sizes.Add(
                    new Size
                    {
                        Id = newGuid,
                        Name = name,
                        Alias = alias,
                        SortOrder = i
                    });
                sizesViewModels.Add(new SizeViewModel
                {
                    Id = newGuid,
                    Name = name,
                    Alias = alias,
                    SortOrder = i
                });
            }

            var cities = new List<City>();
            var cityViewModels = new List<CityViewModel>();

            var ftRandom = new Random();
            for (var i = 0; i < cityCount; i++)
            {
                var newGuid = Guid.NewGuid();
                var name = string.Format("City {0}", i);

                var featureCount = ftRandom.Next(7 , 50);
                var features = new Feature[featureCount];
                var featureViewModels = new List<FeatureViewModel>();

                for (var j = 0; j < featureCount; j++)
                {
                    var fId = Guid.NewGuid();
                    var fName = string.Format("Feature - {0}", j);
                    var fDescription = string.Format("Description Feature - {0}", j);
                    features[j] =
                        new Feature
                        {
                            Id = fId,
                            Name = fName,
                            Description = fDescription,
                            Rank = 8
                        };
                    featureViewModels.Add(new FeatureViewModel
                    {
                        Id = fId,
                        Name = fName,
                        Description = fDescription,
                        Rank = 8
                    });
                }

                cities.Add(new City
                {
                    Id = newGuid,
                    Name = name,
                    Features = features
                });
                cityViewModels.Add(new CityViewModel
                {
                    Id = newGuid,
                    Name = name,
                    FeaturesList = featureViewModels
                });
            }

            var brandId = Guid.NewGuid();
            var brandName = "Brand name";
            var brand = new Brand
            {
                Id = brandId,
                Name = brandName
            };
            var brandViewModel = new BrandViewModel
            {
                Id = brandId,
                Name = brandName
            };

            var supId = Guid.NewGuid();
            var supplierName = "Supplier name";
            var agreementDate = DateTime.Now;
            var supplier = new Supplier
            {
                Id = supId,
                Name = supplierName,
                AgreementDate = agreementDate,
                Rank = 6,
                Sizes = sizes,
            };

            var supplierViewModel = new SupplierViewModel
            {
                Id = supId,
                Name = supplierName,
                AgreementDate = agreementDate,
                Sizes = sizesViewModels,
            };

            var sizeId = Guid.NewGuid();
            var lonelySize = "Lonely size";
            var sizeSAlias = "Size's alias";
            var size = new Size
            {
                Id = sizeId,
                Name = lonelySize,
                Alias = sizeSAlias,
                SortOrder = 5
            };
            var sizeViewModel = new SizeViewModel
            {
                Id = sizeId,
                Name = lonelySize,
                Alias = sizeSAlias,
                SortOrder = 5
            };

            var optionsCount = random.Next(10, 50);

            var options = new List<ProductOption>();
            var optionViewModels = new List<ProductOptionViewModel>();

            for (var i = 0; i < optionsCount; i++)
            {
                var optionId = Guid.NewGuid();
                var color = "Random";
                var discount = 54M;
                var price = 34M;
                var stock = 102;
                var weight = 23;
                options.Add(
                    new ProductOption
                    {
                        Id = optionId,
                        Cities = cities,
                        Color = color,
                        Discount = discount,
                        Price = price,
                        Stock = stock,
                        Weight = weight,
                        Size = size
                    });
                optionViewModels.Add(
                    new ProductOptionViewModel
                    {
                        Id = optionId,
                        Cities = cityViewModels,
                        Color = color,
                        Discount = discount,
                        Price = price,
                        Stock = stock,
                        Weight = weight,
                        Size = sizeViewModel,
                        DiscountedPrice = Math.Floor(price * discount / 100)
                    });
            }

            var fpId = Guid.NewGuid();
            var fashionProductDescription = "Fashion product description";
            var ean = "6876876-5345345-345345tgreg-435345df-adskf34";
            var topFashionProductName = "Top Fashion Product";
            var createdOn = DateTime.Now;
            var end = DateTime.Now.AddDays(30);
            var start = DateTime.Now;
            var warehouseOn = DateTime.Now.AddDays(-3);
            var fashionProduct = new FashionProduct
            {
                Id = fpId,
                Brand = brand,
                CreatedOn = createdOn,
                Description = fashionProductDescription,
                Ean = ean,
                End = end,
                Gender = GenderTypes.Unisex,
                Name = topFashionProductName,
                Options = options,
                Start = start,
                Supplier = supplier,
                WarehouseOn = warehouseOn
            };

            var fashionProductViewModel = new FashionProductViewModel
            {
                Id = fpId,
                Brand = brandViewModel,
                CreatedOn = createdOn,
                Description = fashionProductDescription,
                Ean = ean,
                End = end,
                OptionalGender = null,
                Name = topFashionProductName,
                Options = optionViewModels,
                Start = start,
                Supplier = supplierViewModel,
                WarehouseOn = warehouseOn
            };

            var result = new KeyValuePair<FashionProduct, FashionProductViewModel>(fashionProduct, fashionProductViewModel);
            return result;
        }
Beispiel #2
0
        public static KeyValuePair<Supplier, SupplierViewModel> GetPropertyMaps()
        {
            var id = Guid.NewGuid();
            var samsung = "Samsung";
            var agreementDate = DateTime.Now.AddDays(-2);
            var src = new Supplier
            {
                Id = id,
                Name = samsung,
                AgreementDate = agreementDate,
                Rank = 7
            };

            var dest = new SupplierViewModel
            {
                Id = id,
                Name = samsung,
                AgreementDate = agreementDate,
            };

            var keyValuePair = new KeyValuePair<Supplier, SupplierViewModel>
                (
                src,
                dest
                );
            return keyValuePair;
        }