// GET: TicketNotifications
        public ActionResult Index(TicketNotifications noty)
        {
            noty.open = true;
            var ticketNotifications = db.TicketNotifications.Include(t => t.Ticket).Include(t => t.User).Include(t => t.open);

            return(View(ticketNotifications.ToList()));
        }
Exemple #2
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Description,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToId")] Tickets model)
        {
            var           user        = db.Users.Find(User.Identity.GetUserId());
            ProjectHelper HistoryHelp = new ProjectHelper(db);

            var tickets = db.Tickets.Find(model.Id);
            var noty    = new TicketNotifications();

            noty.open = false;

            if (!(tickets.Title == model.Title) || (tickets.TicketPriorityId == model.TicketPriorityId) || (tickets.TicketStatusId == model.TicketStatusId) ||
                (tickets.AssignedToId == model.AssignedToId) || (tickets.ProjectId == model.ProjectId) || (tickets.TicketTypeId == model.TicketTypeId))
            {
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.Title, model.Title, "Title");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.TicketPriorityId.ToString(), model.TicketPriorityId.ToString(), "TicketPriority");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.TicketStatusId.ToString(), model.TicketStatusId.ToString(), "TicketStatus");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.TicketTypeId.ToString(), model.TicketTypeId.ToString(), "TicketType");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.ProjectId.ToString(), model.ProjectId.ToString(), "Project");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.Description, model.Description, "Description");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.AssignedToId, model.AssignedToId, "AssignedTo");
                HistoryHelp.AddNoty(tickets.Id, user.Id, noty.open);
            }


            tickets.TicketPriorityId = model.TicketPriorityId;
            tickets.TicketStatusId   = model.TicketStatusId;
            tickets.OwnerUserId      = user.Id;
            tickets.Created          = tickets.Created = DateTime.Now;
            db.Tickets.Add(model);
            //tickets.Id = model.Id;
            var currproject = db.Projects.Find(tickets.ProjectId);


            if (ModelState.IsValid)
            {
                db.Entry(tickets).State = EntityState.Modified;
                db.SaveChanges();

                //Send Email
                var svc = new EmailService();
                var msg = new IdentityMessage();
                msg.Subject = "Edits";
                msg.Body    = "\r\n You're ticket titled," + tickets.Title + "was edited." + "\r\n";

                msg.Destination = currproject.Users.Select(u => u.Email).ToString();

                await svc.SendAsync(msg);

                return(RedirectToAction("myIndex", "Tickets"));
            }
            //ViewBag.AssignedToId = new SelectList(db.Users, "Id", "FirstName", tickets.AssignedToId);
            //ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", tickets.OwnerUserId);
            ViewBag.ProjectId        = new SelectList(db.Projects, "Id", "Name", tickets.ProjectId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", tickets.TicketPriorityId);
            ViewBag.TicketStatusId   = new SelectList(db.TicketStatuses, "Id", "Name", tickets.TicketStatusId);
            ViewBag.TicketTypeId     = new SelectList(db.TicketTypes, "Id", "Name", tickets.TicketTypeId);


            return(View("myIndex", "Tickets"));
        }
        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 DeleteConfirmed(int id)
        {
            TicketNotifications ticketNotifications = db.TicketNotifications.Find(id);

            db.TicketNotifications.Remove(ticketNotifications);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "Id,title,description,created,updated,ProjectID,TicketTypeId,TicketStatusId,TicketPriorityId,AssignedId")] Tickets tickets)
        {
            if (ModelState.IsValid)
            {
                if (User.IsInRole("Developer"))
                {
                    tickets.title            = (string)TempData["Title"];
                    tickets.description      = (string)TempData["Description"];
                    tickets.AssignedId       = (string)TempData["AssignedId"];
                    tickets.TicketPriorityId = (int)TempData["TicketPriorityId"];
                }
                else if (User.IsInRole("Submitter"))
                {
                    tickets.TicketTypeId     = (int)TempData["TicketTypeId"];
                    tickets.TicketStatusId   = (int)TempData["TicketStatusId"];
                    tickets.AssignedId       = (string)TempData["AssignedId"];
                    tickets.TicketPriorityId = (int)TempData["TicketPriorityId"];
                }

                if (User.IsInRole("ProjectManager") || User.IsInRole("Submitter"))
                {
                    if (tickets.AssignedId != (string)TempData["AssignedId"])
                    {
                        TicketNotifications notify = new TicketNotifications();
                        notify.TicketId     = tickets.Id;
                        notify.UserId       = tickets.AssignedId;
                        notify.seen         = false;
                        notify.notification = "You have been assigned to ticket " + (string)TempData["Title"];
                        db.ticketNotifications.Add(notify);
                    }
                    else
                    {
                        TicketNotifications notify = new TicketNotifications();
                        notify.TicketId     = tickets.Id;
                        notify.UserId       = tickets.AssignedId;
                        notify.seen         = false;
                        notify.notification = (string)TempData["Title"] + " has been modified";
                        db.ticketNotifications.Add(notify);
                    }
                }

                tickets.ModifierId      = User.Identity.GetUserId();
                tickets.updated         = DateTimeOffset.Now;
                tickets.created         = (DateTimeOffset)TempData["CreatedDate"];
                tickets.ProjectID       = (int)TempData["ProjectId"];
                tickets.OwnerId         = (string)TempData["OwnerId"];
                db.Entry(tickets).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Personal"));
            }
            ViewBag.AssignedId       = new SelectList(db.Users, "Id", "firstName", tickets.AssignedId);
            ViewBag.OwnerId          = new SelectList(db.Users, "Id", "firstName", tickets.OwnerId);
            ViewBag.ProjectID        = new SelectList(db.projects, "Id", "name", tickets.ProjectID);
            ViewBag.TicketPriorityId = new SelectList(db.ticketPriorities, "Id", "name", tickets.TicketPriorityId);
            ViewBag.TicketStatusId   = new SelectList(db.ticketStatuses, "Id", "name", tickets.TicketStatusId);
            ViewBag.TicketTypeId     = new SelectList(db.ticketTypes, "Id", "name", tickets.TicketTypeId);
            return(View(tickets));
        }
