public void Update(OnlineShop shop)
 {
     if (1 - (shop.SalePrice / shop.Price) >= desiredSavings)
     {
         Console.WriteLine("The Super Cheap Shopper Bought The Item!");
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            var shop = new OnlineShop();

            var annCustomer = new Customer()
            {
                Name = "Ann"
            };

            shop.NewProductRecieved += annCustomer.GotNewGoods;

            var johnCustomer = new Customer()
            {
                Name = "John"
            };

            shop.NewProductRecieved += johnCustomer.GotNewGoods;

            //shop.TestEvent += annCustomer.MyDelegateProcessor;
            //shop.TestEvent += johnCustomer.MyDelegateProcessor;
            var drink = new Product()
            {
                ProductName = "Gin", Cost = 1005, Category = ProductCategory.Drink
            };
            var milk = new Product()
            {
                ProductName = "Bur", Cost = 10, Category = ProductCategory.MilkProduct
            };

            shop.GoodRecieving(drink);
            shop.GoodRecieving(milk);
        }
示例#3
0
        static void Main(string[] args)
        {
            // Observer Example
            var customer  = new Customer("Eliot Anderson");
            var customer2 = new Customer("Andrei Keks");
            var shop      = new OnlineShop();
            var mobile    = new Product("Xiaomi MI 9", 600);

            shop.Subscribe(customer);
            shop.Subscribe(customer2);
            shop.AddProduct(mobile);

            // Template pattern example
            var mkvVideo = new MkvVideoPlayer();
            var mp4Video = new MP4VideoPlayer();

            mkvVideo.PlayVideo("funny-cats.mkv");
            mp4Video.PlayVideo("funny-dogs.mp4");


            // Strategy pattern
            var order           = new Order(126);
            var calculator      = new ShippingCalculator();
            var shippingCostDHL = calculator.CalculateShipping(new DHLShippingStrategy(), order);
            var shippingCostUPS = calculator.CalculateShipping(new UpsShippingStrategy(), order);

            Console.WriteLine($"Shipping prices:\n  DHL price: {shippingCostDHL}$\n  UPS Price: {shippingCostUPS}$");
            Console.ReadLine();
        }
示例#4
0
        public static void Main(string[] args)
        {
            var shop = new OnlineShop();

            var annCustomer = new Customer()
            {
                Name = "Ann"
            };

            shop.NewProductRecieved += annCustomer.GotNewGoods;
            var johnCustomer = new Customer()
            {
                Name = "John"
            };

            shop.NewProductRecieved += johnCustomer.GotNewGoods;
            shop.NewProductRecieved += johnCustomer.GotProcessing;

            var drink = new Product {
                ProductName = "Gin", Cost = 1005, Category = ProductCategory.Drink
            };
            var milk = new Product {
                ProductName = "Bur", Cost = 10, Category = ProductCategory.MilkProduct
            };

            shop.GoodRecieving(drink);
            shop.GoodRecieving(milk);

            Console.ReadKey();
        }
示例#5
0
        //tìm kiếm
        public ActionResult Timkiem(string keysearch, int page = 1)
        {
            int pagesize = 10;

            ViewBag.Keysearch = keysearch;
            var ds = new OnlineShop().Products.Where(x => x.ProductName.ToUpper().Contains(keysearch.Trim().ToUpper()) || x.ProductID.ToString().Contains(keysearch.Trim())).OrderByDescending(x => x.CreateDate).ToList().ToPagedList(page, pagesize);

            return(View(ds));
        }
示例#6
0
        public JsonResult AutocompleteKeysearch(string Prefix)
        {
            //Note : you can bind same list from database
            List <Product> ObjList = new List <Product>();

            ObjList = new OnlineShop().Products.ToList();
            //Searching records from list using LINQ query
            var CityName = (from N in ObjList
                            where N.ProductName.ToUpper().StartsWith(Prefix.ToUpper())
                            select new { N.ProductName });

            return(Json(CityName, JsonRequestBehavior.AllowGet));
        }
示例#7
0
        public static void Init(string directory, string settingsJSON)
        {
            ModDirectory = directory;

            Exception settingsE = null;

            try {
                Fields.settings = Helper.LoadSettings();
            } catch (Exception e) {
                settingsE       = e;
                Fields.settings = new Settings();
            }

            // Add a hook to dispose of logging on shutdown
            Logger = new Logger(directory, "persistent_map_client", Fields.settings.debug);
            System.AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) => Logger.Close();

            if (settingsE != null)
            {
                Logger.Log($"Using default settings due to exception reading settings: {settingsE.Message}");
            }

            Logger.Log($"Starting Client: {ClientVersion}");
            Logger.LogIfDebug($"Settings are:({Fields.settings.ToString()})");

            /* Read the ClientID from a location that is persistent across installs.
             * Everything under /mods is wiped out during RT installs. Instead we write
             * to Battletech/ModSaves/PersistentMapClient to allow it to persist across installs */
            if (Fields.settings.ClientID == null || Fields.settings.ClientID.Equals(""))
            {
                Helper.FetchClientID(directory);
            }
            else
            {
                // We were passed an ID by the test harness. Do nothing.
                Logger.Log("Test harness passed a clientID, skipping.");
            }

            var harmony = HarmonyInstance.Create("de.morphyum.PersistentMapClient");

            harmony.PatchAll(Assembly.GetExecutingAssembly());
            shop = new OnlineShop();
            Control.RegisterShop(shop, new string[] { "systemchange", "ContractComplete", "OwnerChange" });
            blackmarketShop = new BlackMarketOnlineShop();
            Control.RegisterShop(blackmarketShop, new string[] { "systemchange", "ContractComplete", "OwnerChange" });
        }
