public ActionResult DeleteConfirmed(int id)
        {
            TicketComment ticketComment = db.TicketComments.Find(id);

            ticketComment.Closed = true;

            db.Entry(ticketComment).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Create([Bind(Include = "Id,Comment,TicketId")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.TicketComments.Add(ticketComment);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ticketComment));
 }
Пример #3
0
        /// <summary>
        /// Save new ticket comment to redis cache.
        /// </summary>
        /// <param name="data">The ticket information.</param>
        private void SaveRedisCacheTicketComments(TicketComment data)
        {
            var ticketList = RedisCacheHandler.GetValue(ConstantValue.TicketCommentKey + data.TicketId.Value.ToString(), () =>
            {
                return(this.FuncGetValue(data.TicketId.Value).ToList());
            });

            ticketList.Add(this.InitialTicketCommentViewModel(data));
            RedisCacheHandler.SetValue(ConstantValue.TicketCommentKey + data.TicketId.Value.ToString(), ticketList);
        }
 public ActionResult Edit([Bind(Include = "Id,TicketId,Body,CreatedDate,UpdatedDate,AuthorId")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Tickets", new { id = ticketComment.TicketId }));
     }
     return(View(ticketComment));
 }
        public ActionResult DeleteComment(int id)
        {
            TicketComment ticketcomment = db.TicketComments.Find(id);


            db.TicketComments.Remove(ticketcomment);
            db.SaveChanges();
            //return RedirectToAction("Index");
            return(RedirectToAction("Details", "Tickets", new { id = ticketcomment.TicketId }));
        }
Пример #6
0
 public ActionResult Edit([Bind(Include = "Id,TicketId,Comment,UserName,Created")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ticketComment));
 }
Пример #7
0
 public ActionResult CreateComment([Bind(Include = "TicketId, UserId, Comment")] TicketComment tcomm)
 {
     if (ModelState.IsValid)
     {
         tcomm.Created = DateTimeOffset.Now;
         db.TicketComments.Add(tcomm);
         db.SaveChanges();
     }
     return(RedirectToAction("Details", new { id = tcomm.TicketId }));
 }
        // GET: TicketComments/Create
        public ActionResult Create(int id)
        {
            TicketComment ticketcomment = new TicketComment();

            ticketcomment.TicketId = id;
            ticketcomment.UserId   = User.Identity.GetUserId();
            //ViewBag.ticketId = id;
            //ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title");
            //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName");
            return(View(ticketcomment));
        }
Пример #9
0
        public static void ManageCommentNotifications(TicketComment ticketComment, string assignedToUserId)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            var newNotification     = new TicketNotification();
            var theTicket           = db.Tickets.Where(t => t.Id == ticketComment.TicketId).FirstOrDefault();

            newNotification.TicketId    = ticketComment.TicketId;
            newNotification.RecipientId = assignedToUserId;
            newNotification.Message     = $"There is a new comment for {theTicket.Title} TicketId{newNotification.TicketId}";
            GenerateNotification(newNotification);
        }
Пример #10
0
        public static void Edit(int id, string comment)
        {
            ApplicationDbContext db            = new ApplicationDbContext();
            TicketComment        ticketComment = db.TicketComments.Find(id);

            ticketComment.Comment         = comment;
            ticketComment.Created         = DateTime.Now;
            db.Entry(ticketComment).State = EntityState.Modified;
            db.SaveChanges();
            db.Dispose();
        }
 public ActionResult Edit([Bind(Include = "Id,TicketId,Body,Abstract,AuthorID,Created,Updated")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComment.TicketId);
     return(View(ticketComment));
 }
