-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkItemRepository.cs
More file actions
55 lines (49 loc) · 2.03 KB
/
WorkItemRepository.cs
File metadata and controls
55 lines (49 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using AzureDevopsTracker.Data.Context;
using AzureDevopsTracker.Entities;
using AzureDevopsTracker.Interfaces.Internals;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AzureDevopsTracker.Data
{
internal class WorkItemRepository : Repository<WorkItem>, IWorkItemRepository
{
public WorkItemRepository(AzureDevopsTrackerContext context) : base(context) { }
public async Task<WorkItem> GetByWorkItemId(string workItemId)
{
return await DbSet
.Include(x => x.WorkItemsChanges)
.Include(x => x.TimeByStates)
.Include(x => x.ChangeLogItem)
.Include(x => x.CustomFields)
.FirstOrDefaultAsync(x => x.Id == workItemId);
}
public async Task<IEnumerable<WorkItem>> ListByWorkItemId(IEnumerable<string> workItemsId)
{
return await DbSet
.Include(x => x.WorkItemsChanges)
.Include(x => x.TimeByStates)
.Include(x => x.ChangeLogItem)
.Include(x => x.CustomFields)
.Where(x => workItemsId.Contains(x.Id))
.ToListAsync();
}
public async Task<IEnumerable<WorkItem>> ListByIterationPath(string iterationPath)
{
return await DbSet
.Include(x => x.WorkItemsChanges)
.Include(x => x.TimeByStates)
.Include(x => x.ChangeLogItem)
.Include(x => x.CustomFields)
.Where(x => x.IterationPath == iterationPath)
.ToListAsync();
}
public void RemoveAllTimeByState(List<TimeByState> timeByStates)
{
if (!timeByStates.Any())
return;
Db.TimeByStates.RemoveRange(timeByStates);
}
}
}