public async Task <ActionResult> Edit([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComments ticketComments) { if (ModelState.IsValid) { db.Entry(ticketComments).State = EntityState.Modified; db.SaveChanges(); //Send Email var svc = new EmailService(); var msg = new IdentityMessage(); msg.Subject = "Comment Edited"; msg.Body = "\r\n Your ticket titled," + ticketComments.Ticket.Title + "has a new edit a on comment." + "\r\n"; msg.Destination = ticketComments.Ticket.AssignedTo.Email; await svc.SendAsync(msg); return(RedirectToAction("details", "Tickets", new { id = ticketComments.TicketId })); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComments.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", ticketComments.UserId); return(View(ticketComments)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComments ticketComments /*int id*/) { if (ModelState.IsValid) { var user = db.Users.Find(User.Identity.GetUserId()); var T = db.Tickets.Find(ticketComments.TicketId); ticketComments.UserId = User.Identity.GetUserId(); ticketComments.Created = DateTime.UtcNow; if (User.IsInRole("Developer")) { if (!(T.AssignedToId == user.Id)) { return(RedirectToAction("Login", "Account")); } } if (User.IsInRole("ProjectManager")) { if (!(T.Project.PManagerID == user.Id)) { return(RedirectToAction("Login", "Account")); } } if (User.IsInRole("Submitter")) { if (!(T.OwnerUserId == user.Id)) { return(RedirectToAction("Login", "Account")); } } db.TicketComments.Add(ticketComments); db.SaveChanges(); var svc = new EmailService(); var msg = new IdentityMessage(); msg.Subject = "New Comment"; msg.Body = "\r\n You have a new Attachment on the ticket titled," + ticketComments.Ticket.Title + "with the following description:" + ticketComments.Ticket.Description + "\r\n"; msg.Destination = ticketComments.Ticket.AssignedToId; await svc.SendAsync(msg); return(RedirectToAction("Details", "Tickets", new { Id = T.Id })); //ticketComments.TicketId = id; //ticketComments.Created = DateTime.Now; //db.TicketComments.Add(ticketComments); //db.SaveChanges(); //return RedirectToAction("Details", "Tickets", new { id = id }); } //ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComments.TicketId); //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", ticketComments.UserId); return(View(ticketComments)); }
public ActionResult Create([Bind(Include = "Id,TicketId,body")] TicketComments ticketComments) { if (ModelState.IsValid) { ticketComments.UserId = User.Identity.GetUserId(); ticketComments.created = DateTimeOffset.Now; if (User.IsInRole("ProjectManager") || User.IsInRole("Submitter")) { TicketNotifications notify = new TicketNotifications(); notify.TicketId = ticketComments.TicketId; notify.UserId = (string)TempData["assignedId"]; notify.seen = false; notify.notification = (string)TempData["Title"] + " has a new comment"; db.ticketNotifications.Add(notify); } db.ticketComments.Add(ticketComments); db.SaveChanges(); return(RedirectToAction("Details", "Tickets", new { id = ticketComments.TicketId })); } ViewBag.TicketId = new SelectList(db.tickets, "Id", "title", ticketComments.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "firstName", ticketComments.UserId); return(View(ticketComments)); }
public ActionResult Create(int id) { var ticketComment = new TicketComments(); ticketComment.TicketId = id; return(View(ticketComment)); }
public ActionResult CreateComment(int id, string body) { var ticket = db.Ticket .Where(p => p.Id == id) .FirstOrDefault(); if (ticket == null) { return(HttpNotFound()); } if (string.IsNullOrWhiteSpace(body)) { ViewBag.ErrorMessage = "Must require a comment..!!"; return(View("Details", new { ticket.Id })); } var comment = new TicketComments(); comment.UserId = User.Identity.GetUserId(); comment.TicketId = ticket.Id; comment.Created = DateTime.Now; comment.Comment = body; db.TicketComments.Add(comment); var user = db.Users.FirstOrDefault(p => p.Id == comment.UserId); var personalEmailService = new PersonalEmailService(); var mailMessage = new MailMessage( WebConfigurationManager.AppSettings["emailto"], user.Email ); mailMessage.Body = "New comment added"; mailMessage.Subject = "New Comment"; mailMessage.IsBodyHtml = true; personalEmailService.Send(mailMessage); db.SaveChanges(); return(RedirectToAction("Details", new { id })); }
// Edit Comment public ActionResult EditComment(TicketComments tc) { if (ModelState.IsValid) { TicketComments Comment = db.TicketComments.Find(tc.Id); Comment.UpdatedBy = User.Identity.GetUserName(); Comment.UpdateDate = System.DateTimeOffset.Now; Comment.Comments = tc.Comments; Comment.FileDesc = tc.FileDesc; db.TicketComments.Attach(Comment); db.Entry(Comment).Property("UpdateDate").IsModified = true; db.Entry(Comment).Property("Comments").IsModified = true; db.Entry(Comment).Property("UpdatedBy").IsModified = true; db.Entry(Comment).Property("FileDesc").IsModified = true; db.SaveChanges(); // Notification var ticket = db.Tickets.Find(tc.TicketId); if (ticket.TicketStatus.StatusName != "Unassigned") { var userId = User.Identity.GetUserId(); string notiReci = histHelper.getAssignedUserEmail(ticket.AssignedToUserId); string notiMessage = "Hello " + notiReci + ". A comment has been changed for the following ticket <U>" + ticket.Id + "</U>"; histHelper.InitializeNoti(ticket.Id, userId, notiReci, notiMessage); } } return(RedirectToAction("Details", "Tickets", new { id = tc.TicketId })); }
public ActionResult AddCommentsConfirm(int?id, [Bind(Include = "Id,Comment")] TicketComments ticketComment) { if (id == null) { return(RedirectToAction("Index")); } Ticket t = db.Tickets.Find(id); ticketComment.TicketId = t.Id; ticketComment.UserId = User.Identity.GetUserId(); string userId = User.Identity.GetUserId(); ticketComment.Created = DateTime.Now; if (User.IsInRole("Admin")) { TicketHandler.AddCommentToTicketForAdmin(ticketComment); } else if (User.IsInRole("ProjectManager")) { TicketHandler.AddCommentToTicketForProjectManager(ticketComment, userId); } else if (User.IsInRole("Developer")) { TicketHandler.AddCommentToTicketForDeveloper(ticketComment, userId); } else if (User.IsInRole("Submitter")) { TicketHandler.AddCommentToTicketForSubmitter(ticketComment, userId); } return(RedirectToAction("MyTickets")); }
// GET: TicketComments/Create public ActionResult Create(int TicketId) { TicketComments comment = new TicketComments(); comment.TicketId = TicketId; comment.created = DateTimeOffset.UtcNow; return(View(comment)); }
public ActionResult DeleteConfirmed(int id) { TicketComments ticketComments = db.TicketComments.Find(id); db.TicketComments.Remove(ticketComments); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { TicketComments commentInDb = db.TicketComments.Find(id); db.TicketComments.Remove(commentInDb); db.SaveChanges(); return(RedirectToAction("List", new { id = commentInDb.TicketId })); }
public ActionResult Create(int id) { ViewBag.TicketId = id; TicketComments ticketComments = new TicketComments() { UserId = User.Identity.GetUserId(), TicketId = id, }; return(View(ticketComments)); }
public ActionResult CreateComments(TicketComments tc, HttpPostedFileBase image, string backUrl) { // uploading image if (image != null && image.ContentLength > 0) { // Check the file name for allowed file types var ext = Path.GetExtension(image.FileName).ToLower(); if (ext != ".png" && ext != ".jpg" && ext != ".jpeg" && ext != ".gif" && ext != ".bmp" && ext != ".doc" && ext != ".pdf") { ModelState.AddModelError("image", "Invalid Format"); } } if (ModelState.IsValid) { // Saving Image if (image != null) { // relative server path var filePath = "/Uploads/"; // path on physical drive on server var absPath = Server.MapPath("~" + filePath); // media URL for relative path tc.FileUrl = filePath + "/" + image.FileName; // save image Directory.CreateDirectory(absPath); image.SaveAs(Path.Combine(absPath, image.FileName)); } tc.CommentsCreated = System.DateTimeOffset.Now; tc.FilePath = null; db.TicketComments.Add(tc); db.SaveChanges(); // Notification var ticket = db.Tickets.Find(tc.TicketId); if (ticket.TicketStatus.StatusName != "Unassigned") { var userId = User.Identity.GetUserId(); string notiReci = histHelper.getAssignedUserEmail(ticket.AssignedToUserId); string notiMessage = "Hello " + notiReci + ". A new comment has been created for the following ticket <U>" + ticket.Id + "</U>"; histHelper.InitializeNoti(ticket.Id, userId, notiReci, notiMessage); } } if (backUrl.Equals("Edit")) { return(RedirectToAction("Edit", "Tickets", new { id = tc.TicketId })); } return(RedirectToAction("Details", "Tickets", new { id = tc.TicketId })); }
public ActionResult Edit([Bind(Include = "Id,TicketId,Body,OwnerId,CreatedDate")] TicketComments ticketComments) { if (ModelState.IsValid) { db.Entry(ticketComments).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OwnerId = new SelectList(db.Users, "Id", "FirstName", ticketComments.OwnerId); ViewBag.TicketId = new SelectList(db.Tickets, "Id", "OwnerUserId", ticketComments.TicketId); return(View(ticketComments)); }
public ActionResult Edit([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComments ticketComments) { if (ModelState.IsValid) { db.Entry(ticketComments).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("details", "Tickets", new { id = ticketComments.TicketId })); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComments.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", ticketComments.UserId); return(View(ticketComments)); }
public ActionResult Edit([Bind(Include = "Id,comment,created,TicketId,UserId")] TicketComments ticketComments) { if (ModelState.IsValid) { db.Entry(ticketComments).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TicketId = new SelectList(db.Tickets, "id", "Title", ticketComments.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "DisplayName", ticketComments.UserId); return(View(ticketComments)); }
public long CreateOrUpdateTicketComments(TicketComments TicketComments) { try { TicketSystemBC TicketSystemBC = new TicketSystemBC(); return(TicketSystemBC.CreateOrUpdateTicketComments(TicketComments)); } catch (Exception) { throw; } finally { } }
public ActionResult Edit([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComments ticketComments) { if (ModelState.IsValid) { ticketComments.Updated = DateTimeOffset.Now; ticketComments.UserId = User.Identity.GetUserId(); db.Entry(ticketComments).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TicketId = new SelectList(db.Ticket, "Id", "Title", ticketComments.TicketId); return(View(ticketComments)); }
public ActionResult Create([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComments ticketComments) { if (ModelState.IsValid) { db.TicketComments.Add(ticketComments); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComments.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", ticketComments.UserId); return(View(ticketComments)); }
public ActionResult Create([Bind(Include = "TicketId, Comment")] TicketComments ticketComments) { if (ModelState.IsValid) { ticketComments.Created = DateTimeOffset.Now; ticketComments.UserId = User.Identity.GetUserId(); db.TicketComment.Add(ticketComments); db.SaveChanges(); return(RedirectToAction("Details", "Tickets", new { id = ticketComments.TicketId })); } ViewBag.TicketId = new SelectList(db.Ticket, "Id", "Title", ticketComments.TicketId); return(View(ticketComments)); }
public ActionResult Details(int?id) { if (id == null) { return(View("404", "Account")); } TicketComments ticketComments = db.TicketComment.Find(id); if (ticketComments == null) { return(View("404", "Account")); } return(View(ticketComments)); }
public ActionResult Create([Bind(Include = "Id,TicketId,Body,OwnerId,CreatedDate")] TicketComments ticketComments) { if (ModelState.IsValid) { ticketComments.CreatedDate = DateTime.Now; db.TicketComments.Add(ticketComments); db.SaveChanges(); return(RedirectToAction("Details", "Tickets", new { id = ticketComments.Id })); } ViewBag.OwnerId = new SelectList(db.Users, "Id", "FirstName", ticketComments.OwnerId); ViewBag.TicketId = new SelectList(db.Tickets, "Id", "OwnerUserId", ticketComments.TicketId); return(View(ticketComments)); }
public ActionResult Edit(TicketComments ticketComments) { if (ModelState.IsValid) { User loggedInUser = userHelper.GetUserFromId(User.Identity.GetUserId()); if (ticketHelper.isUserExistInTicket(loggedInUser.Id, ticketComments.TicketId)) { TicketComments commentInDb = db.TicketComments.Find(ticketComments.Id); commentInDb.Comment = ticketComments.Comment; db.SaveChanges(); } } return(RedirectToAction("List", new { id = ticketComments.TicketId })); }
public ActionResult Create(TicketComments ticketComments) { if (ModelState.IsValid) { User loggedInUser = userHelper.GetUserFromId(User.Identity.GetUserId()); if (ticketHelper.isUserExistInTicket(loggedInUser.Id, ticketComments.TicketId)) { ticketComments.Created = DateTime.Now; db.TicketComments.Add(ticketComments); db.SaveChanges(); } } return(RedirectToAction("List", new { id = ticketComments.TicketId })); }
public ActionResult Create([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComments ticketComments /*int id*/) { if (ModelState.IsValid) { var user = db.Users.Find(User.Identity.GetUserId()); var T = db.Tickets.Find(ticketComments.TicketId); ticketComments.UserId = User.Identity.GetUserId(); ticketComments.Created = DateTime.UtcNow; if (User.IsInRole("Developer")) { if (!(T.AssignedToId == user.Id)) { return(RedirectToAction("Login", "Account")); } } if (User.IsInRole("ProjectManager")) { if (!(T.Project.PManagerID == user.Id)) { return(RedirectToAction("Login", "Account")); } } if (User.IsInRole("Submitter")) { if (!(T.OwnerUserId == user.Id)) { return(RedirectToAction("Login", "Account")); } } db.TicketComments.Add(ticketComments); db.SaveChanges(); return(RedirectToAction("Details", "Tickets", new { Id = T.Id })); //ticketComments.TicketId = id; //ticketComments.Created = DateTime.Now; //db.TicketComments.Add(ticketComments); //db.SaveChanges(); //return RedirectToAction("Details", "Tickets", new { id = id }); } //ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComments.TicketId); //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", ticketComments.UserId); return(View(ticketComments)); }
public ActionResult Edit(int id) { ViewBag.TicketId = id; TicketComments comment = db.TicketComments.Find(id); TicketComments ticketComments = new TicketComments() { UserId = comment.UserId, Comment = comment.Comment, TicketId = comment.TicketId, Created = comment.Created, }; return(View(ticketComments)); }
// GET: TicketComments/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TicketComments ticketComments = db.TicketComments.Find(id); if (ticketComments == null) { return(HttpNotFound()); } return(View(ticketComments)); }
public ActionResult Create([Bind(Include = "Id,CommentBody,Created,UserId,TicketId")] TicketComments ticketComments) { if (ModelState.IsValid) { ticketComments.Created = DateTime.Now; ticketComments.UserId = User.Identity.GetUserId(); db.TicketComments.Add(ticketComments); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "OwnerUserId", ticketComments.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", ticketComments.UserId); return(View(ticketComments)); }
public ActionResult CommentDetails(int?id) { if (id == null || !User.Identity.IsAuthenticated) { return(RedirectToAction("Index")); } if (!TicketHandler.TicketCommentConfirmation(User.Identity.GetUserId(), Convert.ToInt32(id))) { return(RedirectToAction("Index")); } TicketComments ticketComments = db.TicketComments.Find(id); ticketComments.UserId = db.Users.Find(ticketComments.UserId).Email; return(View(ticketComments)); }
public ActionResult Edit(int?id) { if (id == null) { return(View("404", "Account")); } TicketComments ticketComments = db.TicketComment.Find(id); if (ticketComments == null) { return(View("404", "Account")); } ViewBag.TicketId = new SelectList(db.Ticket, "Id", "Title", ticketComments.TicketId); return(View(ticketComments)); }
// GET: TicketComments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TicketComments ticketComments = db.TicketComments.Find(id); if (ticketComments == null) { return(HttpNotFound()); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComments.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", ticketComments.UserId); return(View(ticketComments)); }