Пример #12
0
 public ActionResult Edit([Bind(Include = "ID,Comment,UserID,Created,TicketID")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TicketID = new SelectList(db.Tickets, "ID", "UserID", ticketComment.TicketID);
     return(View(ticketComment));
 }
Пример #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            TicketComment ticketComment = db.TicketComments.Find(id);

            db.TicketComments.Remove(ticketComment);
            if (!roleHelper.IsUserDemo())
            {
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComment ticketComment)
        {
            if (ModelState.IsValid)
            {
                TicketCommentHelper.Create(ticketComment.Comment, ticketComment.TicketId, User.Identity.GetUserId());
                return(RedirectToAction("Index", "Tickets", new { userId = User.Identity.GetUserId() }));
            }

            ViewBag.TicketId = new SelectList(TicketHelper.GetTickets(), "Id", "Title", ticketComment.TicketId);
            return(View(ticketComment));
        }
 public ActionResult Edit([Bind(Include = "Id,UserId,TicketId,CommentBody,Created,AuthorId")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", ticketComment.AuthorId);
     return(View(ticketComment));
 }
Пример #16
0
        // GET: TicketComments/Create
        public IActionResult Create(int?id)
        {
            TicketComment model = new TicketComment {
                TicketId = ( int )id
            };

            this.ViewData["TicketId"] = new SelectList(this.context.Tickets, "Id", "Description");
            this.ViewData["UserId"]   = new SelectList(this.context.Users, "Id", "Id");

            return(this.View(model));
        }
Пример #17
0
 public ActionResult Edit([Bind(Include = "Id,Body,DateCreated,DateUpdated,TicketId,AuthorUserId")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Tickets", new { id = ticketComment.TicketId }));
     }
     ViewBag.AuthorUserId = new SelectList(db.Users, "Id", "FirstName", ticketComment.AuthorUserId);
     return(View(ticketComment));
 }
Пример #18
0
 public ActionResult Edit([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComment ticketComments)
 {
     if (ModelState.IsValid)
     {
         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 Edit([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComment ticketComment)
        {
            if (ModelState.IsValid)
            {
                TicketCommentHelper.Edit(ticketComment.Id, ticketComment.Comment);
                db.SaveChanges();
                return(RedirectToAction("Index", new { ticketId = ticketComment.TicketId }));
            }

            return(View(ticketComment));
        }
Пример #20
0
 public ActionResult AddCommentToTicket(int id, TicketComment comment)
 {
     if (ModelState.IsValid)
     {
         comment.TicketId = id;
         comment.Date     = DateTime.Now;
         comment.UserId   = User.Identity.GetUserId();
         TicketHelper.AddCommentToTicket(db, comment);
         return(RedirectToAction("Detail", new { id }));
     }
     return(View(comment));
 }
        public ActionResult DeleteConfirmed(int id, bool flag)
        {
            TicketComment ticketComment = db.TicketComments.Find(id);

            db.TicketComments.Remove(ticketComment);
            db.SaveChanges();
            if (flag)
            {
                return(RedirectToAction("UserIndex", "Tickets"));
            }
            return(RedirectToAction("Index", "Tickets"));
        }
Пример #22
0
        public ActionResult Create([Bind(Include = "Id,Body,DateCreated,DateUpdated,TicketId,AuthorUserId")] TicketComment ticketComment)
        {
            if (ModelState.IsValid)
            {
                db.TicketComments.Add(ticketComment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AuthorUserId = new SelectList(db.Users, "Id", "FirstName", ticketComment.AuthorUserId);
            return(View(ticketComment));
        }
Пример #23
0
 // GET: TicketComments/Create
 public ActionResult Create(int id)
 {
     TicketComment model = new TicketComment();
     model.Created = new DateTimeOffset(DateTime.Now);
     model.User = db.Users.Single(u => u.UserName == User.Identity.Name);
     model.UserId = model.User.Id;
     model.Ticket = db.Tickets.Find(id);
     model.TicketId = id;
     //ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title");
     //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName");
     return View(model);
 }
Пример #24
0
        public ActionResult CreateComment(int id, string body, IdentityMessage message)
        {
            var ticketcomment = db.TicketModels.Where(p => p.Id == id).FirstOrDefault();

            if (ticketcomment == null)
            {
                return(HttpNotFound());
            }

            if (string.IsNullOrWhiteSpace(body))
            {
                TempData["ErrorMessage"] = "Comment is required";
                return(RedirectToAction("Details", new { id = id }));
            }

            var comment = new TicketComment();

            comment.UserId   = User.Identity.GetUserId();
            comment.TicketId = ticketcomment.Id;
            comment.Created  = DateTime.Now;
            comment.Comment  = body;
            db.TicketComments.Add(comment);

            //Step 1: Find if there is a developer assigned to the ticket

            //Step 2: If yes, send him an e-email



            var attachmentFind = db.Users.Where(t => t.Id == comment.UserId).FirstOrDefault();

            var email = WebConfigurationManager.AppSettings["emailto"];



            var personalEmailService = new PersonalEmailService();
            var mailMessage          = new MailMessage(
                WebConfigurationManager.AppSettings["emailto"],
                attachmentFind.Email
                );



            mailMessage.Body       = "fake";
            mailMessage.Subject    = "comments";
            mailMessage.IsBodyHtml = true;
            personalEmailService.Send(mailMessage);


            db.SaveChanges();

            return(RedirectToAction("Details", new { id = id }));
        }
 public ActionResult Edit([Bind(Include = "Id,Comment,Created,TicketId,UserId")] TicketComment ticketComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Tickets", new { id = ticketComment.TicketId }));
     }
     ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComment.TicketId);
     ViewBag.UserId   = new SelectList(db.Users, "Id", "DisplayName", ticketComment.UserId);
     return(View(ticketComment));
 }
Пример #26
0
        public static TicketComment GetTicketComment(int?Id)
        {
            ApplicationDbContext db            = new ApplicationDbContext();
            TicketComment        ticketComment = db.TicketComments.Find(Id);

            if (ticketComment == null)
            {
                return(null);
            }

            return(ticketComment);
        }
        // GET: TicketComments/Create
        public ActionResult Create(int ticketId)
        {
            ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title");
            ViewBag.UserId   = new SelectList(db.Users, "Id", "FirstName");
            var newTicket = new TicketComment();

            if (ticketId != 0)
            {
                newTicket.TicketId = (int)ticketId;
            }
            return(View(newTicket));
        }
Пример #28
0
        public ActionResult Create([Bind(Include = "Id,TicketId,AuthorId,CommentBody,Created")] TicketComment ticketComment)
        {
            if (ModelState.IsValid)
            {
                db.TicketComments.Add(ticketComment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TicketId = new SelectList(db.Tickets, "Id", "OwnerUserId", ticketComment.TicketId);
            return(View(ticketComment));
        }
        /// <summary>
        /// Adds the ticket event notifications for the supplied comment.
        /// </summary>
        /// <param name="comment">The comment for which notifications should be added.</param>
        /// <param name="isGiveUpTicket">if set to <c>true</c> is a give up ticket action.</param>
        /// <param name="subscribers">The subscribers.</param>
        public void AddTicketEventNotifications(TicketComment comment, bool isNewOrGiveUpTicket, string[] subscribers)
        {
            Dictionary <string, string> userReasons = GetNotificationUsersForComment(isNewOrGiveUpTicket, subscribers);
            var newNotes = CreateNotesForUsers(userReasons, comment);

            ScheduleNoteDeliveries(newNotes);

            foreach (var note in newNotes)
            {
                comment.TicketEventNotifications.Add(note);
            }
        }
Пример #30
0
 public TicketComment Add(TicketComment comment)
 {
     using (var context = new PunchClockDbContext())
     {
         {
             comment.CreatedDateUtc = DateTime.UtcNow;
             context.TicketComments.Add(comment);
             context.SaveChanges();
         }
         return(comment);
     }
 }