Exemple #6
0
        public void AddNoty(int tId, string userID, bool open)
        {
            TicketNotifications noty = new TicketNotifications();

            noty.TicketId = tId;
            noty.UserId   = userID;
            noty.open     = open;

            db.TicketNotifications.Add(noty);
            db.SaveChanges();
        }
 public ActionResult Edit([Bind(Include = "Id,TicketId,UserId")] TicketNotifications ticketNotifications)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketNotifications).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TicketId = new SelectList(db.Ticket, "Id", "Title", ticketNotifications.TicketId);
     //ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "FirstName", ticketNotifications.UserId);
     return(View(ticketNotifications));
 }
Exemple #8
0
 public ActionResult Edit([Bind(Include = "Id,TIcketId,NotificationBody,CreatedDate,RecipientID,IsRead")] TicketNotifications ticketNotifications)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketNotifications).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RecipientID = new SelectList(db.Users, "Id", "FirstName", ticketNotifications.RecipientID);
     ViewBag.TIcketId    = new SelectList(db.Tickets, "Id", "Title", ticketNotifications.TIcketId);
     return(View(ticketNotifications));
 }
Exemple #9
0
        public ActionResult Create([Bind(Include = "Id,TicketId,NotificationBody,CreatedDate,RecipientId,IsRead")] TicketNotifications ticketNotifications)
        {
            if (ModelState.IsValid)
            {
                db.TicketNotifications.Add(ticketNotifications);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RecipientId = new SelectList(db.Users, "Id", "FirstName", ticketNotifications.RecipientId);
            ViewBag.TicketId    = new SelectList(db.Tickets, "Id", "OwnerUserId", ticketNotifications.TicketId);
            return(View(ticketNotifications));
        }
        public ActionResult Create([Bind(Include = "Id,TicketId,UserId,seen")] TicketNotifications ticketNotifications)
        {
            if (ModelState.IsValid)
            {
                db.ticketNotifications.Add(ticketNotifications);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TicketId = new SelectList(db.tickets, "Id", "title", ticketNotifications.TicketId);
            ViewBag.UserId   = new SelectList(db.Users, "Id", "firstName", ticketNotifications.UserId);
            return(View(ticketNotifications));
        }
        // GET: TicketNotifications/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TicketNotifications ticketNotifications = db.TicketNotifications.Find(id);

            if (ticketNotifications == null)
            {
                return(HttpNotFound());
            }
            return(View(ticketNotifications));
        }
Exemple #12
0
        public ActionResult Create([Bind(Include = "Id,TIcketId,NotificationBody,Title,CreatedDate,SenderId,RecipientID,IsRead")] TicketNotifications ticketNotifications)
        {
            if (ModelState.IsValid)
            {
                ticketNotifications.SenderId    = User.Identity.GetUserId();
                ticketNotifications.CreatedDate = DateTime.Now;
                db.TicketNotifications.Add(ticketNotifications);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RecipientID = new SelectList(db.Users, "Id", "FirstName", ticketNotifications.RecipientID);
            ViewBag.TIcketId    = new SelectList(db.Tickets, "Id", "Title", ticketNotifications.TIcketId);
            return(View(ticketNotifications));
        }
Exemple #13
0
        private void AddAssignmentNotification(Tickets oldTicket, Tickets newTicket)
        {
            var notification = new TicketNotifications
            {
                TicketId         = newTicket.Id,
                IsRead           = false,
                SenderId         = HttpContext.Current.User.Identity.GetUserId(),
                RecipientId      = newTicket.AssignedToUserId,
                CreatedDate      = DateTime.Now,
                NotificationBody = $"You have been assigned to a ticket Id {newTicket.Id} on project {newTicket.Project.Name}. The ticket title is {newTicket.Title}"
            };

            db.TicketNotifications.Add(notification);
            db.SaveChanges();
        }
 public ActionResult Edit([Bind(Include = "Id,TicketId,UserId")] TicketNotifications model)
 {
     if (ModelState.IsValid)
     {
         if (model.open == true)
         {
             db.Entry(model).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", model.TicketId);
     ViewBag.UserId   = new SelectList(db.Users, "Id", "FirstName", model.UserId);
     return(View(model));
 }
        public ActionResult Edit([Bind(Include = "Id,Title,Description,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToId")] Tickets model)
        {
            var           user        = db.Users.Find(User.Identity.GetUserId());
            ProjectHelper HistoryHelp = new ProjectHelper(db);

            var tickets = db.Tickets.Find(model.Id);
            var noty    = new TicketNotifications();

            noty.open = false;

            if (!(tickets.Title == model.Title) || (tickets.TicketPriorityId == model.TicketPriorityId) || (tickets.TicketStatusId == model.TicketStatusId) ||
                (tickets.AssignedToId == model.AssignedToId) || (tickets.ProjectId == model.ProjectId) || (tickets.TicketTypeId == model.TicketTypeId))
            {
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.Title, model.Title, "Title");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.TicketPriorityId.ToString(), model.TicketPriorityId.ToString(), "TicketPriority");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.TicketStatusId.ToString(), model.TicketStatusId.ToString(), "TicketStatus");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.TicketTypeId.ToString(), model.TicketTypeId.ToString(), "TicketType");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.ProjectId.ToString(), model.ProjectId.ToString(), "Project");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.Description, model.Description, "Description");
                HistoryHelp.AddHistory(tickets.Id, user.Id, tickets.AssignedToId, model.AssignedToId, "AssignedTo");
                HistoryHelp.AddNoty(tickets.Id, user.Id, noty.open);
            }


            tickets.TicketPriorityId = model.TicketPriorityId;
            tickets.TicketStatusId   = model.TicketStatusId;
            tickets.OwnerUserId      = user.Id;
            tickets.Created          = tickets.Created = DateTime.Now;
            db.Tickets.Add(model);
            //tickets.Id = model.Id;

            if (ModelState.IsValid)
            {
                db.Entry(tickets).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("myIndex", "Tickets"));
            }
            //ViewBag.AssignedToId = new SelectList(db.Users, "Id", "FirstName", tickets.AssignedToId);
            //ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", tickets.OwnerUserId);
            ViewBag.ProjectId        = new SelectList(db.Projects, "Id", "Name", tickets.ProjectId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", tickets.TicketPriorityId);
            ViewBag.TicketStatusId   = new SelectList(db.TicketStatuses, "Id", "Name", tickets.TicketStatusId);
            ViewBag.TicketTypeId     = new SelectList(db.TicketTypes, "Id", "Name", tickets.TicketTypeId);


            return(View("myIndex", "Tickets"));
        }
        // GET: TicketNotifications/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TicketNotifications ticketNotifications = db.TicketNotifications.Find(id);

            if (ticketNotifications == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketNotifications.TicketId);
            ViewBag.UserId   = new SelectList(db.Users, "Id", "FirstName", ticketNotifications.UserId);
            return(View(ticketNotifications));
        }
