Наследование: DomainEntity
Пример #1
0
        private void CreateVendor()
        {
            _vendor1 = new Vendor
            {
                Company = "Some Company1",
                Phone = "555.123.4567",
                Fax = "123.456.7891",
                Website = "www.somewebsite1.com",
                LogoUrl = "someurl1",
                Notes = "notes1"
            };

            _vendor2 = new Vendor
            {
                Company = "Some Company2",
                Phone = "555.123.4567",
                Fax = "123.456.7891",
                Website = "www.somewebsite2.com",
                LogoUrl = "someurl2",
                Notes = "notes2"
            };

            _vendor1.AddProduct(_fertilizer1);
            _vendor1.AddProduct(_fertilizer2);
            _vendor2.AddProduct(_fertilizer1);
            _vendor2.AddProduct(_fertilizer2);

            _vendor1.AddProduct(_chemical1);
            _vendor1.AddProduct(_chemical2);
            _vendor2.AddProduct(_chemical1);
            _vendor2.AddProduct(_chemical2);

            _vendor1.AddProduct(_materials1);
            _vendor1.AddProduct(_materials2);
            _vendor2.AddProduct(_materials1);
            _vendor2.AddProduct(_materials2);

            _vendor1.AddProduct(_seed1);
            _vendor1.AddProduct(_seed2);
            _vendor2.AddProduct(_seed1);
            _vendor2.AddProduct(_seed2);

            _repository.Save(_vendor1);
            _repository.Save(_vendor2);

            var purchaseOrder1 = new PurchaseOrder {Vendor = _vendor1, DateCreated = DateTime.Parse("1/5/2009"), Status = TemporalStatus.Complete.Key};
            var poli1 = new PurchaseOrderLineItem()
            {
                Product = _fertilizer1,
                Price = 10,
                QuantityOrdered = 5,
                Tax = 5
            };

            var poli2 = new PurchaseOrderLineItem()
            {
                Product = _fertilizer1,
                Price = 10,
                QuantityOrdered = 5,
                Tax = 5
            };

            var poli3 = new PurchaseOrderLineItem()
            {
                Product = _materials1,
                Price = 10,
                QuantityOrdered = 5,
                Tax = 5
            };

            var poli4 = new PurchaseOrderLineItem()
            {
                Product = _materials2,
                Price = 10,
                QuantityOrdered = 5,
                Tax = 5
            };

            var poli5 = new PurchaseOrderLineItem()
            {
                Product = _chemical2,
                Price = 10,
                QuantityOrdered = 5,
                Tax = 5
            };

            var poli6 = new PurchaseOrderLineItem()
            {
                Product = _chemical1,
                Price = 10,
                QuantityOrdered = 5,
                Tax = 5
            };

            purchaseOrder1.AddLineItem(poli1);
            purchaseOrder1.AddLineItem(poli2);
            purchaseOrder1.AddLineItem(poli3);
            purchaseOrder1.AddLineItem(poli4);
            purchaseOrder1.AddLineItem(poli5);
            purchaseOrder1.AddLineItem(poli6);
            _vendor1.AddPurchaseOrder(purchaseOrder1);
            _repository.Save(_vendor1);
        }
Пример #2
0
 private Vendor mapToDomain(VendorViewModel input, Vendor vendor)
 {
     var vendorModel = input.Vendor;
     vendor.Company = vendorModel.Company;
     vendor.Fax = vendorModel.Fax;
     vendor.Phone = vendorModel.Phone;
     vendor.Address1 = vendorModel.Address1;
     vendor.Address2 = vendorModel.Address2;
     vendor.City = vendorModel.City;
     vendor.State = vendorModel.State;
     vendor.ZipCode = vendorModel.ZipCode;
     vendor.Website = vendorModel.Website;
     vendor.Status = vendorModel.Status;
     vendor.Notes = vendorModel.Notes;
     vendor.ClearProducts();
     if(input.ChemicalInput.IsNotEmpty())
         input.ChemicalInput.Split(',').Each(x => vendor.AddProduct(_repository.Find<Chemical>(Int32.Parse(x))));
     if (input.FertilizerInput.IsNotEmpty())
         input.FertilizerInput.Split(',').Each(x => vendor.AddProduct(_repository.Find<Fertilizer>(Int32.Parse(x))));
     if (input.MaterialInput.IsNotEmpty())
         input.MaterialInput.Split(',').Each(x => vendor.AddProduct(_repository.Find<Material>(Int32.Parse(x))));
     if (input.SeedInput.IsNotEmpty())
         input.SeedInput.Split(',').Each(x => vendor.AddProduct(_repository.Find<Seed>(Int32.Parse(x))));
     return vendor;
 }