예제 #1
0
        private void Seed()
        {
            // Create a couple of Stores each with some Products and Employees
            var barginBasin = new Store { Name = "Bargin Basin" };
            var superMart = new Store { Name = "SuperMart" };

            var potatoes = new Product { Name = "Potatoes", Price = 3.60 };
            var fish = new Product { Name = "Fish", Price = 4.49 };
            var milk = new Product { Name = "Milk", Price = 0.79 };
            var bread = new Product { Name = "Bread", Price = 1.29 };
            var cheese = new Product { Name = "Cheese", Price = 2.10 };
            var waffles = new Product { Name = "Waffles", Price = 2.41 };

            var daisy = new Employee { FirstName = "Daisy", LastName = "Harrison" };
            var jack = new Employee { FirstName = "Jack", LastName = "Torrance" };
            var sue = new Employee { FirstName = "Sue", LastName = "Walkters" };
            var bill = new Employee { FirstName = "Bill", LastName = "Taft" };
            var joan = new Employee { FirstName = "Joan", LastName = "Pope" };

            // Add Products to the Stores
            // The Store-Product relationship is many-to-many
            AddProductsToStore(barginBasin, potatoes, fish, milk, bread, cheese);
            AddProductsToStore(superMart, bread, cheese, waffles);

            // Add Employees to the Stores
            // The Store-Employee relationship is one-to-many
            AddEmployeesToStore(barginBasin, daisy, jack, sue);
            AddEmployeesToStore(superMart, bill, joan);

            StoreRepository.SaveOrUpdateAll(barginBasin, superMart);
        }
예제 #2
0
 public virtual Product AddProduct(Product product)
 {
     product.StoresStockedIn.Add(this);
     Products.Add(product);
     return product;
 }
예제 #3
0
        private Order AddOrderToBascet(User user, Product product)
        {
            Order order = new Order()
            {
                Email = !string.IsNullOrEmpty(user.Email) ? user.Email : "*****@*****.**",
                User = user,
                Product = product,
                Comments = DefaultComments
            };

            order = OrdersRepository.SaveOrUpdate(order);

            user.AddOrder(order);
            UserRepository.SaveOrUpdate(user);

            return order;
        }
예제 #4
0
파일: Store.cs 프로젝트: galyna/SumkaNet
 public virtual void AddProduct(Product product)
 {
     product.StoresStockedIn.Add(this);
     Products.Add(product);
 }
예제 #5
0
파일: Store.cs 프로젝트: galyna/Toloka
 public virtual IList<Product> DeleteProduct(Product product)
 {
     product.Store = null;
     Products.Remove(product);
     return Products;
 }
예제 #6
0
파일: Store.cs 프로젝트: galyna/Toloka
 public virtual Product AddProduct(Product product)
 {
     product.Store = this;
     Products.Add(product);
     return product;
 }
예제 #7
0
        private Product CreateProduct(int employeeId)
        {
            Product product = new Product() { Name = "Назва", Price = 100, ImagePath = DefaulImgBigBanner, ImageSmallPath = DefaulImgSmallBanner, ImageMediumPath = DefaulImgBigBanner ,};
            product.Employee = EmployeeRepository.Get(e => e.Id == employeeId).SingleOrDefault();
            product.Store = StoreRepository.GetAll().First();

            Product productSaved = ProductsRepository.SaveOrUpdate(product);
            product.Store.AddProduct(productSaved);

            productSaved = ProductsRepository.SaveOrUpdate(productSaved);
            return productSaved;
        }
예제 #8
0
        private void CreateHtml(ref Product product)
        {
            var HtmlBanner = string.Format(_productBennerTemplate, product.Id, !string.IsNullOrEmpty(product.ImageMediumPath) ? product.ImagePath : DefaulImgBigBanner, product.Name, product.Price + " грн.");
            var HtmlBannerOrderedNot = string.Format(_productBenner, product.Id, !string.IsNullOrEmpty(product.ImageMediumPath) ? product.ImagePath : DefaulImgBigBanner, product.Name, product.Price + " грн.");
            var HtmlBannerOrdered = string.Format(_productBennerOrder, product.Id, !string.IsNullOrEmpty(product.ImageMediumPath) ? product.ImagePath : DefaulImgBigBanner, product.Name, product.Price + " грн.");
            var HtmlBannerEdit = "";
            if (product.IsPublished)
            {
                HtmlBannerEdit = string.Format(_productBennerTemplatePublished, product.Id,!string.IsNullOrEmpty(product.ImageMediumPath)?product.ImagePath:DefaulImgBigBanner, product.Name, product.Price + " грн.");
            }
            else
            {
                HtmlBannerEdit = string.Format(_productBennerTemplate, product.Id, !string.IsNullOrEmpty(product.ImageMediumPath) ? product.ImageMediumPath : DefaulImgBigBanner, product.Name, product.Price + " грн.");
            }

            var HtmlSmallBanner = string.Format(_productSmallBenner, !string.IsNullOrEmpty(product.ImageSmallPath) ? product.ImageSmallPath : DefaulImgSmallBanner);
            product.HtmlBanner = Server.HtmlEncode(HtmlBanner);
            product.HtmlBannerOrderedNot = Server.HtmlEncode(HtmlBannerOrderedNot);
            product.HtmlBannerOrdered = Server.HtmlEncode(HtmlBannerOrdered);
            product.HtmlBannerEdit = Server.HtmlEncode(HtmlBannerEdit);
            product.HtmlSmallBanner = Server.HtmlEncode(HtmlSmallBanner);
        }