public async Task <IActionResult> PutBaskets(string id, Baskets baskets) { if (id != baskets.Id) { return(BadRequest()); } _context.Entry(baskets).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BasketsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private static void AddToBasket() { int quantita = 1; string descrizione; Console.WriteLine("Inserisci la descrizione :"); descrizione = Console.ReadLine(); Console.WriteLine("Inserisci la quantita :"); quantita = int.Parse(Console.ReadLine()); Article myArticleSearched = Articles.SearchArticle(descrizione); //Finishing the ecommerce structure (#6) if (!(myArticleSearched == null)) { Console.WriteLine("l'id ricercato è " + myArticleSearched.Id_article); Basket myBasket = new Basket(myArticleSearched, quantita, myDefaultCustomer); Baskets.AddtoList(myBasket); Baskets.List(); Console.WriteLine($"{descrizione} aggiunto al basket"); } else { Console.WriteLine($"{descrizione} non trovato"); } Baskets.List(); }
//adds object to user's basket public Baskets AddObjectToUserBasket(string userID, Product product) { Baskets basket = activelist[userID]; basket.AdditemToBasket(product); return(basket); }
public void PrintBaskets(Baskets baskets, Products products, TaxRates taxrates) { _baskets = baskets; _products = products; _taxrates = taxrates; _baskets.Basket.ForEach(delegate(Basket basket) { PrintBasket(basket); }); }
public bool AddBasket(string email, Baskets basket) { var context = new StoreManagementDbContext(); var cust = context.Set <Customer>().SingleOrDefault(Customer => Customer.Email == email); int cid = cust.CustomerId; int bid = basket.BasketsId; var bs = context.Set <Baskets>().SingleOrDefault(b => b.BasketsId == bid); bs.Customer = cust; cust.Baskets.Add(bs); context.SaveChanges(); return(true); }
internal void AddBasket(int id, string name, string sellerName) { if (Baskets.ContainsKey(id)) { return; } var basket = new Basket { Name = name, SellerName = sellerName }; Baskets.Add(id, basket); }
//releases object in the pool, and removes from dict public void ReleaseObject(Baskets obj, string userID) { if (activelist.ContainsKey(userID)) { //releases the basket back to the objpool objPool.Release(activelist[userID]); //removes it from the dictionary activelist.Remove(userID); } else { //throws exception if userID not in dict throw new ArgumentException("activeList dictionary doesn't contain the userID key", "UserID"); } }
public virtual async Task <IActionResult> OnGetSelectAsync(string id, string sortOrder, string searchString, int pageIndex, string fixedFilter, string fixedValue) { Product p = await db.Get(id); Basket b = await Baskets.GetLatestForUser(User.Identity.Name); BasketItem i = await BasketItems.Add(b, p); var url = new Uri($"{basketItemsPage}/Edit?handler=Edit" + $"&id={i.Id}" + $"&fixedFilter={nameof(i.BasketId)}" + $"&fixedValue={b.Id}", UriKind.Relative); return(Redirect(url.ToString())); }
public Baskets DeserializeBaskets() { Baskets baskets = null; path = @"Resources\Baskets.xml"; projectFolder = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; file = Path.Combine(projectFolder, path); serializer = new XmlSerializer(typeof(Baskets)); reader = new StreamReader(file); baskets = (Baskets)serializer.Deserialize(reader); reader.Close(); return(baskets); }
//gets object from pool, and adds it to the dict public static void GetObjectPool(string userID) { //gets object from the pool Baskets obj = objPool.Get(); if (obj == null) { Console.WriteLine("Basket obj is null"); } else { Console.WriteLine("Adding to object pool"); } //moves it to the dictionary activelist.Add(userID, obj); }
public string GetBasketString(int uid) { var builder = new StringBuilder(); int count = 0; decimal value = 0m; var baskets = Baskets.Include(b => b.Good).AsEnumerable().Where(b => b.UserID == uid && !GetIsPlaced(b.ID)); foreach (var item in baskets) { count += item.GoodCount; value += item.Good.Value * item.GoodCount; } builder.Append($"{count}"); if (count > 10 && count <= 20) { builder.Append(" товаров"); } else { switch (count % 10) { case 0: case 5: case 6: case 7: case 8: case 9: builder.Append(" товаров"); break; case 1: builder.Append(" товар"); break; case 2: case 3: case 4: builder.Append(" товара"); break; } } builder.Append($" на сумму {value:# ##0.00} рублей"); return(builder.ToString()); }
private void btnBuy_Click(object sender, RoutedEventArgs e) { try { if (Baskets == null || !Baskets.Any(b => b.IsSelected)) { MessageBox.Show("Warning! You must select at least one basket to buy.", "TAS", MessageBoxButton.OK, MessageBoxImage.Warning); } else { _saleService.Sell(Baskets); } } catch (Exception exception) { MessageBox.Show("Buy error! Please, contact the support at the desk information.", "TAS", MessageBoxButton.OK, MessageBoxImage.Error); NLog.LogManager.GetLogger("LogErrori").Error(exception); } }
public async Task <ActionResult <Baskets> > PostBaskets(Baskets baskets) { _context.Baskets.Add(baskets); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (BasketsExists(baskets.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetBaskets", new { id = baskets.Id }, baskets)); }
static void CreateCompleteOrder() { // conteggio i numeri di articoli del file csv valorizzando la lista articles Console.WriteLine("il numero di articoli è :" + Articles.Count()); //Milestone 1 Customer myCustomer1 = new Customer("Francesco", "Rossi", "*****@*****.**"); Customer myCustomer2 = new Customer("Alberto", "Bianchi", "*****@*****.**"); Admin myAdmin = new Admin(); myAdmin.SetAdministrator(true); myAdmin.AggiungiUser("lore", "ctt", "lore@aaa"); //Milestone 2 Articles.List(); Article myArticle1 = new Article("Videocassetta", (decimal)12.4); Articles.Add(myArticle1); Article myArticle2 = new Article("martello", (decimal)90.0); Articles.Add(myArticle2); Article myArticle3 = new Article("pinza", (decimal)10.5); Articles.Add(myArticle3); Articles.List(); Console.WriteLine($"stampo in console il prezzo del martello: {Articles.SearchArticle("martello").Price}"); Console.WriteLine("adesso il numero di articoli è :" + Articles.Count()); //----------- //Milestone 3 Basket Basket1 = new Basket(myArticle1, 20, myCustomer1); //aggiungo un articolo nel carrello // Basket1.Add(myArticle1, 20, myCustomer1); Baskets.AddtoList(Basket1); /// ------------------------------- Article myart = new Article(); myart = Articles.SearchArticle("martello"); // ricerco una descrizione e ritorno un articolo Milestone 2 Basket Basket2 = new Basket(myart, 20, myCustomer1); //Creo e valorizzo il basket Baskets.AddtoList(Basket2); // aggiungo il basket alla lista //------------- Baskets.ElencaTutti(); // elenca gli articoli inseriti del basket // ----- Console.WriteLine($"----- prezzo totale del cliente myCustomer1 è = {Baskets.TotalPrice(myCustomer1)}"); //----------------------- // esercizio 10 // Articles.WriteToFileCSV(); // SALVA LA LISTA ARTICOLI dalla classe // Baskets.WriteToFileCSV(); // SALVA LA LISTA DEL CARRELLO //------------------- }
private static bool MainMenu() { Console.Clear(); Console.WriteLine("Scegli una opzione :"); // Console.WriteLine("1a) Login cliente TODO"); //Console.WriteLine("1b) Login Amministratore "); Console.WriteLine("1c) Lista articoli "); Console.WriteLine("2) Inserimento articolo "); Console.WriteLine("3) Ricerca articolo per descrizione"); Console.WriteLine("4) Cancellazione articolo "); Console.WriteLine("5) Inserimento articolo nel carrello "); Console.WriteLine("6) Lista del carrello e importo totale"); //Console.WriteLine("7) Crea ordine "); //Console.WriteLine("8) "); //Console.WriteLine("9) "); Console.WriteLine("---------------------"); Console.WriteLine("11) Test Vari "); Console.WriteLine("q) Esci"); Console.Write("\r\nSelect an option: "); switch (Console.ReadLine()) { case "1c": Console.Clear(); Console.WriteLine("LISTA ARTICOLI :"); Articles.List(); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "2": Console.Clear(); Console.WriteLine("2) Inserimento articolo "); CreaArticolo(); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "3": Console.Clear(); Console.WriteLine("Ricerca per descrizione"); RicercaArticolo(); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "4": Console.WriteLine("Cancellazione articolo in anagrafica "); CancellaArticolo(); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "5": Console.Clear(); Console.WriteLine("5) Inserimento articolo nel carrello "); AddToBasket(); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "6": Console.Clear(); Baskets.List(); Console.WriteLine($"--- prezzo totale del cliente myDefaultCustomer è = {Baskets.TotalPrice(myDefaultCustomer)}"); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "7": Console.Clear(); Console.WriteLine("TODO"); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "8": Console.Clear(); Console.WriteLine("TODO"); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "9": // Console.Clear(); Console.WriteLine("TODO"); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "10": Console.Clear(); Console.WriteLine("TODO"); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Premere un tasto per continuare"); Console.ReadLine(); return(true); case "11": Console.Clear(); return(CodiceVarioTest.MainMenuTestVari()); case "q": return(false); default: return(true); } }
private App() { m_Books = new Books(m_Authors, m_Genres); m_Baskets = new Baskets(m_Books, m_Users); }
internal Basket GetBasket(int id) { return(Baskets.ContainsKey(id) ? Baskets[id] : null); }
//get user's basket public Baskets GetUserBasket(string userID) { Baskets basket = activelist[userID]; return(basket); }