public void Insert_Should_InsertArtikel_When_NieuwArtikel_IsGiven() { // Arrange Bestelling bestelling = new BestellingBuilder().SetDummy().Create(); var dataMapper = new BestellingDataMapper(_context); // Act dataMapper.Insert(bestelling); Bestelling result = dataMapper.GetByFactuurnummer(bestelling.Factuurnummer); // Assert Assert.IsNotNull(result); Assert.IsTrue(bestelling.IsEqual(result)); }
private List <Bestelling> ReadTables(DataTable dataTable) { List <Bestelling> bestellingen = new List <Bestelling>(); foreach (DataRow dr in dataTable.Rows) { Bestelling bestelling = new Bestelling() { bestellingID = (int)dr["bestellingID"], bedienerID = (int)dr["bedienerID"], klantID = (int)dr["klantID"] }; bestellingen.Add(bestelling); } return(bestellingen); }
public ActionResult AddKaartje(int evenementId, int aantal, int prijs, SoortKaartje soortKaartje, string bijzonderheden, Dag dag) { Kaartje kaartje = new Kaartje(); kaartje.Aantal = aantal; kaartje.DagEvenement = (int)dag; kaartje.TotaalPrijs = prijs * aantal; kaartje.BijzonderhedenRestaurant = bijzonderheden; kaartje.SoortKaartje = (int)soortKaartje; kaartje.DagEvenement = 3; kaartje.EvenementId = evenementId; Bestelling bestelling = basketRepos.AddBestelling(kaartje); return(View("Index", bestelling)); }
private void Calculation(Bestelling order) { amount = 0; decimal amountWithBtw = 0; foreach (OrderItem o in order.orderItems) { decimal btwPercentage = (decimal)o.menuItem.btwPercentage / 100; amountWithBtw = amountWithBtw + (o.Aantal * o.menuItem.prijs) * (btwPercentage + 1); amount = amount + (o.Aantal * o.menuItem.prijs); } btw = amountWithBtw - amount; bon.totaalprijs = amountWithBtw; }
private void MapBestelRegel(BestellingCM bestellingCM, Bestelling bestelling) { var bestelRegels = bestellingCM?.BestelRegels ?? new List <BestelRegelCM>(); foreach (var regel in bestelRegels) { var artikel = _artikelDataMapper.GetById(regel.Artikelnummer); var regelResult = Mapper.Map <BestelRegel>(artikel); regelResult.Aantal = regel.Aantal; regelResult.PrijsExclBtw = artikel.Prijs; CalculateRegelSum(ref regelResult); bestelling.BestelRegels.Add(regelResult); } }
public IActionResult BeheerBestelling(int id, int bestellingId) { McEditie editie = _editieRepository.GetById(id); if (editie == null) { return(NotFound()); } Bestelling bestelling = editie.GetBestelling(bestellingId); if (bestelling == null) { return(NotFound()); } return(View(new BestellingEditViewModel(bestelling))); }
// GET: ShoppingCart public ActionResult Index() { shoppingCartDataService = new ShoppingCartDataService(); bestellingService = new BestellingService(); Bestelling bestelling = bestellingService.GetBestellingMetTicketsByUser(User.Identity.GetUserId()); // ViewModel opvullen ShoppingCart shoppingCart = new ShoppingCart(); shoppingCart.Bestelling = bestelling; shoppingCart.ShoppingCartItems = bestelling.ShoppingCartDatas; shoppingCart.Tickets = bestelling.Tickets; shoppingCart.TotaalPrijs = shoppingCartDataService.berekenTotaalPrijs(bestelling); return(View(shoppingCart)); }
public long Insert(Bestelling obj) { long result = 0; try { string sql = "INSERT INTO Bestelling(Accountid, BestelDatum, LeverDatum, TotaalPrijs, Postcode, Huisnummer) OUTPUT Inserted.Id VALUES(@accountid, @besteldatum, @leverdatum, @totaalprijs, @postcode, @huisnummer)"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("accountid", obj.KlantId.ToString()), new KeyValuePair <string, string>("besteldatum", DateTime.Now.ToString("yyyy-MM-dd")), new KeyValuePair <string, string>("leverdatum", obj.Leverdatum.ToString("yyyy-MM-dd")), new KeyValuePair <string, string>("totaalprijs", obj.Totaalprijs), new KeyValuePair <string, string>("postcode", obj.Postcode), new KeyValuePair <string, string>("huisnummer", obj.Huisnummer), }; result = ExecuteInsert(sql, parameters); } catch (Exception e) { throw e; } foreach (Product p in obj.Products) { try { string sql = "INSERT INTO ProductBestelling(ProductId, BestellingId, Aantal) VALUES(@productId, @bestellingId, @aantal)"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("productId", p.Id.ToString()), new KeyValuePair <string, string>("bestellingId", result.ToString()), new KeyValuePair <string, string>("aantal", p.Aantal.ToString()), }; ExecuteSql(sql, parameters); } catch (Exception e) { throw e; } } return(result); }
public void HandlePlaatsBestelling_ShouldCallInsertOnDataMapper() { var artikel = new ArtikelBuilder() .SetArtikelNummer(1) .SetLeveranciercode("1-abc-xyz") .SetNaam("Fietsband") .SetPrijs(12.99m) .Create(); var bestellingCM = new BestellingCM { Klantnummer = 1234, ContactInfo = new ContactInfoCM(), Afleveradres = new AfleveradresCM(), BestelRegels = new List <BestelRegelCM> { new BestelRegelCM { Artikelnummer = 1, Aantal = 2 }, } }; Bestelling bestelling = null; _artikelDataMapperMock.Setup(a => a.GetById(1)).Returns(artikel); _bestellingDataMapperMock.Setup(m => m.Insert(It.IsAny <Bestelling>())) .Callback <Bestelling>(b => { b.Id = 42; bestelling = b; }) .Returns(bestelling); _bestellingDataMapperMock.Setup(m => m.Update(It.IsAny <Bestelling>())) .Callback <Bestelling>(b => bestelling = b); _eventPublisherMock.Setup(p => p.Publish(It.IsAny <DomainEvent>())); var requestCommand = new PlaatsBestellingCommand(bestellingCM, NameConstants.BestelServicePlaatsBestellingCommandQueue); var result = _target.HandlePlaatsBestelling(requestCommand); _bestellingDataMapperMock.VerifyAll(); _artikelDataMapperMock.VerifyAll(); _eventPublisherMock.VerifyAll(); Assert.AreEqual(42, result); Assert.AreEqual(42, bestelling.Factuurnummer); Assert.AreEqual(DateTime.Now.Date, bestelling.Besteldatum.Date); Assert.AreEqual(BestelStatus.Geplaatst, bestelling.BestelStatus); }
//Julian Remmers, Vraagt de bestellingen op voor Bar en Keuken public List <Bestelling> GetAllBestellingen(string locatieid) { List <Bestelling> bestelling = new List <Bestelling>(); string com; conn.Open(); if (locatieid == "Bar") { com = "SELECT * FROM Bestelling INNER JOIN Bestel_Item ON Bestelling.ID = Bestel_Item.Bestel_ID INNER JOIN Menu_Item ON Bestel_Item.Menu_Item_ID = Menu_Item.ID INNER JOIN Menu_Categorie ON Menu_Item.Menu_Categorie_ID = Menu_Categorie.ID INNER JOIN Menu_Kaart ON Menu_Categorie.Menu_Kaart_ID = Menu_Kaart.ID WHERE Menu_Kaart.ID = 1 AND Bestelling.Betaald = 0"; } else { com = "SELECT * FROM Bestelling INNER JOIN Bestel_Item ON Bestelling.ID = Bestel_Item.Bestel_ID INNER JOIN Menu_Item ON Bestel_Item.Menu_Item_ID = Menu_Item.ID INNER JOIN Menu_Categorie ON Menu_Item.Menu_Categorie_ID = Menu_Categorie.ID INNER JOIN Menu_Kaart ON Menu_Categorie.Menu_Kaart_ID = Menu_Kaart.ID WHERE Menu_Kaart.ID != 1 AND Bestelling.Betaald = 0"; } SqlCommand command = new SqlCommand(com, conn); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Bestelling item = ReadBestellingen(reader); // Kayleigh, zorgt ervoor dat er niet meerdere bestellingen met overeenkomdend ID in de lijst komen bool gelijk = false; foreach (Bestelling b in bestelling) { if (b.ID == item.ID) { gelijk = true; } } if (gelijk) { continue; } else { bestelling.Add(item); } } reader.Close(); conn.Close(); return(bestelling); }
public ProductenScherm(KassaApp app, Bestelling bestelling) { InitializeComponent(); App = app; if (App.GetIsGemachtigd()) { if (bestelling == null) { btRemove.Enabled = true; } else { btRemove.Enabled = false; } } UpdateProducten(bestelling); }
public async Task HandleUpdateBestelStatus_ShouldLowerStockWhenBestelStatusVerzonden() { // Arrange var artikel = new ArtikelBuilder() .SetArtikelNummer(1) .SetLeveranciercode("1-abc-xyz") .SetNaam("Fietsband") .SetPrijs(12.99m) .Create(); var existing = new Bestelling { Klantnummer = 1234, BestelStatus = BestelStatus.WordtIngepakt, ContactInfo = new ContactInfo(), Afleveradres = new Afleveradres(), BestelRegels = new List <BestelRegel> { new BestelRegel { Artikelnummer = 1, Aantal = 2 }, } }; var bestelStatusCommand = new UpdateBestelStatusCommand(1, BestelStatus.Verzonden, NameConstants.BestelServiceUpdateBestelStatusCommandQueue); _bestellingDataMapperMock.Setup(m => m.GetByFactuurnummer(1)).Returns(existing); _bestellingDataMapperMock.Setup(m => m.Update(It.IsAny <Bestelling>())); _eventPublisherMock.Setup(publisher => publisher.Publish(It.IsAny <DomainEvent>())); var response = new ResponseCommandMessage(JsonConvert.SerializeObject(true), "type", "correlationId"); _commandSenderMock.Setup(sendr => sendr.SendCommandAsync(It.Is <RequestCommandMessage>(cm => cm.RoutingKey == NameConstants.MagazijnServiceCommandQueue && cm.Type == NameConstants.MagazijnServiceHaalVoorraadUitMagazijnCommand ))).ReturnsAsync(response); // Act await _target.HandleUpdateBestelStatus(bestelStatusCommand); // Assert _nijnContextMock.VerifyAll(); _bestellingDataMapperMock.VerifyAll(); _eventPublisherMock.VerifyAll(); _commandSenderMock.VerifyAll(); }
private List <Bestelling> ReadOrders(DataTable dataTable) { List <Bestelling> bestellingen = new List <Bestelling>(); foreach (DataRow dr in dataTable.Rows) { Bestelling bestelling = new Bestelling() { bestelling_ID = (int)dr["bestelling_ID"], commentaar = (String)(dr["commentaar"].ToString()), datum = (DateTime)dr["datum"], tafel_ID = (int)dr["tafel_ID"] }; bestellingen.Add(bestelling); } return(bestellingen); }
public List <Bestelling> GetRangedOrders(DateTime startDate, DateTime endDate) { try { return(bestelling_db.GetRangeOfOrders(startDate, endDate)); } catch (Exception) { List <Bestelling> fakeorderlist2 = new List <Bestelling>(); Bestelling neporder2 = new Bestelling(1, DateTime.Now, 2, 1, 1); fakeorderlist2.Add(neporder2); return(fakeorderlist2); } }
public List <Bestelling> GetOrders() { try { return(bestelling_db.GetAllOrders()); } catch (Exception) { List <Bestelling> fakeorderlist = new List <Bestelling>(); Bestelling neporder = new Bestelling(1, DateTime.Now, 2, 1, 1); fakeorderlist.Add(neporder); return(fakeorderlist); } }
public void GetByFactuurnummer_Should_ReturnBestellingWithCertainId_When_Factuurnummer_IsGiven() { // Arrange Bestelling bestelling = new BestellingBuilder().SetDummy().Create(); _betaalContext.Bestellingen.Add(bestelling); _betaalContext.SaveChanges(); var dataMapper = new BestellingDataMapper(_betaalContext); // Act Bestelling result = dataMapper.GetByFactuurnummer(bestelling.Factuurnummer); // Assert Assert.IsNotNull(result); Assert.AreEqual(bestelling.Factuurnummer, result.Factuurnummer); }
public ActionResult Details(int evenementId, int aantal, int prijs, SoortKaartje soortKaartje, string bijzonderheden, int dag) { IBasketRepository basketRepos = new BasketRepository(); Kaartje kaartje = new Kaartje(); kaartje.Aantal = aantal; kaartje.DagEvenement = dag; kaartje.TotaalPrijs = prijs * aantal; kaartje.BijzonderhedenRestaurant = bijzonderheden; kaartje.SoortKaartje = (int)soortKaartje; kaartje.DagEvenement = 3; kaartje.EvenementId = evenementId; Bestelling bestelling = basketRepos.AddBestelling(kaartje); return(View("Index", restaurantRepos.GetAllRestaurants())); }
public ActionResult AddBestelling() { //instantiate the product repository var bestelling = new Bestelling(); //for get product categories from database var gerechten = ki.GetFullList(); //for initialize viewmodel var bestellingViewModel = new ViewModels.BestellingViewModel(); //assign values for viewmodel bestellingViewModel.Gerechts = gerechten; //send viewmodel into UI (View) return(View("AddProduct", bestellingViewModel)); }
private List <Bestelling> ReadTablesList(DataTable dataTable) // Sander Brijer 646235 { List <Bestelling> bestellingen = new List <Bestelling>(); foreach (DataRow r in dataTable.Rows) { Bestelling bestelling = new Bestelling() { BestellingId = (int)r["BestellingId"], TafelId = (int)r["TafelId"], MedewerkerId = (int)r["MedewerkerId"], TijdBestelling = (DateTime)r["TijdBestelling"] }; bestellingen.Add(bestelling); } return(bestellingen); }
public void GetById_Should_ReturnBestellingWithCertainId_When_Id_IsGiven() { // Arrange Bestelling bestelling = new BestellingBuilder().SetDummy().Create(); _context.Bestellingen.Add(bestelling); _context.SaveChanges(); var dataMapper = new BestellingDataMapper(_context); // Act Bestelling result = dataMapper.GetById(bestelling.Id); // Assert Assert.IsNotNull(result); Assert.IsTrue(bestelling.IsEqual(result)); }
//Haal orderID op. public int getOrderNr(Bestelling _bestelling) { MySqlConnection sqlConn = new MySqlConnection(ConnStr); sqlConn.Open(); string query = "select ordernr from tblbestelling where klantnr =" + _bestelling.KlantNr + " order by ordernr asc"; MySqlCommand sqlCmd = new MySqlCommand(query, sqlConn); MySqlDataReader reader = sqlCmd.ExecuteReader(); int OrderID = 0; while (reader.Read()) { OrderID = Convert.ToInt32(reader["OrderNr"]); } sqlConn.Close(); return(OrderID); }
public IActionResult Index(WinkelwagenViewModel vm) { Bestelling bestelling = new Bestelling { KlantId = GetUserId() }; bestelling = ConstructBestelling(bestelling); long result = bestellingRepository.Insert(bestelling); if (result != -1) { HttpContext.Session.Clear(); return(RedirectToAction("Geplaatst")); } return(RedirectToAction("Mislukt")); }
//Verandert de status naar afgerond van een bestelling. public IActionResult Afronden(BestellingDetailViewModel vm) { Bestelling b = new Bestelling(); b = BestellingConverter.DetailViewModelToModel(vm); bool succes = BestellingRepo.UpdateBestelling(b.ReserveringID, b.GerechtID, b.Ronde, b.Aantal, b.Naam, "Ontvangen", b.Ronde); if (succes) { return(Bestellingen(b.ReserveringID)); } else { return(View("AfrondenFail")); } }
public async Task <IActionResult> Create([Bind("Id,Aantal,ConsumptieId,TafelsId,Bestellingsdatum_Tijd,Afgerond")] Bestelling bestelling) { List <Category> categoryList = _context.Categories.ToList(); bestelling.Bestellingsdatum_Tijd = DateTime.Now; bestelling.Afgerond = false; if (ModelState.IsValid) { _context.Add(bestelling); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ConsumptieId"] = new SelectList(_context.Consumpties, "Id", "Id", bestelling.ConsumptieId); ViewData["TafelsId"] = new SelectList(_context.Tafels, "Id", "Id", bestelling.TafelsId); return(View(bestelling)); }
public async Task <IActionResult> Create([Bind("Id,Status,Betaald,KlantId,Tijdslot,Opmerkingen")] Bestelling bestelling) { await ControleerWijzigingen(null, bestelling); if (ModelState.IsValid) { _context.Add(bestelling); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Edit), new { id = bestelling.Id })); } else { ViewData["KlantId"] = new SelectList(_context.Klanten, "Id", "Email", bestelling.KlantId); return(View(bestelling)); } }
private void converteerPdf(Bestelling bestelling) { // Create a new Microsoft Word application object Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); // C# doesn't have optional arguments so we'll need a dummy value object oMissing = System.Reflection.Missing.Value; // Get list of Word files in specified directory FileInfo wordFile = new FileInfo(@"C:\Users\Giovanni\Documents\Facturen\" + "Factuur_" + bestelling.id + ".docx"); word.Visible = false; word.ScreenUpdating = false; // Cast as Object for word Open method Object filename = (Object)wordFile.FullName; // Use the dummy value as a placeholder for optional arguments Document doc = word.Documents.Open(ref filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); doc.Activate(); object outputFileName = wordFile.FullName.Replace(".docx", ".pdf"); object fileFormat = WdSaveFormat.wdFormatPDF; // Save document into PDF Format doc.SaveAs(ref outputFileName, ref fileFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); object saveChanges = WdSaveOptions.wdDoNotSaveChanges; ((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing); doc = null; ((_Application)word).Quit(ref oMissing, ref oMissing, ref oMissing); word = null; File.Delete(@"C:\Users\Giovanni\Documents\Facturen\" + "Factuur_" + bestelling.id + ".docx"); }
// Kayleigh private BestelItem ReadBestelItem(SqlDataReader reader) { try { int BestelItemID = reader.GetInt32(0); int bestelId = reader.GetInt32(1); int menuItemID = reader.GetInt32(2); int aantal = reader.GetInt32(3); Status status = (Status)Enum.Parse(typeof(Status), reader.GetString(4)); string opmerking = reader.GetString(5); double BestelItemPrijs = reader.GetDouble(6); DateTime bestelItemTijd = reader.GetDateTime(7); string MenuItemNaam = reader.GetString(9); double MenuItemPrijs = reader.GetDouble(10); int MenuItemVoorraad = reader.GetInt32(11); int MenuCatId = reader.GetInt32(12); int tafelId = reader.GetInt32(14); int medId = reader.GetInt32(15); bool betaald = reader.GetBoolean(16); string menuCatNaam = reader.GetString(18); int btw = reader.GetInt32(19); int MenuKaartId = reader.GetInt32(20); string menukaartNaam = reader.GetString(22); bool tafelstatus = reader.GetBoolean(24); string voornaam = reader.GetString(26); string achternaam = reader.GetString(27); Functie functie = (Functie)Enum.Parse(typeof(Functie), reader.GetString(28)); string wachtwoord = reader.GetString(29); MenuKaart kaart = new MenuKaart(MenuKaartId, menukaartNaam); Menucategorie cat = new Menucategorie(MenuCatId, menuCatNaam, btw, kaart); MenuItem menuitem = new MenuItem(menuItemID, MenuItemNaam, MenuItemPrijs, MenuItemVoorraad, cat); Tafel tafel = new Tafel(tafelId, tafelstatus); Medewerker med = new Medewerker(medId, voornaam, achternaam, functie, wachtwoord); Bestelling best = new Bestelling(bestelId, betaald, tafel, med); BestelItem bestelItem = new BestelItem(BestelItemID, best, menuitem, BestelItemPrijs, aantal, status, opmerking, bestelItemTijd); return(bestelItem); } catch { return(null); } }
public void HandlePlaatsBestelling_ShouldPublishBestellingGeplaatstEvent() { var artikel = new ArtikelBuilder() .SetArtikelNummer(1) .SetLeveranciercode("1-abc-xyz") .SetNaam("Fietsband") .SetPrijs(12.99m) .Create(); var bestellingCM = new BestellingCM { Klantnummer = 1234, ContactInfo = new ContactInfoCM(), Afleveradres = new AfleveradresCM(), BestelRegels = new List <BestelRegelCM> { new BestelRegelCM { Artikelnummer = 1, Aantal = 2 }, } }; Bestelling bestelling = null; _artikelDataMapperMock.Setup(a => a.GetById(1)).Returns(artikel); _bestellingDataMapperMock.Setup(m => m.Insert(It.IsAny <Bestelling>())) .Callback <Bestelling>(b => { b.Id = 42; bestelling = b; }) .Returns(bestelling); _bestellingDataMapperMock.Setup(m => m.Update(It.IsAny <Bestelling>())); _eventPublisherMock.Setup(e => e.Publish(It.Is <BestellingGeplaatstEvent>(evt => evt.RoutingKey == NameConstants.BestelServiceBestellingGeplaatstEvent && evt.Bestelling == bestelling ))).Verifiable("Publish event should be called"); var requestCommand = new PlaatsBestellingCommand(bestellingCM, NameConstants.BestelServicePlaatsBestellingCommandQueue); _target.HandlePlaatsBestelling(requestCommand); _bestellingDataMapperMock.VerifyAll(); _artikelDataMapperMock.VerifyAll(); _eventPublisherMock.VerifyAll(); }
public async Task KeurBestellingGoedChangesBestellingToGereedVoorBehandeling() { using (var context = new BeheerContext(options)) { var bestelling = new Bestelling { Id = 1, KlantId = "1", AdresRegel1 = "Laagstraat 11", Plaats = "Laaghoven", Postcode = "1234FG", BestellingStatus = BestellingStatus.TerControleVoorSales, BesteldeArtikelen = new List <BestellingItem> { new BestellingItem(1, 3) { Id = 1 }, new BestellingItem(2, 5) { Id = 2 } } }; var datamapper = new BestellingDatamapper(context); await datamapper.Insert(bestelling); } var commandPublisher = new CommandPublisher(_context); await commandPublisher.Publish <int>(new BestellingGoedkeurenCommand { Id = 1 }, NameConstants.BestellingGoedKeurenCommandQueue); Thread.Sleep(1000); using (var context = new BeheerContext(options)) { var datamapper = new BestellingDatamapper(context); var result = await datamapper.GetBestelling(1); Assert.AreEqual(BestellingStatus.GereedVoorBehandeling, result.BestellingStatus); var klantmapper = new KlantDatamapper(context); var klant = await klantmapper.GetKlant("1"); } }
public ActionResult PutBestelling(int id, [FromBody] Bestelling value) { if (id != value.BestellingID) { return(BadRequest()); } var OldBestelling = _context.Bestellingen.Find(id); OldBestelling.Korting = value.Korting; OldBestelling.prijs = value.prijs; OldBestelling.beschrijving = value.beschrijving; _context.SaveChangesAsync(); return(NoContent()); }