public IReadOnlyList <AvailableRelationship> GetAvailableRelationships()
        {
            var nonDirectional = data.Query <NonDirectionalRelationship>().ToLazy();
            var directional    = data.Query <DirectionalRelationship>().ToLazy();

            return(directional.Value
                   .SelectMany(GetAvailableRelationships)
                   .Union(nonDirectional.Value.SelectMany(GetAvailableRelationships))
                   .ToArray());
        }
        public IReadOnlyList <ListedLabel> GetLabels(string searchQuery, int?maxResults = null)
        {
            var queryStr = searchQuery ?? String.Empty;

            var query = (from label in data.Query <Label>()
                         let openCount = label.Tickets.Count(x => !x.Closed)
                                         let closedCount = label.Tickets.Count(x => x.Closed)
                                                           let exactMatch = label.Name.Equals(queryStr)
                                                                            let startsWith = label.Name.StartsWith(queryStr)
                                                                                             let contains = label.Name.Contains(queryStr)
                                                                                                            let relevance = (
                             exactMatch ? 0 :
                             startsWith ? 1 :
                             contains ? 2 :
                             3
                             )
                                                                                                                            where exactMatch || startsWith || contains
                                                                                                                            orderby relevance
                                                                                                                            select new ListedLabel {
                Name = label.Name,
                CountOfOpenTickets = openCount,
                CountOfClosedTickets = closedCount
            });

            if (maxResults.HasValue && maxResults.Value > 0)
            {
                query = query.Take(maxResults.Value);
            }

            return(query.ToArray());
        }
Exemplo n.º 3
0
        public User Get(string username)
        {
            if (username == null)
            {
                throw new ArgumentNullException(nameof(username));
            }

            return(repo.Query <User>().FirstOrDefault(x => x.Username == username));
        }
        protected override RuleOutcome GetValueOutcome(string value)
        {
            if (String.IsNullOrEmpty(value))
            {
                return(RuleOutcome.Success);
            }

            var hasDuplicateProjectCode = data.Query <Project>()
                                          .Any(x => x.Code == value);

            return(hasDuplicateProjectCode ? RuleOutcome.Failure : RuleOutcome.Success);
        }
Exemplo n.º 5
0
        public IList <Sprint> GetSprints(ListSprintsRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(data.Query <Sprint>()
                   .Where(GetSpecification(request))
                   .OrderBy(x => x.StartDate.HasValue ? x.StartDate : x.CreationDate)
                   .ToList());
        }
Exemplo n.º 6
0
        public Label GetLabel(string name)
        {
            if (String.IsNullOrEmpty(name))
            {
                return(null);
            }

            return(data.Query <Label>()
                   .Where(x => x.Name == name)
                   .FetchChildren(x => x.Tickets)
                   .AsEnumerable()
                   .FirstOrDefault());
        }
Exemplo n.º 7
0
 public IReadOnlyList <ListedLabel> GetAllLabels()
 {
     return((from label in data.Query <Label>()
             let openCount = label.Tickets.Count(isOpen)
                             let closedCount = label.Tickets.Count(isClosed)
                                               orderby label.Name
                                               select new ListedLabel {
         Name = label.Name,
         CountOfOpenTickets = openCount,
         CountOfClosedTickets = closedCount
     })
            .ToArray());
 }
Exemplo n.º 8
0
        public Project GetCurrentProject()
        {
            var user = userReader.RequireCurrentUser();

            return((from project in data.Query <Project>()
                    let priority = project.Administrators.Contains(user)
                                   ? 0
                                   : project.Contributors.Contains(user)
                                   ? 1
                                   : 2
                                   orderby priority, project.Name
                    select project)
                   .FirstOrDefault());
        }
Exemplo n.º 9
0
        public TimeSpan GetTotalTimeLogged(Ticket ticket)
        {
            if (ticket == null)
            {
                throw new ArgumentNullException(nameof(ticket));
            }

            var spec = specFactory(ticket);

            return(data.Query <TicketWorkLog>()
                   .Where(spec)
                   .AsEnumerable()
                   .Aggregate(TimeSpan.Zero, (acc, next) => acc + next.GetTimeSpent()));
        }
Exemplo n.º 10
0
        public Ticket GetTicketByReference(TicketReference reference)
        {
            if (reference == null)
            {
                return(null);
            }

            var spec = specFactory(reference);

            return(repo
                   .Query <Ticket>()
                   .Where(spec)
                   .SingleOrDefault());
        }
Exemplo n.º 11
0
        protected override RuleOutcome GetOutcome(EditProjectRequest validated)
        {
            if (String.IsNullOrEmpty(validated.Code))
            {
                return(RuleOutcome.Success);
            }
            if (validated.Identity == null)
            {
                return(RuleOutcome.Success);
            }

            var project          = data.Theorise(validated.Identity);
            var hasDuplicateCode = data.Query <Project>()
                                   .Any(x => x != project && x.Code == validated.Code);

            return(hasDuplicateCode ? RuleOutcome.Failure : RuleOutcome.Success);
        }
Exemplo n.º 12
0
        public Ticket GetTicket(IIdentity <Ticket> ticket)
        {
            if (ticket == null)
            {
                throw new ArgumentNullException(nameof(ticket));
            }

            var ticketTheory = repo.Theorise(ticket);

            return(repo
                   .Query <Ticket>()
                   .Where(x => x == ticketTheory)
                   .FetchChildren(x => x.Comments)
                   .FetchChild(x => x.Type)
                   .ToArray()
                   .FirstOrDefault());
        }
