Revize 87e9a7c9
Přidáno uživatelem Milan Hotovec před téměř 4 roky(ů)
src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGlobalDefinitionAreaRepository.cs | ||
---|---|---|
1 |
using System; |
|
1 |
using Leuze.Modules.Goal.Domain.Domains; |
|
2 |
using System; |
|
2 | 3 |
using System.Collections.Generic; |
3 | 4 |
using System.Linq; |
4 | 5 |
using System.Text; |
... | ... | |
8 | 9 |
{ |
9 | 10 |
public interface IGlobalDefinitionAreaRepository |
10 | 11 |
{ |
12 |
Task<bool> AddAsync(GlobalDefinitionArea gdArea); |
|
13 |
|
|
14 |
Task<bool> RemoveAsync(Guid id); |
|
15 |
|
|
16 |
Task<GlobalDefinitionArea> GetByIdAsync(Guid id); |
|
17 |
|
|
18 |
Task<List<GlobalDefinitionArea>> GetAllAsync(); |
|
19 |
|
|
20 |
Task<bool> SetFrom(Guid id, DateTime from); |
|
21 |
|
|
22 |
Task<bool> SetTo(Guid id, DateTime to); |
|
23 |
|
|
24 |
Task<bool> SetCompanyVariSetVariCompanySuccess(Guid id, double vari); |
|
25 |
|
|
11 | 26 |
} |
12 | 27 |
} |
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs | ||
---|---|---|
3 | 3 |
using Leuze.Core.Infrastructure.Persistence; |
4 | 4 |
using Leuze.Modules.Goal.Domain.Domains; |
5 | 5 |
using Leuze.Modules.Goal.Domain.Repositories; |
6 |
using Microsoft.EntityFrameworkCore; |
|
6 | 7 |
using System; |
7 | 8 |
using System.Collections.Generic; |
8 | 9 |
using System.Linq; |
... | ... | |
43 | 44 |
|
44 | 45 |
public async Task<List<Comment>> GetAllForGoalAsync(Guid goalId) |
45 | 46 |
{ |
46 |
return dbSet.Where(item => item.GoalId == goalId).ToList(); //TODO: await??
|
|
47 |
return await dbSet.Where(item => item.GoalId == goalId).ToListAsync();
|
|
47 | 48 |
} |
48 | 49 |
|
49 | 50 |
public async Task<List<Comment>> GetAllAsync() |
50 | 51 |
{ |
51 |
return dbSet.ToList(); //TODO: Await??
|
|
52 |
return await dbSet.ToListAsync();
|
|
52 | 53 |
} |
53 | 54 |
|
54 | 55 |
public async Task<bool> EditAsync(Guid id, string text) |
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GlobalDefinitionAreaRepository.cs | ||
---|---|---|
1 |
using Leuze.Modules.Goal.Domain.Repositories; |
|
1 |
using ExtCore.Data.EntityFramework; |
|
2 |
using Leuze.Modules.Goal.Domain.Domains; |
|
3 |
using Leuze.Modules.Goal.Domain.Repositories; |
|
4 |
using Microsoft.EntityFrameworkCore; |
|
2 | 5 |
using System; |
3 | 6 |
using System.Collections.Generic; |
4 | 7 |
using System.Linq; |
... | ... | |
7 | 10 |
|
8 | 11 |
namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories |
9 | 12 |
{ |
10 |
class GlobalDefinitionAreaRepository : IGlobalDefinitionAreaRepository |
|
13 |
class GlobalDefinitionAreaRepository : RepositoryBase<GlobalDefinitionArea>, IGlobalDefinitionAreaRepository
|
|
11 | 14 |
{ |
15 |
public async Task<bool> AddAsync(GlobalDefinitionArea gdArea) |
|
16 |
{ |
|
17 |
await dbSet.AddAsync(gdArea); |
|
18 |
await storageContext.SaveChangesAsync(); |
|
19 |
return true; |
|
20 |
} |
|
21 |
|
|
22 |
public async Task<List<GlobalDefinitionArea>> GetAllAsync() |
|
23 |
{ |
|
24 |
return await dbSet.ToListAsync(); |
|
25 |
} |
|
26 |
|
|
27 |
public async Task<GlobalDefinitionArea> GetByIdAsync(Guid id) |
|
28 |
{ |
|
29 |
return await dbSet.FindAsync(id); |
|
30 |
} |
|
31 |
|
|
32 |
public async Task<bool> RemoveAsync(Guid id) |
|
33 |
{ |
|
34 |
GlobalDefinitionArea item = await GetByIdAsync(id); |
|
35 |
if (item == null) |
|
36 |
{ |
|
37 |
return false; |
|
38 |
} |
|
39 |
dbSet.Remove(item); |
|
40 |
await storageContext.SaveChangesAsync(); |
|
41 |
return true; |
|
42 |
} |
|
43 |
|
|
44 |
public async Task<bool> SetCompanyVariSetVariCompanySuccess(Guid id, double vari) |
|
45 |
{ |
|
46 |
GlobalDefinitionArea item = await dbSet.FindAsync(id); |
|
47 |
if (item == null) return false; |
|
48 |
item.SetVariCompanySuccess(vari); |
|
49 |
await storageContext.SaveChangesAsync(); |
|
50 |
return true; |
|
51 |
} |
|
52 |
|
|
53 |
public async Task<bool> SetFrom(Guid id, DateTime from) |
|
54 |
{ |
|
55 |
GlobalDefinitionArea item = await dbSet.FindAsync(id); |
|
56 |
if (item == null) return false; |
|
57 |
item.SetFrom(from); |
|
58 |
await storageContext.SaveChangesAsync(); |
|
59 |
return true; |
|
60 |
} |
|
61 |
|
|
62 |
public async Task<bool> SetTo(Guid id, DateTime to) |
|
63 |
{ |
|
64 |
GlobalDefinitionArea item = await dbSet.FindAsync(id); |
|
65 |
if (item == null) return false; |
|
66 |
item.SetTo(to); |
|
67 |
await storageContext.SaveChangesAsync(); |
|
68 |
return true; |
|
69 |
} |
|
12 | 70 |
} |
13 | 71 |
} |
Také k dispozici: Unified diff
Global definition area Repo prepared