예제 #1
0
        public async Task MarkTicketAsSeen(long ticketId, string userName)
        {
            var user = await _userManager.FindByNameAsync(userName);

            if (user == null)
            {
                return;
            }

            if (!_dbContext.TrackItUserTickets.Any(ll => ll.TicketId == ticketId && ll.TrackItUserId == user.Id))
            {
                _dbContext.TrackItUserTickets.Add(new TrackItUserTicket()
                {
                    TicketId = ticketId, TrackItUserId = user.Id
                });
                _dbContext.SaveChanges();
            }
        }
예제 #2
0
        public static void Initialize(TrackItContext context)
        {
            if (context.Projects.Any())
            {
                return;
            }

            string lorem50 = "Lorem ipsum dolor sit amet consectetur adipisicing elit. Esse tenetur quia quo voluptatem exercitationem voluptates praesentium animi cum ipsum magni fugit incidunt in nobis est unde commodi alias culpa quisquam, recusandae accusamus! Repudiandae cumque eius recusandae ex, est saepe in ab aliquam esse nam. Corrupti pariatur corporis illum cupiditate perspiciatis!";

            var projects = new Project[]
            {
                new Project()
                {
                    Name = "TrackIt", CreateTs = DateTime.Now
                },
                new Project()
                {
                    Name = "Haushalt", CreateTs = DateTime.Now
                },
                new Project()
                {
                    Name = "AnderesProjekt", CreateTs = DateTime.Now
                },
            };

            context.Projects.AddRange(projects);

            var tickets = new Ticket[]
            {
                new Ticket()
                {
                    Project = projects[0], CreatedTs = DateTime.Now, State = eTicketState.New, Topic = "dummy1", Type = eTicketType.Feature, AssignedTo = "alex2", Reporter = "alex", Description = lorem50
                },
                new Ticket()
                {
                    Project = projects[0], CreatedTs = DateTime.Now, State = eTicketState.Done, Topic = "dummy2", Type = eTicketType.Feature, AssignedTo = "alex2", Reporter = "alex", Description = lorem50
                },
                new Ticket()
                {
                    Project = projects[0], CreatedTs = DateTime.Now, State = eTicketState.InProgress, Topic = "dummy3", Type = eTicketType.Bug, AssignedTo = "alex2", Reporter = "alex", Description = lorem50
                },
                new Ticket()
                {
                    Project = projects[1], CreatedTs = DateTime.Now, State = eTicketState.New, Topic = "dummy4", Type = eTicketType.Bug, AssignedTo = "alex2", Reporter = "alex", Description = lorem50
                },
                new Ticket()
                {
                    Project = projects[2], CreatedTs = DateTime.Now, State = eTicketState.Denied, Topic = "dummy5", Type = eTicketType.Service, AssignedTo = "alex2", Reporter = "alex", Description = lorem50
                },
            };

            foreach (var ticket in tickets)
            {
                context.Tickets.Add(ticket);
                context.TicketComments.Add(new TicketComment()
                {
                    Ticket = ticket, CreatedTs = DateTime.Now, User = "******", Comment = lorem50
                });
                context.TicketComments.Add(new TicketComment()
                {
                    Ticket = ticket, CreatedTs = DateTime.Now, User = "******", Comment = lorem50
                });
            }

            context.SaveChanges();
        }