예제 #1
0
        public ActionResult Create()
        {
            var items = _db.TicketTicketPriorities
                        .Select(t => new SelectListItem {
                Value = t.ToString(),
                Text  = t.Priority
            });

            var model = new TicketCreationViewModel();

            model.TicketTicketPriorities = _db.TicketTicketPriorities.ToArray();

            return(View(model));
        }
예제 #2
0
        public ActionResult Create()
        {
            var id       = User.Identity.GetUserId();
            var projects = db.Projects.Where(x => x.Users.Any(z => z.Id == id)).ToList();
            var vm       = new TicketCreationViewModel()
            {
                Projects = projects
            };

            if (projects.Any())
            {
                return(View(vm));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
예제 #3
0
        public ActionResult Create(TicketCreationViewModel model, HttpPostedFileBase fileAttachment)
        {
            var ticketTitle   = model.ticketTitle;
            var ticketSummary = model.ticketSummary;
            var projectId     = model.projectId;

            if (ModelState.IsValid)
            {
                var ticket = new Ticket();
                ticket.Title       = ticketTitle;
                ticket.Summary     = ticketSummary;
                ticket.OwnerId     = User.Identity.GetUserId();
                ticket.CreatedDate = DateTime.Now;
                ticket.ProjectId   = projectId;
                ticket.StatusId    = db.Statuses.FirstOrDefault(x => x.Name == "Created").Id;
                ticket.PriorityId  = db.Priorities.FirstOrDefault(x => x.Name == "Medium").Id;
                ticket.TypeId      = db.Types.FirstOrDefault(x => x.Name == "Other").Id;
                var newticket = db.Tickets.Add(ticket);

                if (fileAttachment != null)
                {
                    var filename = DateTime.Now.Ticks + "-" + fileAttachment.FileName;
                    var path     = Path.Combine(Server.MapPath("~/Uploads/"), filename);
                    fileAttachment.SaveAs(path);
                    var attachment = db.TicketAttachments.Add(new TicketAttachment()
                    {
                        Description = "Initial File Attachment",
                        UploadDate  = DateTime.Now,
                        UserId      = User.Identity.GetUserId(),
                        TicketId    = newticket.Id,
                        FilePath    = "/Uploads/" + filename
                    });;
                    var newAttachment = db.TicketAttachments.Add(attachment);
                    newticket.TicketAttachments.Add(newAttachment);
                }
                db.SaveChanges();
                Helpers.NotificationHelpers.SendProjectNotification(projectId, "Ticket Submitted On " + db.Projects.Find(projectId).Name, "New ticket submitted by " + User.Identity.GetUserFirstName() + " " + User.Identity.GetUserLastName(), db.Users.Find(User.Identity.GetUserId()));
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
예제 #4
0
        public ActionResult Create(TicketCreationViewModel ticket)
        {
            //TicketCreationViewModel model = ticket;
            int currentUserId = int.Parse(Membership.GetUser().ProviderUserKey.GetType().ToString());

            ticket.Tickets.CreateDate = DateTime.Now;

            if (ticket.Tickets.Locked == true)
            {
                ticket.Tickets.LockedByUserId = 1;
            }

            ticket.Emails.UserId = 1;

            if (ModelState.IsValid)
            {
                _db.Add(ticket.Tickets);
                _db.Add(ticket.Emails);
                _db.SaveChanges();
                return(RedirectToAction("Index", "Ticket"));
            }
            return(View(ticket));
        }