public void AVerkoop_Add_TrueVerkoopExists() { lampRepository.GetAll(); Koper koper = new Koper() { Naam = "Jan", Rekeningnummer = "10", Gemeente = "Weert", Straat = "Erk", Huisnummer = "26", PostCode = "3084KI" }; koperRepository.Add(koper); Verkoop verkoop = new Verkoop() { LampId = 1, KoperId = 1, Aantal = 20 }; verkoopRepository.Add(verkoop); verkoopRepository.Save(); Assert.IsTrue(verkoopRepository.GetById(1).Lamp.Model == "Test"); }
private void verwijderVerkoop() { try { if (SelectedVerkoop != null) { Customer cust = Klant; cust.Balance += SelectedVerkoop.Price; Klant = cust; Totaal -= SelectedVerkoop.Price; Verkoop.Remove(SelectedVerkoop); } } catch (Exception ex) { Errorlog err = new Errorlog() { Register = ApplicationVM.register, Message = ex.Message, Stacktrace = ex.StackTrace, Timestamp = UnixTimestamp.ToUnixTimestamp(DateTime.Now) }; Servicelayer.PostLog(err); } }
protected virtual void OnVerkoop(Bestelling bestelling) { //if (Verkoop != null) Verkoop?.Invoke(this, new WinkelEventArgs() { Bestelling = bestelling }); }
public async Task BVerkoop_GetAllVerkopenByModelAsync_TrueIsVerkoopnaamAsync() { lampRepository.GetAll(); Verkoop verkoop = verkoopRepository.GetAll().First(); string searchstring = verkoop.Lamp.Model; var verkopen = await verkoopRepository.GetAllVerkopenByModelAsync(searchstring); Assert.IsTrue(verkopen.First().Lamp.Model == "Test"); }
private void Aantal(string aantal) { try { if (SelectedProduct != null) { Sale sale = new Sale() { Customer = Klant, Product = SelectedProduct, Amount = Convert.ToUInt32(aantal), Price = Convert.ToUInt32(aantal) * SelectedProduct.Price, Timestamp = UnixTimestamp.ToUnixTimestamp(DateTime.Now), Register = ApplicationVM.register }; // Klant.Balance -= sale.Price; if (Klant.Balance - sale.Price <= 0) { Foutmelding = "Er staat te weinig geld op kaart"; } else { Customer cust = Klant; cust.Balance -= sale.Price; Klant = cust; Totaal += sale.Price; Verkoop.Add(sale); } } } catch (Exception ex) { Errorlog err = new Errorlog() { Register = ApplicationVM.register, Message = ex.Message, Stacktrace = ex.StackTrace, Timestamp = UnixTimestamp.ToUnixTimestamp(DateTime.Now) }; Servicelayer.PostLog(err); } }
public async Task <IActionResult> Create([Bind("LampId,Aantal,KoperId")] Verkoop verkoop) { if (ModelState.IsValid) { var lamp = await lampRepository.GetByIdAsync(verkoop.LampId); var koper = await koperRepository.GetByIdAsync(verkoop.KoperId); if (lamp == null || koper == null) { return(NotFound()); } lamp.Aantal -= verkoop.Aantal; lampRepository.Update(lamp); verkoopRepository.Add(verkoop); await verkoopRepository.SaveAsync(); return(RedirectToAction(nameof(Index))); } return(View(verkoop)); }
//---------------- public List <Verkoop> ProductenVerkoop() { List <Verkoop> verkoopList = new List <Verkoop>(); try { conn.Open(); string select = @"SELECT prod.Product_ID , prod.Productnaam , prod.Prijs , SUM(ordregel.Aantal)AS Aantal ," + " SUM(ordregel.Subtotaal) AS Totaal FROM tbl_product prod " + " LEFT JOIN tbl_orderregel ordregel ON prod.Product_ID=ordregel.Product_ID " + " GROUP BY prod.Product_ID ORDER BY Aantal DESC"; MySqlCommand cmd = new MySqlCommand(select, conn); MySqlDataReader datareader = cmd.ExecuteReader(); while (datareader.Read()) { int id = datareader.GetInt32("Product_ID"); string temp; //---null values double totaal; if (!datareader.IsDBNull(4)) { totaal = datareader.GetDouble("Totaal"); } else { totaal = 0; } double prijs = datareader.GetDouble("Prijs"); //---null values int aantal; if (!datareader.IsDBNull(3)) { aantal = datareader.GetInt32("Aantal"); } else { aantal = 0; } string productnaam = datareader.GetString("Productnaam"); Verkoop verkoop = new Verkoop { productID = id, Totaal = totaal, Prijs = prijs, Aantal = aantal, ProductNaam = productnaam }; verkoopList.Add(verkoop); } return(verkoopList); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("ManagementDBController Productenverkoop" + e); return(null); } finally { conn.Close(); } }