public ActionResult CreateTicket(Ticket ticket) { if (ModelState.IsValid) { ticket.Username = User.Identity.Name; Facade.GetTicketGateway().Create(ticket); return RedirectToAction("Index"); } return View(ticket); }
public ActionResult CreateTicket(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Ticket newTicket = new Ticket(); newTicket.Username = User.Identity.Name; newTicket.ProjectId = (int)id; newTicket.Project = Facade.GetProjectGateway().Read((int)id); return View(newTicket); }
public ActionResult ViewTicket(string submit, Ticket ticket, string NewComment, DateTime? larstDoDate) { if (Request.Form["NewCommentBtn"] != null) { Comment comment = new Comment() { CommentText = NewComment, Ticketid = ticket.ID, Username = User.Identity.Name, }; Facade.GetCommentGateway().Create(comment); } if (Request.Form["ChangeStatus"] != null) { Facade.GetTicketGateway().Update(ticket); Comment comment = new Comment() { CommentText = "Statusen er ændret til: " + Facade.GetStatusGateway().Read(ticket.StatusId).Name, Ticketid = ticket.ID, Username = User.Identity.Name, SystemComment = true, }; Facade.GetCommentGateway().Create(comment); } if (Request.Form["ChangeProject"] != null) { Facade.GetTicketGateway().Update(ticket); Comment comment = new Comment() { CommentText = "Projektet er ændret til: " + Facade.GetProjectGateway().Read(ticket.ProjectId).Name, Ticketid = ticket.ID, Username = User.Identity.Name, SystemComment = true, }; Facade.GetCommentGateway().Create(comment); } if (Request.Form["ChangeLarstDoDate"] != null) { DateTime date = (DateTime)larstDoDate; ticket.LastDoDate = larstDoDate; Facade.GetTicketGateway().Update(ticket); Comment comment = new Comment() { CommentText = "Sidste udførselsdate er ændret til : " + date.ToShortDateString(), Ticketid = ticket.ID, Username = User.Identity.Name, SystemComment = true, }; Facade.GetCommentGateway().Create(comment); } if (Request.Form["ChangeTechnician"] != null) { Facade.GetTicketGateway().Update(ticket); Comment comment = new Comment() { Ticketid = ticket.ID, Username = User.Identity.Name, SystemComment = true, }; if (ticket.TechnicianId != null) { comment.CommentText = "Tekniker er ændret til: " + Facade.GetTechnicianGateway().Read((int)ticket.TechnicianId).FriendlyName; } else { comment.CommentText = "Der er nu ingen teknikere tilknyttet"; } Facade.GetCommentGateway().Create(comment); } return RedirectToAction("ViewTicket", new { id = ticket.ID }); }