private static void ActionCreateTicket() { int accountNumber = 0; string problem = ""; string device = ""; Console.Write("Is het een hardware probleem (j/n)? "); bool isHardwareProblem = (Console.ReadLine().ToLower() == "j"); if (isHardwareProblem) { Console.Write("Naam van het toestel: "); device = Console.ReadLine(); } Console.Write("Gebruikersnummer: "); accountNumber = Int32.Parse(Console.ReadLine()); Console.Write("Probleem: "); problem = Console.ReadLine(); if (!isHardwareProblem) { mgr.AddTicket(accountNumber, problem); } else { mgr.AddTicket(accountNumber, device, problem); } }
private static void ActionCreateTicket() { var accountNumber = 0; var problem = ""; var device = ""; Write("Is het een hardware probleem (j/n)? "); var isHardwareProblem = ReadLine().ToLower() == "j"; if (isHardwareProblem) { Write("Naam van het toestel: "); device = ReadLine(); } Write("Gebruikersnummer: "); accountNumber = int.Parse(ReadLine()); Write("Probleem: "); problem = ReadLine(); if (!isHardwareProblem) { Ticket ticket = mgr.AddTicket(accountNumber, problem); } else { mgr.AddTicket(accountNumber, device, problem); } }
public void AddTicketWithInvalidQuestionThrowsValidationException(string question) { _repository = Substitute.For <ITicketRepository>(); _mgr = new TicketManager(_repository); Assert.Throws <ValidationException>(() => _mgr.AddTicket(1, question)); }
public IActionResult Create(/*int accId, string problem*/ CreateTicketViewModel createTicket) { Ticket newTicket = mgr.AddTicket(/*accId*/ createTicket.AccId, /*problem*/ createTicket.Problem); cache.Remove("TicketList"); return(RedirectToAction("Details", new { id = newTicket.TicketNumber })); }
public ActionResult Create(Ticket ticket) { if (ModelState.IsValid) { ticket = mgr.AddTicket(ticket.AccountId, ticket.Text); //ticket = client.CreateTicket(ticket.AccountId, ticket.Text); return(RedirectToAction("Details", new { id = ticket.TicketNumber })); } return(View()); }
public ActionResult Create(Ticket ticket) { // TODO: Add insert logic here if (ModelState.IsValid) { mgr.AddTicket(ticket.AccountId, ticket.Text); return(RedirectToAction("Details", new { id = ticket.TicketNumber })); } return(View()); }
/* public ActionResult Create(Ticket ticket) * { * if (ModelState.IsValid) * { * ticket = mgr.AddTicket(ticket.AccountId, ticket.Text); * * return RedirectToAction("Details", new { id = ticket.TicketNumber }); * } * * return View(); * } */ // ADHV view-model 'CreateTicketVM' public ActionResult Create(CreateTicketVM newTicket) { if (ModelState.IsValid) { Ticket ticket = mgr.AddTicket(newTicket.AccId, newTicket.Problem); return(RedirectToAction("Details", new { id = ticket.TicketNumber })); } return(View("Create")); }
public IHttpActionResult Post([FromBody] Ticket ticket) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Ticket returnTicket = mgr.AddTicket(ticket.AccountId, ticket.Text); return(CreatedAtRoute("DefaultApi", new { controller = "Ticket", TicketNumber = ticket.TicketNumber }, returnTicket)); }
public void AddTicketWithAccountIdAndQuestionReturnsNewTicket(string question, int accountId) { _repository = Substitute.For <ITicketRepository>(); _repository.CreateTicket(Arg.Any <Ticket>()).Returns(new Ticket { Text = question, AccountId = accountId, TicketNumber = 1 }); _mgr = new TicketManager(_repository); Ticket t = _mgr.AddTicket(accountId, question); Assert.Equal(question, t.Text); Assert.Equal(accountId, t.AccountId); }
public IActionResult Create(CreateTicketVM vm) { Ticket newTicket = mgr.AddTicket(vm.AccId, vm.Problem); return(RedirectToAction("Details", "Ticket", new { id = newTicket.TicketNumber })); }
public TicketDTO AddTicket(int accountId, string question) { return(new TicketDTO(mgr.AddTicket(accountId, question))); }