Exemplo n.º 13
0
        public Sprint GetSprint(IIdentity <Sprint> identity)
        {
            if (ReferenceEquals(identity, null))
            {
                return(null);
            }

            var theory = repo.Theorise(identity);

            return(repo
                   .Query <Sprint>()
                   .Where(x => x == theory)
                   .FetchChild(x => x.Project)
                   .FetchChildren(x => x.Tickets)
                   .ThenFetchGrandchild(x => x.Type)
                   .ToList()
                   .SingleOrDefault());
        }
Exemplo n.º 14
0
        public IReadOnlyList <ListedLabel> GetLabels(string searchQuery, int?maxResults = null)
        {
            var query = (from label in data.Query <Label>()
                         let openCount = label.Tickets.Count(x => !x.Closed)
                                         let closedCount = label.Tickets.Count(x => x.Closed)
                                                           orderby openCount descending
                                                           select new ListedLabel {
                Name = label.Name,
                CountOfOpenTickets = openCount,
                CountOfClosedTickets = closedCount
            });

            if (maxResults.HasValue && maxResults.Value > 0)
            {
                query = query.Take(maxResults.Value);
            }

            return(query.ToArray());
        }
        List <TheoreticalRelationship> GetExistingRelationships(IIdentity <Ticket> ticketIdentity)
        {
            if (ReferenceEquals(ticketIdentity, null))
            {
                return(new List <TheoreticalRelationship>());
            }

            var ticket = data.Theorise(ticketIdentity);

            return((from rel in data.Query <TicketRelationship>()
                    where
                    rel.PrimaryTicket == ticket ||
                    rel.SecondaryTicket == ticket
                    select rel)
                   .FetchChild(x => x.Relationship)
                   .AsEnumerable()
                   .Select(MapToTheoreticalRelationship)
                   .ToList());
        }
Exemplo n.º 16
0
        public void Load()
        {
            using (var tran = transactionCreator.GetTransaction())
            {
                var project = repo.Query <Project>().First();
                var admin   = userQuery.Get(AdminUser.Username);
                admin.SiteAdministrator = true;

                var youssef = CreateYoussef();
                project.Administrators.Add(youssef);

                var sprint1 = CreateSprintOne(project);
                var sprint2 = CreateSprintTwo(project);
                var sprint3 = CreateSprintThree(project);

                var bug         = CreateBugType();
                var enhancement = CreateEnhancementType();

                var ticket1 = CreateTicketOne(sprint1, youssef, enhancement);
                var ticket2 = CreateTicketTwo(sprint1, youssef, enhancement);
                var ticket3 = CreateTicketThree(sprint1, youssef, enhancement);
                var ticket4 = CreateClosedTicketFour(sprint1, youssef, bug);
                var ticket5 = CreateTicketFive(sprint2, youssef, bug);
                var ticket6 = CreateTicketSix(sprint2, youssef, bug);

                project.NextAvailableTicketNumber = 7;

                var comment1 = CreateCommentOne(ticket1, youssef);
                var comment2 = CreateCommentTwo(ticket2, admin);
                var comment3 = CreateCommentThree(ticket2, admin);
                var comment4 = CreateCommentFour(ticket2, admin);

                CreateExistingLabelOne(ticket2, ticket3, ticket4);
                CreateExistingLabelTwo(ticket6);

                tran.Commit();
            }
        }
Exemplo n.º 17
0
        public TicketDetailDto GetTicketDetailDto(TicketReference reference)
        {
            var ticket = GetTicket(reference);

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

            var eagerFetchedTicket = data
                                     .Query <Ticket>()
                                     .Where(x => x == ticket)
                                     .FetchChildren(x => x.Comments)
                                     .FetchChildren(x => x.PrimaryRelationships)
                                     .FetchChildren(x => x.SecondaryRelationships)
                                     .FetchChildren(x => x.Labels)
                                     .FetchChild(x => x.Project)
                                     .FetchChild(x => x.User)
                                     .FetchChild(x => x.Type)
                                     .AsEnumerable()
                                     .FirstOrDefault();

            return(mapper.Map <TicketDetailDto>(eagerFetchedTicket));
        }
Exemplo n.º 18
0
 User GetUserAccount(LoginCredentials enteredCredentials)
 {
     return(query.Query <User>().SingleOrDefault(x => x.Username == enteredCredentials.Username));
 }
Exemplo n.º 19
0
 public IList <Project> GetsProjects()
 {
     return(data.Query <Project>()
            .Where(projectSpec)
            .ToList());
 }
Exemplo n.º 20
0
 public IQueryable <Ticket> GetQuery() => data.Query <Ticket>();
Exemplo n.º 21
0
 public IReadOnlyCollection <TicketType> GetTicketTypes() => data.Query <TicketType>().ToArray();
Exemplo n.º 22
0
        public override IReadOnlyCollection <Label> GetLabels(IReadOnlyCollection <string> labelNames)
        {
            var spec = new LabelNameIn(labelNames);

            return(entityData.Query <Label>().Where(spec).ToList());
        }
Exemplo n.º 23
0
 public Project GetProject(string code)
 {
     return(data.Query <Project>().FirstOrDefault(x => x.Code == code));
 }