public void Remove(TicketBase ticket)
 {
     if (Tickets.Contains(ticket))
     {
         Tickets.Remove(ticket);
     }
 }
Exemple #2
0
        public PartialViewResult Edit(TicketBase tick, string Id)
        {
            ObjectId tickId;
            var      isValid = ObjectId.TryParse(Id, out tickId);

            if (isValid)
            {
                var _tickets = mongoDatabase.GetCollection <TicketBase>("TicketBase");
                var getQuery = Query <TicketBase> .EQ(e => e.Id, tickId);

                var existingtick = _tickets.FindOne(getQuery);
                existingtick.AssignedToId    = tick.AssignedToId;
                existingtick.CloseDate       = tick.CloseDate;
                existingtick.CreateDate      = tick.CreateDate;
                existingtick.CreatedBy       = tick.CreatedBy;
                existingtick.Issue           = tick.Issue;
                existingtick.PercentComplete = tick.PercentComplete;
                existingtick.ProjectName     = tick.ProjectName;
                existingtick.Remarks         = tick.Remarks;
                existingtick.Status          = tick.Status;

                _tickets.Save(existingtick);
                return(GetAll());
            }
            else
            {
                return(PartialView("Error"));
            }
        }
Exemple #3
0
 public void PutTicket(RelationModel model, TicketBase ticket)
 {
     using (model.For(out TicketBox ticketBox, () => new TicketBox()))
     {
         ticketBox.Put(ticket);
     }
 }
Exemple #4
0
 public PartialViewResult Create(TicketBase tick)
 {
     if (ModelState.IsValid)
     {
         var _tickets = mongoDatabase.GetCollection <TicketBase>("TicketBase");
         _tickets.Insert(tick);
         var id = tick.Id;
         return(GetAll());
     }
     else
     {
         return(PartialView("Error"));
     }
 }
Exemple #5
0
        public async Task <JsonResult> AddTicket(TicketBase newTicket)
        {
            if (newTicket.BaseTicketId != null && newTicket.Description != null && newTicket.BaseTicketId > 0 && newTicket.BaseTeamId > 0)
            {
                ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext()
                                       .GetUserManager <ApplicationUserManager>()
                                       .FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
                User curUser = await db.Users.SingleOrDefaultAsync(x => x.Email.ToLower().Equals(user.Email.ToLower()));

                TicketType ticketType = await db.TicketTypes.SingleOrDefaultAsync(x => x.Id == newTicket.TypeId);

                Ticket baseTicket = await db.Tickets.SingleOrDefaultAsync(x => x.Id == newTicket.BaseTicketId);

                if (curUser != null && ticketType != null)
                {
                    Ticket    ticket       = new Ticket(newTicket.BaseTeamId, curUser, newTicket.Description, ticketType, DateTime.Now, TicketState.New, baseTicket);
                    Ticket    ticketFromDb = db.Tickets.Add(ticket);
                    TicketDTO ticketDto    = new TicketDTO(ticketFromDb.Id, ticketFromDb.TeamId, ticketFromDb.User,
                                                           ticketFromDb.Description, ticketFromDb.Type, ticketFromDb.TimeCreated.ToString(), ticketFromDb.State,
                                                           ticketFromDb.ChildTickets.Count, ticketFromDb.Comments.Count);
                    await db.SaveChangesAsync();

                    return(Json(ticketDto));
                }
            }
            else if (newTicket.BaseTicketId == null && newTicket.Description != null && newTicket.BaseTeamId > 0)
            {
                ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext()
                                       .GetUserManager <ApplicationUserManager>()
                                       .FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
                User curUser = await db.Users.SingleOrDefaultAsync(x => x.Email.ToLower().Equals(user.Email.ToLower()));

                TicketType ticketType = await db.TicketTypes.SingleOrDefaultAsync(x => x.Id == newTicket.TypeId);

                if (curUser != null && ticketType != null)
                {
                    Ticket    ticket       = new Ticket(newTicket.BaseTeamId, curUser, newTicket.Description, ticketType, DateTime.Now, TicketState.New);
                    Ticket    ticketFromDb = db.Tickets.Add(ticket);
                    TicketDTO ticketDto    = new TicketDTO(ticketFromDb.Id, ticketFromDb.TeamId, ticketFromDb.User,
                                                           ticketFromDb.Description, ticketFromDb.Type, ticketFromDb.TimeCreated.ToString(), ticketFromDb.State,
                                                           ticketFromDb.ChildTickets.Count, ticketFromDb.Comments.Count);
                    await db.SaveChangesAsync();

                    return(Json(ticketDto));
                }
            }
            return(Json(null));
        }
        public async Task <JsonResult> AddTicket(TicketBase newTicket)
        {
            User curUser = await userManager.GetCurrentUser();

            string unescapedText = htmlValidator.ValidateHtml(HttpUtility.UrlDecode(newTicket.Description));

            newTicket.Description = unescapedText;
            TeamPermissions userPerms = await GetCurrentTeamPermissions(newTicket.BaseTeamId, curUser.Id);

            if (userPerms.CanCreateTicket == true || curUser.AppRole.Permissions.IsAdmin == true)
            {
                Ticket createdTicket = await ticketManager.Add(newTicket, curUser);

                TicketDTO ticketDto = dtoConverter.ConvertTicket(createdTicket, curUser, userPerms);
                return(Json(ticketDto));
            }
            return(Json(null));
        }
        public async Task <Ticket> Add(TicketBase newTicket, User user)
        {
            Ticket baseTicket = null;

            if (newTicket.BaseTicketId != null && newTicket.Description != null && newTicket.BaseTicketId > 0 && newTicket.BaseTeamId > 0)
            {
                baseTicket = await db.Tickets.SingleOrDefaultAsync(x => x.Id == newTicket.BaseTicketId);
            }
            if (newTicket.Description != null && newTicket.BaseTeamId > 0 && user != null && newTicket.TypeId > 0)
            {
                TicketType ticketType = await db.TicketTypes.SingleOrDefaultAsync(x => x.Id == newTicket.TypeId);

                if (ticketType != null)
                {
                    Ticket ticket       = new Ticket(newTicket.BaseTeamId, user, newTicket.Description, ticketType, DateTime.Now, TicketState.New, baseTicket);
                    Ticket ticketFromDb = db.Tickets.Add(ticket);
                    ticketLogger.WriteTicketLog(user, TicketAction.CreateTicket, baseTicket);
                    await db.SaveChangesAsync();

                    return(ticketFromDb);
                }
            }
            throw new ArgumentNullException();
        }
 public void Put(TicketBase ticket)
 {
     Tickets.Add(ticket);
 }