public ActionResult AddPsu(string name, int manufacturerId, string model, string link, int formFactorId, int power, string efficiency, string image, int shopId) { if (Request.IsAuthenticated && User.Identity.Name == "admin") { var psuToAdd = new Psu() { Name = name, ManufacturerId = manufacturerId, Model = model, Link = link, FormFactorId = formFactorId, Power = power, Efficiency = efficiency, Image = image, ShopId = shopId }; context.Psu.Add(psuToAdd); context.SaveChanges(); return(RedirectToAction("PsuAddForm")); } else { return(RedirectToAction("Index", "Home")); } }
/// PSU public void PsuAddToBuild(Psu psu) { var build = NewBuild(); build.Psu = psu; session.Set(SessionNames.BuildSessionKey, build); }
static void Main(string[] args) { System.Console.WriteLine("Build your PC today"); // Użytkownik wszedł do sklepu User user = new User(); Ram ram = new Ram(); Psu psu = new Psu(); Cpu cpu = new Cpu(); // Chciałbym kupić komputer Pc newlyCreatedPc = new Pc(cpu, psu, ram); // Czy komputer działa? if (!(newlyCreatedPc.HasRequiredComponents() && newlyCreatedPc.HasPostivePowerBalance())) { System.Console.WriteLine("Nie działa, nie sprzedajemy"); } else { // Płacę za komputer! user.AddPc(newlyCreatedPc); } }
public static string GetPrice(Psu c) { using (WebClient webClient = new WebClient()) { webClient.Encoding = Encoding.UTF8; string html = webClient.DownloadString(c.Link); HtmlDocument pageDocument = new HtmlDocument(); pageDocument.LoadHtml(html); if (c.Shop.Name == "Sferis") { if (html.ToString().Contains("Produkt chwilowo niedostępny")) { return("Produkt niedostępny"); } else { var prize = pageDocument.DocumentNode.SelectSingleNode("//div[@class='" + c.Shop.Class + "']/span"); return(prize.InnerHtml.ToString()); } } else if (c.Shop.Name == "Media Expert") { var prize = pageDocument.DocumentNode.SelectSingleNode("//p[@class='" + c.Shop.Class + "']"); var prizeMod = prize.InnerHtml.ToString().Replace("<span>", ",").Replace("</span>", "") + " zł"; return(prizeMod); } else if (c.Shop.Name == "Vobis") { if (html.ToString().Contains("Produkt niedostępny")) { return("Produkt niedostępny"); } else { var prize = pageDocument.DocumentNode.SelectSingleNode("//div[@class='" + c.Shop.Class + "']/span"); var prizeMod = prize.InnerHtml.ToString().Replace("PLN", "zł"); return(prizeMod); } } else { var prize = pageDocument.DocumentNode.SelectSingleNode("//div[@class='" + c.Shop.Class + "']"); return(prize.InnerHtml.ToString()); } } }
public Pc(Cpu cpu, Psu psu, Ram ram) { this.Cpu = cpu; this.Psu = psu; this.Ram = ram; }