Skip to content

Commit 972bfe2

Browse files
authored
rbiyovskiy/756 codeficator model (#763)
* Codeficator Dto changes * Added CodeficatorId to model * mapping changes * Service changes * Tests changes * Migration
1 parent 40f1762 commit 972bfe2

File tree

14 files changed

+2843
-114
lines changed

14 files changed

+2843
-114
lines changed

OutOfSchool/OutOfSchool.Common/Models/CodeficatorAddressDto.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class CodeficatorAddressDto
1414

1515
public string Settlement { get; set; }
1616

17+
public string CityDistrict { get; set; }
18+
1719
public double Latitude { get; set; }
1820

1921
public double Longitude { get; set; }
@@ -22,7 +24,12 @@ public string FullName
2224
{
2325
get
2426
{
25-
string addr = Settlement;
27+
string addr = CityDistrict;
28+
29+
if (!string.IsNullOrEmpty(Settlement))
30+
{
31+
addr += GetSplitter(addr) + Settlement;
32+
}
2633

2734
if (!string.IsNullOrEmpty(TerritorialCommunity))
2835
{

OutOfSchool/OutOfSchool.DataAccess/Enums/CodeficatorCategory.cs

Lines changed: 155 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,170 @@
22

33
namespace OutOfSchool.Services.Enums;
44

5-
public sealed class CodeficatorCategory : SmartEnum<CodeficatorCategory>
5+
public abstract class CodeficatorCategory : SmartEnum<CodeficatorCategory>
66
{
7-
public static readonly CodeficatorCategory Region = new ("O", 1); // Автономна Республіка Крим, області.
8-
public static readonly CodeficatorCategory SpecialStatusCity = new ("K", 2); // Міста, що мають спеціальний статус.
9-
public static readonly CodeficatorCategory Level1 = new ("OK", 3); // Автономна Республіка Крим, області та міста, що мають спеціальний статус.
7+
public static readonly CodeficatorCategory Region = new RegionCategory(); // Автономна Республіка Крим, області.
108

11-
public static readonly CodeficatorCategory District = new ("P", 4); // Райони в областях та Автономній Республіці Крим.
9+
public static readonly CodeficatorCategory SpecialStatusCity = new SpecialStatusCityCategory(); // Міста, що мають спеціальний статус.
1210

13-
public static readonly CodeficatorCategory TerritorialCommunity = new ("H", 8); // Території територіальних громад (назви територіальних громад) в областях, територіальні громади Автономної Республіки Крим.
14-
public static readonly CodeficatorCategory Level3 = new ("H", 8); // Території територіальних громад (назви територіальних громад) в областях, територіальні громади Автономної Республіки Крим.
11+
public static readonly CodeficatorCategory District = new DistrictCategory(); // Райони в областях та Автономній Республіці Крим.
1512

16-
public static readonly CodeficatorCategory City = new ("M", 16); // Міста.
17-
public static readonly CodeficatorCategory UrbanSettlement = new ("T", 32); // Селища міського типу.
18-
public static readonly CodeficatorCategory Village = new ("C", 64); // Села.
19-
public static readonly CodeficatorCategory Settlement = new ("X", 128); // Селища.
20-
public static readonly CodeficatorCategory Level4 = new ("MTCX", 208); // Міста, селища міського типу, села та селища
13+
public static readonly CodeficatorCategory TerritorialCommunity = new TerritorialCommunityCategory(); // Території територіальних громад (назви територіальних громад) в областях, територіальні громади Автономної Республіки Крим.
2114

22-
public static readonly CodeficatorCategory CityDistrict = new ("B", 256); // Райони в містах.
23-
public static readonly CodeficatorCategory Level2 = new ("PB", 260); // Райони в областях та Автономній Республіці Крим та райони в містах.
15+
public static readonly CodeficatorCategory City = new CityCategory(); // Міста.
2416

25-
public static readonly CodeficatorCategory SearchableCategories = new ("MTCXK", 210); // Міста, що мають спеціальний статус, міста, селища міського типу, села та селища
17+
public static readonly CodeficatorCategory UrbanSettlement = new UrbanSettlementCategory(); // Селища міського типу.
18+
19+
public static readonly CodeficatorCategory Village = new VillageCategory(); // Села.
20+
21+
public static readonly CodeficatorCategory Settlement = new SettlementCategory(); // Селища.
22+
23+
public static readonly CodeficatorCategory CityDistrict = new CityDistrictCategory(); // Райони в містах.
24+
25+
public static readonly CodeficatorCategory Level1 = new Level1Category(); // Автономна Республіка Крим, області та міста, що мають спеціальний статус.
26+
27+
public static readonly CodeficatorCategory Level2 = new Level2Category(); // Райони в областях та Автономній Республіці Крим та райони в містах.
28+
29+
public static readonly CodeficatorCategory Level4 = new Level4Category(); // Міста, селища міського типу, села та селища
30+
31+
public static readonly CodeficatorCategory SearchableCategories = new SearchableCategoriesCategory(); // Міста, що мають спеціальний статус, міста, селища міського типу, села та селища
2632

2733
private CodeficatorCategory(string name, int value)
2834
: base(name, value)
2935
{
3036
}
37+
38+
public abstract string Abbrivation { get; }
39+
40+
private sealed class RegionCategory : CodeficatorCategory
41+
{
42+
public RegionCategory()
43+
: base("O", 1)
44+
{
45+
}
46+
47+
public override string Abbrivation => "обл.";
48+
}
49+
50+
private sealed class SpecialStatusCityCategory : CodeficatorCategory
51+
{
52+
public SpecialStatusCityCategory()
53+
: base("K", 2)
54+
{
55+
}
56+
57+
public override string Abbrivation => "м.";
58+
}
59+
60+
private sealed class DistrictCategory : CodeficatorCategory
61+
{
62+
public DistrictCategory()
63+
: base("P", 4)
64+
{
65+
}
66+
67+
public override string Abbrivation => "р-н";
68+
}
69+
70+
private sealed class TerritorialCommunityCategory : CodeficatorCategory
71+
{
72+
public TerritorialCommunityCategory()
73+
: base("H", 8)
74+
{
75+
}
76+
77+
public override string Abbrivation => "отг";
78+
}
79+
80+
private sealed class CityCategory : CodeficatorCategory
81+
{
82+
public CityCategory()
83+
: base("M", 16)
84+
{
85+
}
86+
87+
public override string Abbrivation => "м.";
88+
}
89+
90+
private sealed class UrbanSettlementCategory : CodeficatorCategory
91+
{
92+
public UrbanSettlementCategory()
93+
: base("T", 32)
94+
{
95+
}
96+
97+
public override string Abbrivation => "смт";
98+
}
99+
100+
private sealed class VillageCategory : CodeficatorCategory
101+
{
102+
public VillageCategory()
103+
: base("C", 64)
104+
{
105+
}
106+
107+
public override string Abbrivation => "с.";
108+
}
109+
110+
private sealed class SettlementCategory : CodeficatorCategory
111+
{
112+
public SettlementCategory()
113+
: base("X", 128)
114+
{
115+
}
116+
117+
public override string Abbrivation => "с-ще";
118+
}
119+
120+
private sealed class CityDistrictCategory : CodeficatorCategory
121+
{
122+
public CityDistrictCategory()
123+
: base("B", 258)
124+
{
125+
}
126+
127+
public override string Abbrivation => "р-н";
128+
}
129+
130+
// Group (flag) values
131+
132+
private sealed class Level1Category : CodeficatorCategory
133+
{
134+
public Level1Category()
135+
: base("OK", 3)
136+
{
137+
}
138+
139+
public override string Abbrivation => string.Empty;
140+
}
141+
142+
private sealed class Level2Category : CodeficatorCategory
143+
{
144+
public Level2Category()
145+
: base("PB", 260)
146+
{
147+
}
148+
149+
public override string Abbrivation => string.Empty;
150+
}
151+
152+
private sealed class Level4Category : CodeficatorCategory
153+
{
154+
public Level4Category()
155+
: base("MTCX", 208)
156+
{
157+
}
158+
159+
public override string Abbrivation => string.Empty;
160+
}
161+
162+
private sealed class SearchableCategoriesCategory : CodeficatorCategory
163+
{
164+
public SearchableCategoriesCategory()
165+
: base("MTCXK", 210)
166+
{
167+
}
168+
169+
public override string Abbrivation => string.Empty;
170+
}
31171
}

OutOfSchool/OutOfSchool.DataAccess/Models/Address.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public class Address : IKeyedEntity<long>
3636
// parameter r means size (resolution) of hexagon
3737
public ulong GeoHash => Api.GeoToH3(default(GeoCoord).SetDegrees((decimal)Latitude, (decimal)Longitude), GeoMathHelper.Resolution);
3838

39+
public long CodeficatorId { get; set; }
40+
41+
public virtual Codeficator Codeficator { get; set; }
42+
3943
public override bool Equals(object obj)
4044
{
4145
if (obj == null)

0 commit comments

Comments
 (0)