Exemple #17
0
        public void InsertNotificationTable(Tickets ticket)
        {
            var tn = new TicketNotifications();

            tn.TicketId      = ticket.Id;
            tn.Detail        = ComposeEmailBody(ticket);
            tn.UserId        = ticket.AssignedToUser.Id;
            tn.GeneratedDate = DateTime.Now;
            db.TicketNotification.Add(tn);
            try
            {
                db.SaveChanges();
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #18
0
        public async Task <bool> Noto(Tickets tickets)
        {
            //ApplicationUser assignee = db.Users.FirstOrDefault(u => u.Id.Equals(tickets.AssignedToUserId));

            TicketNotifications tn5 = new TicketNotifications
            {
                TicketId = tickets.Id,
                UserId   = tickets.AssignedToUserId
            };

            db.TicketNotifications.Add(tn5);

            db.SaveChanges();

            var assignee = db.Users.Find(tickets.AssignedToUserId);
            var es       = new EmailService();
            var im       = new IdentityMessage();

            im.Destination = assignee.Email;
            im.Body        = "Notification of changes";
            await es.SendAsync(im);

            return(true);
        }
Exemple #19
0
        public ActionResult Create([Bind(Include = "Id,TicketId,description")] TicketAttachments ticketAttachments, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                FileUploadValidator helper = new FileUploadValidator();

                if (helper.IsWebpageFrendlyFile(file))
                {
                    var extention = Path.GetExtension(file.FileName);
                    var fileName  = Path.GetFileName(file.FileName);
                    file.SaveAs(Path.Combine(Server.MapPath("~/UploadedFiles/"), fileName));
                    ticketAttachments.fileURL  = "/UploadedFiles/" + fileName;
                    ticketAttachments.filePath = Path.GetFileNameWithoutExtension(file.FileName);

                    if (extention == ".doc" || extention == ".docx")
                    {
                        ticketAttachments.icon = "/Attachments/word.png";
                    }
                    else if (extention == ".xls" || extention == ".xlsx")
                    {
                        ticketAttachments.icon = "/Attachments/excel.png";
                    }
                    else if (extention == ".pdf")
                    {
                        ticketAttachments.icon = "/Attachments/pdf.png";
                    }
                    else if (extention == ".png" || extention == ".jpg" || extention == ".jpeg")
                    {
                        ticketAttachments.icon = "/Attachments/image.png";
                    }
                    else
                    {
                        ticketAttachments.icon = "/Attachments/default.png";
                    }
                }
                else
                {
                    TempData["attachCheck"] = "Failure";
                    return(RedirectToAction("Details", "Tickets", new { id = ticketAttachments.TicketId }));
                }

                if (User.IsInRole("ProjectManager") || User.IsInRole("Submitter"))
                {
                    TicketNotifications notify = new TicketNotifications();
                    notify.TicketId     = ticketAttachments.TicketId;
                    notify.UserId       = (string)TempData["assignedId"];
                    notify.seen         = false;
                    notify.notification = (string)TempData["Title"] + " has a new attachment";
                    db.ticketNotifications.Add(notify);
                }

                ticketAttachments.UserId  = User.Identity.GetUserId();
                ticketAttachments.created = DateTimeOffset.Now;
                db.ticketAttachments.Add(ticketAttachments);
                db.SaveChanges();
                TempData["attachCheck"] = "Success";
                return(RedirectToAction("Details", "Tickets", new { id = ticketAttachments.TicketId }));
            }

            TempData["attachCheck"] = "Failure";
            ViewBag.TicketId        = new SelectList(db.tickets, "Id", "title", ticketAttachments.TicketId);
            ViewBag.UserId          = new SelectList(db.Users, "Id", "firstName", ticketAttachments.UserId);
            return(View(ticketAttachments));
        }