public void Update(OnlineShop shop) { if (1 - (shop.SalePrice / shop.Price) >= desiredSavings) { Console.WriteLine("The Super Cheap Shopper Bought The Item!"); } }
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); }
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(); }
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(); }
//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)); }
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)); }
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" }); }
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(); }
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)); }
public CustomerAccountDAO() { dt = new OnlineShop(); }
public Order_Detail() { dt = new OnlineShop(); }
public TagDAO() { dt = new OnlineShop(); }
public ProductDAO() { db = new OnlineShop(); }
public ProductCategoryDAO() { dt = new OnlineShop(); }
public AboutDAO() { dt = new OnlineShop(); }
public ContentDAO() { dt = new OnlineShop(); }
public ContactDAO() { db = new OnlineShop(); }
public EntityCatalog(OnlineShop.DAL.OnlineShopContext context) { this.db = context; }
public UserDao() { db = new OnlineShop(); }
public OrderDAO() { dt = new OnlineShop(); }
public OrderDetailDAO() { db = new OnlineShop(); }
public FeedbackDAO() { dt = new OnlineShop(); }
public CategoryDAO() { db = new OnlineShop(); }
public NewsDAO() { dt = new OnlineShop(); }
public UserDAO() { db = new OnlineShop(); }
public MenuTypeDAO() { dt = new OnlineShop(); }
public EntityContact(OnlineShop.DAL.OnlineShopContext context) { this.db = context; }
public SlideDAO() { db = new OnlineShop(); }
public MenuDAO() { db = new OnlineShop(); }