Skip to content

Commit

Permalink
rbiyovskiy/756 codeficator model (#763)
Browse files Browse the repository at this point in the history
* Codeficator Dto changes

* Added CodeficatorId to model

* mapping changes

* Service changes

* Tests changes

* Migration
  • Loading branch information
RBiyovskiy authored Jul 21, 2022
1 parent 40f1762 commit 972bfe2
Show file tree
Hide file tree
Showing 14 changed files with 2,843 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class CodeficatorAddressDto

public string Settlement { get; set; }

public string CityDistrict { get; set; }

public double Latitude { get; set; }

public double Longitude { get; set; }
Expand All @@ -22,7 +24,12 @@ public string FullName
{
get
{
string addr = Settlement;
string addr = CityDistrict;

if (!string.IsNullOrEmpty(Settlement))
{
addr += GetSplitter(addr) + Settlement;
}

if (!string.IsNullOrEmpty(TerritorialCommunity))
{
Expand Down
170 changes: 155 additions & 15 deletions OutOfSchool/OutOfSchool.DataAccess/Enums/CodeficatorCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,170 @@

namespace OutOfSchool.Services.Enums;

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

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

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

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

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

public static readonly CodeficatorCategory SearchableCategories = new ("MTCXK", 210); // Міста, що мають спеціальний статус, міста, селища міського типу, села та селища
public static readonly CodeficatorCategory UrbanSettlement = new UrbanSettlementCategory(); // Селища міського типу.

public static readonly CodeficatorCategory Village = new VillageCategory(); // Села.

public static readonly CodeficatorCategory Settlement = new SettlementCategory(); // Селища.

public static readonly CodeficatorCategory CityDistrict = new CityDistrictCategory(); // Райони в містах.

public static readonly CodeficatorCategory Level1 = new Level1Category(); // Автономна Республіка Крим, області та міста, що мають спеціальний статус.

public static readonly CodeficatorCategory Level2 = new Level2Category(); // Райони в областях та Автономній Республіці Крим та райони в містах.

public static readonly CodeficatorCategory Level4 = new Level4Category(); // Міста, селища міського типу, села та селища

public static readonly CodeficatorCategory SearchableCategories = new SearchableCategoriesCategory(); // Міста, що мають спеціальний статус, міста, селища міського типу, села та селища

private CodeficatorCategory(string name, int value)
: base(name, value)
{
}

public abstract string Abbrivation { get; }

private sealed class RegionCategory : CodeficatorCategory
{
public RegionCategory()
: base("O", 1)
{
}

public override string Abbrivation => "обл.";
}

private sealed class SpecialStatusCityCategory : CodeficatorCategory
{
public SpecialStatusCityCategory()
: base("K", 2)
{
}

public override string Abbrivation => "м.";
}

private sealed class DistrictCategory : CodeficatorCategory
{
public DistrictCategory()
: base("P", 4)
{
}

public override string Abbrivation => "р-н";
}

private sealed class TerritorialCommunityCategory : CodeficatorCategory
{
public TerritorialCommunityCategory()
: base("H", 8)
{
}

public override string Abbrivation => "отг";
}

private sealed class CityCategory : CodeficatorCategory
{
public CityCategory()
: base("M", 16)
{
}

public override string Abbrivation => "м.";
}

private sealed class UrbanSettlementCategory : CodeficatorCategory
{
public UrbanSettlementCategory()
: base("T", 32)
{
}

public override string Abbrivation => "смт";
}

private sealed class VillageCategory : CodeficatorCategory
{
public VillageCategory()
: base("C", 64)
{
}

public override string Abbrivation => "с.";
}

private sealed class SettlementCategory : CodeficatorCategory
{
public SettlementCategory()
: base("X", 128)
{
}

public override string Abbrivation => "с-ще";
}

private sealed class CityDistrictCategory : CodeficatorCategory
{
public CityDistrictCategory()
: base("B", 258)
{
}

public override string Abbrivation => "р-н";
}

// Group (flag) values

private sealed class Level1Category : CodeficatorCategory
{
public Level1Category()
: base("OK", 3)
{
}

public override string Abbrivation => string.Empty;
}

private sealed class Level2Category : CodeficatorCategory
{
public Level2Category()
: base("PB", 260)
{
}

public override string Abbrivation => string.Empty;
}

private sealed class Level4Category : CodeficatorCategory
{
public Level4Category()
: base("MTCX", 208)
{
}

public override string Abbrivation => string.Empty;
}

private sealed class SearchableCategoriesCategory : CodeficatorCategory
{
public SearchableCategoriesCategory()
: base("MTCXK", 210)
{
}

public override string Abbrivation => string.Empty;
}
}
4 changes: 4 additions & 0 deletions OutOfSchool/OutOfSchool.DataAccess/Models/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class Address : IKeyedEntity<long>
// parameter r means size (resolution) of hexagon
public ulong GeoHash => Api.GeoToH3(default(GeoCoord).SetDegrees((decimal)Latitude, (decimal)Longitude), GeoMathHelper.Resolution);

public long CodeficatorId { get; set; }

public virtual Codeficator Codeficator { get; set; }

public override bool Equals(object obj)
{
if (obj == null)
Expand Down
Loading

0 comments on commit 972bfe2

Please sign in to comment.