public async Task <IActionResult> Edit([FromForm] Ticket ticketUpdate) { var ticket = await _context.Tickets.FindAsync(ticketUpdate.Id); ticket.Title = ticketUpdate.Title; ticket.Description = ticketUpdate.Description; ticket.Complexity = ticketUpdate.Complexity; ticket.Notes = ticketUpdate.Notes; ticket.Open = ticketUpdate.Open; // Ticket is closing if (!ticket.Open && ticket.DateClosed == DateTime.MinValue) { ticket.DateClosed = DateTime.Now; } // Ticket is re-opening if (ticket.Open && ticket.DateClosed != DateTime.MinValue) { ticket.DateClosed = DateTime.MinValue; } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Open), new { id = ticket.Id })); }
public async Task <IActionResult> Add([FromForm] Client client) { client.DateAdded = DateTime.Now; _context.Clients.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Open), new { id = client.Id })); }