示例#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;
        }
示例#2
0
        public static KeyValuePair<Table, TableViewModel> FieldsTestMap()
        {
            var idTable = Guid.NewGuid();
            var tableName = "Just a table!";
            var countryName = "Cuba";
            var countryId = Guid.NewGuid();

            var table = new Table
            {
                Id = idTable,
                Name = tableName,
                Manufacturer = new Country
                {
                    Id = countryId,
                    Name = countryName
                },
                Sizes = new List<Size>(),
                Brands = new List<Brand>()
            };

            var tableViewModel = new TableViewModel
            {
                Id = idTable,
                Name = tableName,
                Manufacturer = new CountryViewModel
                {
                    Id = countryId,
                    Name = countryName
                },
                Sizes = new List<SizeViewModel>(),
                Brands = new List<BrandViewModel>()
            };

            for (var i = 0; i < 10; i++)
            {
                var brandId = Guid.NewGuid();
                var name = string.Format("Brand {0}", i);
                var brand = new Brand
                {
                    Id = brandId,
                    Name = name,
                };

                var brandViewModel = new BrandViewModel
                {
                    Id = brandId,
                    Name = name,
                };

                table.Brands.Add(brand);
                tableViewModel.Brands.Add(brandViewModel);
            }

            for (var i = 0; i < 5; i++)
            {
                var sizeId = Guid.NewGuid();
                var name = string.Format("Size {0}", i);
                var size = new Size
                {
                    Id = sizeId,
                    Name = name,
                };

                var sizeViewModel = new SizeViewModel
                {
                    Id = sizeId,
                    Name = name,

                };

                table.Sizes.Add(size);
                tableViewModel.Sizes.Add(sizeViewModel);
            }

            return new KeyValuePair<Table, TableViewModel>(table, tableViewModel);
        }
示例#3
0
        public static KeyValuePair<List<Size>, List<SizeViewModel>> CollectionCustomMap()
        {
            var source = new List<Size>();
            var result = new List<SizeViewModel>();
            Func<string, int, string> iterateFormatFunc = (str, ind) => string.Format("{0}-{1}", str, ind);

            for (var i = 0; i < 10; i++)
            {
                var id = Guid.NewGuid();
                var name = string.Format("size-{0}", i);
                var alias = string.Format("alias-{0}", i);

                var src = new Size
                {
                    Id = id,
                    Name = name,
                    Alias = alias,
                    SortOrder = i
                };

                var rst = new SizeViewModel
                {
                    Id = id,
                    Name = name,
                    Alias = alias,
                    SortOrder = i
                };

                source.Add(src);
                result.Add(rst);
            }

            return new KeyValuePair<List<Size>, List<SizeViewModel>>(source, result);
        }
示例#4
0
 public bool Equals(Size other)
 {
     return Id == other.Id && Name == other.Name && Alias == other.Alias && NotNullable.GetValueOrDefault() == other.NotNullable.GetValueOrDefault() && Nullable == other.Nullable && SortOrder == other.SortOrder && BoolValue == other.BoolValue;
 }