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()); }
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); }
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()); }
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()); }
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()); }
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()); }
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())); }
public Ticket GetTicketByReference(TicketReference reference) { if (reference == null) { return(null); } var spec = specFactory(reference); return(repo .Query <Ticket>() .Where(spec) .SingleOrDefault()); }
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); }
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()); }
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()); }
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()); }
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(); } }
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)); }
User GetUserAccount(LoginCredentials enteredCredentials) { return(query.Query <User>().SingleOrDefault(x => x.Username == enteredCredentials.Username)); }
public IList <Project> GetsProjects() { return(data.Query <Project>() .Where(projectSpec) .ToList()); }
public IQueryable <Ticket> GetQuery() => data.Query <Ticket>();
public IReadOnlyCollection <TicketType> GetTicketTypes() => data.Query <TicketType>().ToArray();
public override IReadOnlyCollection <Label> GetLabels(IReadOnlyCollection <string> labelNames) { var spec = new LabelNameIn(labelNames); return(entityData.Query <Label>().Where(spec).ToList()); }
public Project GetProject(string code) { return(data.Query <Project>().FirstOrDefault(x => x.Code == code)); }