public IActionResult Create(TicketEditViewModel tevm, Klant klant) { if (ModelState.IsValid) { try { Ticket ticket = new Ticket(); MapTicketEditViewModelToTicket(tevm, ticket); TicketType ticketType = _ticketTypeRepository.GetBy(tevm.TicketTypeId); ticket.TicketType = ticketType; klant.AddTicketByContractId(tevm.ContractId, ticket); _gebruikerRepository.SaveChanges(); _notyf.Success("Ticket succesvol aangemaakt", 3); } catch { _notyf.Error("Er is iets misgelopen. Probeer opnieuw.", 3); } return(RedirectToAction(nameof(Index))); } ViewData["IsEdit"] = false; ViewData["ticketTypes"] = GetTicketTypesAsSelectList(); return(View(nameof(Edit), tevm)); }
public void AddTicketByContractId_ContractMetId1_VoegtTicketToeBijContract_() { Ticket t = _klant.AddTicketByContractId(1, new Ticket()); Assert.Equal(3, _klant.GetContractById(1).NrOfTickets); }