예제 #1
0
 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));
 }
예제 #2
0
        public void AddTicketByContractId_ContractMetId1_VoegtTicketToeBijContract_()
        {
            Ticket t = _klant.AddTicketByContractId(1, new Ticket());

            Assert.Equal(3, _klant.GetContractById(1).NrOfTickets);
        }