public IActionResult Details(int id) { Madbestillings madbestillings = madbestillingRepository.Get(id); MadmenuBestillingVM vm = ViewModelCreator.createMadmenuBestillingVM(madmenuRepository); vm.Madbestillings = madbestillings; return(View(vm)); }
public void AddNewMadbestillingToDatabase() { IMadbestillingRepository testRepo = DataTestService.GetInMemoryRepo(); var madbestillings = new Madbestillings() { MenuTekst = "Burger", AntalBestillinger = 1 }; testRepo.Save(madbestillings); Assert.Single(testRepo.Get()); Assert.Equal(madbestillings.MenuTekst, testRepo.Get(1).MenuTekst); }
// GET: Madbestillings/Edit/5 public IActionResult Edit(int id) { Madbestillings madbestillings = madbestillingRepository.Get(id); if (madbestillings == null) { return(NotFound()); } MadmenuBestillingVM vm = ViewModelCreator.createMadmenuBestillingVM(madmenuRepository); vm.Madbestillings = madbestillings; return(View(vm)); // Create an edit view // Look up cat object from catId in the database // Show an edit view to the user, displaying the cat object }
public void DeleteMadbestillingFromDatabase() { IMadbestillingRepository testrepo = DataTestService.GetInMemoryRepo(); var madbestillings = new Madbestillings() { MenuTekst = "Burger", AntalBestillinger = 1 }; testrepo.Save(madbestillings); testrepo.Delete(testrepo.Get(1).MadbestillingId); Assert.Empty(testrepo.Get()); }
public void MadbestillingWithSameIDOverWritesCurrentMadbestillingInDB() { IMadbestillingRepository testrepo = DataTestService.GetInMemoryRepo(); var madbestillings = new Madbestillings() { MenuTekst = "Burger", AntalBestillinger = 1 }; testrepo.Save(madbestillings); var sameMadbestilling = testrepo.Get(1); sameMadbestilling.MenuTekst = "Burger2"; testrepo.Save(sameMadbestilling); Assert.Single(testrepo.Get()); Assert.Equal(sameMadbestilling.MenuTekst, testrepo.Get(1).MenuTekst); }