示例#8
0
        static void Main(string[] args)
        {
            var onlineShop = new OnlineShop();


            Money ApplyDiscount(Money money)
            {
                var thisMoney = new Money(money.Amount, money.Currency);

                Console.WriteLine("Discount Applied");

                var totalDiscount = thisMoney.Scale(.1M);

                return(thisMoney - totalDiscount);
            }

            onlineShop.BrowseProducts("mobile")
            .Map(products => onlineShop.SelectProduct(products))
            .Map(product => onlineShop.Checkout(product))
            .When(onlineShop.IsHappyHour, ApplyDiscount)
            .Tee(money => Console.WriteLine($"Thanks for shopping. You have successfully paid {money.ToString()}"));

            Console.ReadLine();
        }
示例#9
0
        public ActionResult Shop(string ShopName)
        {
            OnlineShop onlineShop = new OnlineShop();

            onlineShop.Home = GetOnlineShopHomeDetails(ShopName);

            if (onlineShop.Home.WebBusinessName == null)
            {
                ViewBag.StoreName = ShopName;
                return(View("NotValid"));
            }
            onlineShop.Products    = GetOnlineShopProductDetails(ShopName);
            onlineShop.TeamMembers = GetOnlineShopTeamMemberDetails(ShopName);
            onlineShop.Discounts   = GetOnlineShopDiscountDetails(ShopName);

            if (onlineShop.Products != null)
            {
                onlineShop.ShopCategory = onlineShop.Products.Select(product => product.FolderName).Distinct().ToList();
            }

            onlineShop.Awards       = GetOnlineShopHomeAwards(ShopName);
            onlineShop.Testimonials = GetOnlineShopTestimonials(ShopName);
            return(View(onlineShop));
        }
示例#10
0
 public CustomerAccountDAO()
 {
     dt = new OnlineShop();
 }
 public Order_Detail()
 {
     dt = new OnlineShop();
 }
示例#12
0
 public TagDAO()
 {
     dt = new OnlineShop();
 }
示例#13
0
 public ProductDAO()
 {
     db = new OnlineShop();
 }
 public ProductCategoryDAO()
 {
     dt = new OnlineShop();
 }
示例#15
0
 public AboutDAO()
 {
     dt = new OnlineShop();
 }
示例#16
0
 public ContentDAO()
 {
     dt = new OnlineShop();
 }
示例#17
0
 public ContactDAO()
 {
     db = new OnlineShop();
 }
示例#18
0
 public EntityCatalog(OnlineShop.DAL.OnlineShopContext context)
 {
     this.db = context;
 }
示例#19
0
 public UserDao()
 {
     db = new OnlineShop();
 }
示例#20
0
 public OrderDAO()
 {
     dt = new OnlineShop();
 }
 public OrderDetailDAO()
 {
     db = new OnlineShop();
 }
 public FeedbackDAO()
 {
     dt = new OnlineShop();
 }
示例#23
0
 public CategoryDAO()
 {
     db = new OnlineShop();
 }
示例#24
0
 public NewsDAO()
 {
     dt = new OnlineShop();
 }
示例#25
0
 public UserDAO()
 {
     db = new OnlineShop();
 }
 public MenuTypeDAO()
 {
     dt = new OnlineShop();
 }
示例#27
0
 public EntityContact(OnlineShop.DAL.OnlineShopContext context)
 {
     this.db = context;
 }
示例#28
0
 public SlideDAO()
 {
     db = new OnlineShop();
 }
示例#29
0
 public MenuDAO()
 {
     db = new OnlineShop();
 }