-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathVillageTask.cs
More file actions
25 lines (20 loc) · 969 Bytes
/
Copy pathVillageTask.cs
File metadata and controls
25 lines (20 loc) · 969 Bytes
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
namespace MainCore.Tasks.Base
{
public abstract class VillageTask(AccountId accountId, VillageId villageId) : AccountTask(accountId), IAccountVillageConstraint
{
public VillageId VillageId { get; } = villageId;
protected string VillageName { get; set; } = "Unknown village";
public void SetVillageName(AppDbContext context)
{
if (VillageName != "Unknown village")
return;
var getVillageNameSpec = new GetVillageNameSpec(VillageId);
VillageName = context.Villages
.WithSpecification(getVillageNameSpec)
.FirstOrDefault() ?? "Unknown village";
}
public override string Description => $"{TaskName} in {VillageName}";
public override string Key => $"{AccountId}-{VillageId}";
public void Deconstruct(out AccountId accountId, out VillageId villageId) => (accountId, villageId) = (AccountId, VillageId);
}
}