//product details public ActionResult Details(int id) //details view. right click on ActionResult - new model { var factory = new ShopFactory(); var found = factory.Products.Where(p => p.ID == id).FirstOrDefault(); //db, table return(View(found)); //a list called found }
/* * public ActionResult Product() * { * ViewBag.Message = "List & details:"; * * return View(); * } */ public ActionResult Details(int id) { var factory = new ShopFactory(); var found = factory.Products.Where(p => p.ID == id).FirstOrDefault(); return(View(found)); }
public ActionResult Index() { var factory = new ShopFactory(); var products = factory.Products.ToList(); return(View(products)); }
// Product details public ActionResult Detail(int id) { // Displays details for each products on index page var factory = new ShopFactory(); var found = factory.Products.Where(p => p.ID == id).FirstOrDefault(); return(View(found)); }
public void CheckShopIdsDiffrent() { ShopFactory factory = new ShopFactory(name, city, country, phone); var instance1 = factory.Instance; var instance2 = factory.Instance; Assert.AreEqual(instance1.Id + 1, instance2.Id); }
public ActionResult Index(string searchString) { // Displays a list of products on index page var factory = new ShopFactory(); var products = factory.Products.Where(p => string.IsNullOrEmpty(searchString) || p.Name.Contains(searchString)).OrderBy(p => p.Name).Take(10).ToList(); //var products = factory.Products.Take(10).ToList(); return(View(products)); }
public void CheckShopGeneration() { ShopFactory factory = new ShopFactory(name, city, country, phone); var instance = factory.Instance; Assert.AreEqual(instance.City, city); Assert.AreEqual(instance.Name, name); Assert.AreEqual(instance.TelephoneNumber, phone); Assert.AreEqual(instance.Country, country); Assert.Greater(instance.Id, -1); }
static void Main(string[] args) { /* * Database init * 가게 파싱 시작 */ con = new MySqlConnection("Server=localhost;Port=3306;Database=beakchelin;Uid=root;Pwd=tkfkd784;CharSet=utf8;"); if (ShopFactory.LoadShop(con)) { Console.WriteLine("모든 로딩이 끝났습니다."); } /* * 서버 오픈 */ sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); sock.Bind(new IPEndPoint(IPAddress.Any, 10100)); sock.Listen(100); Console.WriteLine("서버가 시작되었습니다."); var S_args = new SocketAsyncEventArgs(); S_args.Completed += new EventHandler <SocketAsyncEventArgs>(Accept_Completed); sock.AcceptAsync(S_args); /* * 명령어 */ while (true) { var Command = Console.ReadLine(); var CommandArgs = Command.Split(" "); var Op = CommandArgs[0]; switch (Op) { case "종료": return; case "테스트": Send(CommandArgs[2], Int32.Parse(CommandArgs[1])); break; case "디버그": isDebug = !(isDebug); break; } } }
public ActionResult Index(string searchCriteria) { var factory = new ShopFactory(); IQueryable <Product> prods = factory.Products.OrderBy(p => p.Name); if (searchCriteria != null) { prods = prods.Where(p => p.Name.Contains(searchCriteria)); } var products = prods.Take(10).ToList(); return(View(products)); }
/// <summary> /// Tries to parse. /// </summary> /// <returns><c>true</c>, if parse was successfull, <c>false</c> otherwise.</returns> /// <param name="repr">Repr.</param> /// <param name="factory">Factory.</param> public static bool TryParse(string repr, out ShopFactory factory) { factory = null; var split = repr.Split(new[] { ';' }); if (split.Length != 4) { return(false); } factory = new ShopFactory(split[0], split[1], split[2], split[3]); return(true); }
public ActionResult Picture(int id) { var factory = new ShopFactory(); var product = factory.Products.Where(p => p.ID == id).FirstOrDefault(); if (product == null) { return(HttpNotFound()); } var img = new WebImage(string.Format("~/Content/Images/{0}.jpg", product.ImageName)); img.Resize(50, 50); return(File(img.GetBytes(), "image/jpeg")); }
public ActionResult Index(string searchCriteria) { var factory = new ShopFactory(); IQueryable <Product> prods = factory.Products.OrderBy(p => p.Name); //list of products where we can use Query if (searchCriteria != null) { //if we have a string, we'll go through the products and pick the ones where the search string can be found in the name prods = prods.Where(p => p.Name.Contains(searchCriteria)); } var products = prods.Take(10).ToList(); return(View(products)); }
// Use this for initialization void Start() { var enabled = canvas.enabled; canvas.enabled = false; var shop = ShopFactory.Create(); foreach (var item in shop.GetItems()) { AddShopItem(item); } canvas.enabled = enabled; }
static void Main() { // factory var factories = new ShopFactory[2]; factories[0] = new CanvasFactory("cloth", 14, 12, 100); factories[1] = new DrawingPaperFactory("Cardboard", 30, 30, 15); foreach (ShopFactory factory in factories) { Console.WriteLine(factory.GetType().Name); } Console.WriteLine("\n\n"); // Builder var pencil = new SupplieCreator(new Pencil("red", 12, 2, 1)); pencil.CreateSupplie(); pencil.GetSupplie(); var pastel = new SupplieCreator(new Pastel("black", 2, 4, 2)); pastel.CreateSupplie(); pastel.GetSupplie(); //abstract factory IBrush standartBrush = new AngleBrush(); BrushManager standartManag = new BrushManager(standartBrush); Console.WriteLine(standartManag.GetAngleBrushDelails()); Console.WriteLine(standartManag.GetFlatBrushDetails()); IBrush acrylicBrush = new FlatBrush(); BrushManager acrylicManag = new BrushManager(acrylicBrush); Console.WriteLine(acrylicManag.GetAngleBrushDelails()); Console.WriteLine(acrylicManag.GetFlatBrushDetails()); Console.ReadLine(); }
public override async Task <bool> LoadWalletsFromDb(IDbConnectorService dbservice) { //IDbConnectorService dbservice = new DbConnectorService(); try { var wallets = dbservice.GetWallets(); var accounts = dbservice.GetAccounts(); foreach (var account in accounts) { if (account.AccountKeyId != Guid.Empty) { try { if (EconomyMainContext.StartWithShops) { if (account.Shop == null) { account.Shop = ShopFactory.GetShop(ShopTypes.NeblioTokenShop, account.Address, "La58e9EeXUMx41uyfqk6kgVWAQq9yBs44nuQW8"); } account.Shop.IsActive = true; account.Shop.StartShop(); } } catch (Exception ex) { ; // probably no setting for the shop } } } if (wallets != null && accounts != null) { // this function will load accounts to proper wallets foreach (var w in wallets) { w.NewTransaction += Wall_NewTransaction; w.NewConfirmedTransactionDetailsReceived += WalletHandler_NewTransactionDetailsReceived; if (w != null) { foreach (var a in accounts) { var ltxParsed = accountHandler.GetLastAccountProcessedTxs(a.Address); if (ltxParsed != null) { a.LastConfirmedTxId = ltxParsed.LastConfirmedTxId; a.LastProcessedTxId = ltxParsed.LastProcessedTxId; } a.WalletName = w.Name; a.StartRefreshingData(EconomyMainContext.WalletRefreshInterval); if (a.WalletId == w.Id) { w.Accounts.TryAdd(a.Address, a); } } } } } if (wallets != null) { //refresh main wallet dictionary EconomyMainContext.Wallets.Clear(); foreach (var w in wallets) { EconomyMainContext.Wallets.TryAdd(w.Id.ToString(), w); } } return(true); } catch (Exception ex) { log.Error("Cannot Load and pair wallets and accounts.", ex); return(false); } }
static void ReceiveHander(string[] recv) { int opcode = -1; int idx = -1; try { opcode = Int32.Parse(recv[0]); idx = Int32.Parse(recv[1]); } catch (Exception e) { } if (opcode == -1 || idx == -1) { return; } switch (opcode) { case 0: //getHello break; case 1: //requestShopInfo { sb.Append("1<>"); for (int i = 0; i < shops.Count; i++) { Write packet = new Write(1); packet.writeLine(shops[i].getId().ToString()); packet.writeLine(shops[i].getName().ToString()); packet.writeLine(shops[i].getNumber().ToString()); packet.writeLine(shops[i].getNew().ToString()); packet.writeLine(shops[i].getOld().ToString()); packet.writeLine(shops[i].getCategory().ToString()); packet.writeLine(shops[i].getImage().ToString()); packet.writeLine(shops[i].getStar().ToString()); packet.writeLine(shops[i].getTax().ToString()); packet.writeLine(shops[i].getCompany().ToString()); packet.writeLine(shops[i].getOwner().ToString()); sb.Append(packet.getPacket(true)); packet = null; } sb.Append("<EOF>"); Send(sb.ToString(), idx); sb.Clear(); System.Threading.Thread.Sleep(250); sb.Append("2<>"); for (int i = 0; i < shops.Count; i++) { for (int j = 0; j < shops[i].getItems().Count; j++) { Write packet = new Write(2); ShopItem temp = shops[i].getItems()[j]; packet.writeLine(i.ToString()); packet.writeLine(temp.getShopId().ToString()); packet.writeLine(temp.getName().ToString()); packet.writeLine(temp.getImage().ToString()); packet.writeLine(temp.getPrice().ToString()); packet.writeLine(temp.getCategory().ToString()); sb.Append(packet.getPacket(true)); packet = null; } } sb.Append("<EOF>"); Send(sb.ToString(), idx); sb.Clear(); System.Threading.Thread.Sleep(250); sb.Append("3<>"); for (int i = 0; i < shops.Count; i++) { for (int j = 0; j < shops[i].getReviews().Count; j++) { Write packet = new Write(3); Review temp = shops[i].getReviews()[j]; packet.writeLine(i.ToString()); packet.writeLine(temp.getShopId().ToString()); packet.writeLine(temp.getNickName().ToString()); packet.writeLine(temp.getComment().ToString()); packet.writeLine(temp.getScore().ToString()); sb.Append(packet.getPacket(true)); packet = null; } } sb.Append("<EOF>"); Send(sb.ToString(), idx); sb.Clear(); System.Threading.Thread.Sleep(250); } break; case 3: { int id = Int32.Parse(recv[2]); string nickname = recv[3]; int score = Int32.Parse(recv[4]); string comment = recv[5]; foreach (var shop in shops) { if (shop.getId() == id) { shop.addReview(new Review(nickname, comment, score, id)); } } ShopFactory.saveReview(con, nickname, comment, id, score); } break; } opcode = -1; idx = -1; }