Commit c386d9eb04e796da1a5645ebc09e3a082589441d

Authored by Yarik
1 parent cc1ac3ea

Big commit

src/MapConsole/OsmImport.cs
... ... @@ -153,6 +153,14 @@ namespace MapConsole
153 153 Console.WriteLine(doc.ToString());
154 154 }
155 155  
  156 + public async Task Relation(int Id)
  157 + {
  158 + await Task.Run(async () => {
  159 + Curl curl = new Curl();
  160 + string result = await curl.GetRelation(Id);
  161 + this.SaveRelation(result);
  162 + });
  163 + }
156 164 public async Task Relation()
157 165 {
158 166 await Task.Run(async () => {
... ... @@ -184,23 +192,6 @@ namespace MapConsole
184 192 XElement relationEl = doc.Root.Element("relation");
185 193 string relationRemoteId = relationEl.Attribute("id").Value;
186 194 string[] inserted = {
187   - // "443032",
188   - // "395707",
189   - // "2143285",
190   - // "2143788",
191   - // "2162219",
192   - // "2683872",
193   - // "1613996",
194   - // "1147187",
195   - // "1147852",
196   - // "23751",
197   - // "2143724",
198   - // "451785",
199   - // "2141546",
200   - // "2143335",
201   - // "1151237",
202   - // "975415",
203   - // "1602684"
204 195 };
205 196 if (inserted.Contains(relationRemoteId)) {
206 197 Console.WriteLine("Skipped relation " + relationRemoteId);
... ...
src/MapConsole/Program.cs
... ... @@ -30,6 +30,11 @@ namespace MapConsole
30 30 case "relation":
31 31 osm.Relation().Wait();
32 32 break;
  33 + case "relationId":
  34 + Console.WriteLine("Введите ID");
  35 + string line = Console.ReadLine();
  36 + osm.Relation(Int32.Parse(line)).Wait();
  37 + break;
33 38 }
34 39 }
35 40 }
... ...
src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.dll
No preview for this file type
src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.pdb
No preview for this file type
src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.dll
No preview for this file type
src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.pdb
No preview for this file type
src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.dll
No preview for this file type
src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.pdb
No preview for this file type
src/Maps/Controllers/AuthorityController.cs 0 → 100755
  1 +using System.Linq;
  2 +using System.Threading.Tasks;
  3 +using Microsoft.AspNetCore.Mvc;
  4 +using Microsoft.AspNetCore.Mvc.Rendering;
  5 +using Microsoft.EntityFrameworkCore;
  6 +using MapsDb;
  7 +using MapsDb.Interfaces;
  8 +using MapsDb.DataService;
  9 +using MapsModels.ViewModels;
  10 +using MapsModels.DsModels;
  11 +using System;
  12 +
  13 +namespace Maps.Controllers
  14 +{
  15 + public class AuthorityController : Controller
  16 + {
  17 + private readonly IAuthorityDs _authorityDs;
  18 + private readonly IRoadDs _roadDs;
  19 + private readonly ICrossSectionDs _crossSectionDs;
  20 +
  21 + public AuthorityController(IAuthorityDs AuthorityDs, IRoadDs RoadDs, ICrossSectionDs CrossSectionDs, IRegionDs RegionDs)
  22 + {
  23 + _authorityDs = AuthorityDs;
  24 + _roadDs = RoadDs;
  25 + _crossSectionDs = CrossSectionDs;
  26 + }
  27 +
  28 + // GET: Authority
  29 + [HttpGet]
  30 + public async Task<IActionResult> Index([FromQuery] PaginationDsM data)
  31 + {
  32 +
  33 + var authoritys = await _authorityDs.GetIndexListAsync(data);
  34 +
  35 + AuthorityListVm vm = new AuthorityListVm
  36 + {
  37 + AuthorityEditDsM = authoritys.ToList()
  38 + };
  39 +
  40 + return Json(vm);
  41 +
  42 +
  43 +
  44 + }
  45 +
  46 + [HttpGet]
  47 + public async Task<IActionResult> Directory(){
  48 + var Road = await _roadDs.GetSelectListAsync();
  49 + var CrossSection = await _crossSectionDs.GetSelectListAsync();
  50 +
  51 + CatalogListVm vm = new CatalogListVm
  52 + {
  53 + RoadSelectListDsM = Road.ToList(),
  54 + CrossSectionSelectListDsM = CrossSection.ToList(),
  55 + };
  56 + return Json(vm);
  57 + }
  58 +
  59 +
  60 + [HttpPost]
  61 + public async Task<IActionResult> Create([FromBody] AuthorityEditDsM data)
  62 + {
  63 + var result = await _authorityDs.CreateAsync(data);
  64 + return Json(result);
  65 + }
  66 +
  67 + [HttpPost]
  68 + public async Task<IActionResult> Update(int id, [FromBody] AuthorityEditDsM data){
  69 + await _authorityDs.UpdateAsync(data,id);
  70 + return Json(String.Empty);
  71 + }
  72 +
  73 +
  74 + [HttpDelete]
  75 + public async Task<IActionResult> Delete(int id)
  76 + {
  77 + try
  78 + {
  79 + int authority = await _authorityDs.DeleteAsync(id);
  80 + return Json(authority);
  81 + }
  82 + catch (ArgumentNullException )
  83 + {
  84 + return NotFound();
  85 + }
  86 + }
  87 + }
  88 +}
... ...
src/Maps/Controllers/ContractorController.cs 0 → 100755
  1 +using System.Linq;
  2 +using System.Threading.Tasks;
  3 +using Microsoft.AspNetCore.Mvc;
  4 +using Microsoft.AspNetCore.Mvc.Rendering;
  5 +using Microsoft.EntityFrameworkCore;
  6 +using MapsDb;
  7 +using MapsDb.Interfaces;
  8 +using MapsDb.DataService;
  9 +using MapsModels.ViewModels;
  10 +using MapsModels.DsModels;
  11 +using System;
  12 +
  13 +namespace Maps.Controllers
  14 +{
  15 + public class ContractorController : Controller
  16 + {
  17 + private readonly IContractorDs _contractorDs;
  18 + private readonly IRoadDs _roadDs;
  19 + private readonly ICrossSectionDs _crossSectionDs;
  20 +
  21 + public ContractorController(IContractorDs ContractorDs, IRoadDs RoadDs, ICrossSectionDs CrossSectionDs, IRegionDs RegionDs)
  22 + {
  23 + _contractorDs = ContractorDs;
  24 + _roadDs = RoadDs;
  25 + _crossSectionDs = CrossSectionDs;
  26 + }
  27 +
  28 + // GET: Contractor
  29 + [HttpGet]
  30 + public async Task<IActionResult> Index([FromQuery] PaginationDsM data)
  31 + {
  32 +
  33 + var contractors = await _contractorDs.GetIndexListAsync(data);
  34 +
  35 + ContractorListVm vm = new ContractorListVm
  36 + {
  37 + ContractorEditDsM = contractors.ToList()
  38 + };
  39 +
  40 + return Json(vm);
  41 +
  42 +
  43 +
  44 + }
  45 +
  46 + [HttpGet]
  47 + public async Task<IActionResult> Directory(){
  48 + var Road = await _roadDs.GetSelectListAsync();
  49 + var CrossSection = await _crossSectionDs.GetSelectListAsync();
  50 +
  51 + CatalogListVm vm = new CatalogListVm
  52 + {
  53 + RoadSelectListDsM = Road.ToList(),
  54 + CrossSectionSelectListDsM = CrossSection.ToList(),
  55 + };
  56 + return Json(vm);
  57 + }
  58 +
  59 +
  60 + [HttpPost]
  61 + public async Task<IActionResult> Create([FromBody] ContractorEditDsM data)
  62 + {
  63 + var result = await _contractorDs.CreateAsync(data);
  64 + return Json(result);
  65 + }
  66 +
  67 + [HttpPost]
  68 + public async Task<IActionResult> Update(int id, [FromBody] ContractorEditDsM data){
  69 + await _contractorDs.UpdateAsync(data,id);
  70 + return Json(String.Empty);
  71 + }
  72 +
  73 +
  74 + [HttpDelete]
  75 + public async Task<IActionResult> Delete(int id)
  76 + {
  77 + try
  78 + {
  79 + int contractor = await _contractorDs.DeleteAsync(id);
  80 + return Json(contractor);
  81 + }
  82 + catch (ArgumentNullException )
  83 + {
  84 + return NotFound();
  85 + }
  86 + }
  87 + }
  88 +}
... ...
src/Maps/Controllers/RoadController.cs
... ... @@ -94,5 +94,27 @@ namespace Maps.Controllers
94 94 List<WayLook> result = _roadDs.GetRelationAsync(Id);
95 95 return Json(result);
96 96 }
  97 +
  98 + [HttpGet]
  99 + public async Task<IActionResult> RoadByWay(int Id)
  100 + {
  101 + RoadVm result = _roadDs.GetByWay(Id);
  102 + if (result == null) {
  103 + return NotFound();
  104 + } else {
  105 + return Json(result);
  106 + }
  107 + }
  108 +
  109 + [HttpGet]
  110 + public async Task<IActionResult> RoadByNode(int Id)
  111 + {
  112 + RoadVm result = _roadDs.GetByNode(Id);
  113 + if (result == null) {
  114 + return NotFound();
  115 + } else {
  116 + return Json(result);
  117 + }
  118 + }
97 119 }
98 120 }
... ...
src/Maps/Startup.cs
... ... @@ -57,6 +57,10 @@ namespace Maps
57 57 cnf.CreateMap<SettlementAddressLinkEditDsM, SettlementAddressLink>();
58 58 cnf.CreateMap<RoadToCategory, RoadToCategoryEditDsM>();
59 59 cnf.CreateMap<RoadToCategoryEditDsM, RoadToCategory>();
  60 + cnf.CreateMap<AuthorityEditDsM, Authority>();
  61 + cnf.CreateMap<Authority, AuthorityEditDsM>();
  62 + cnf.CreateMap<ContractorEditDsM, Contractor>();
  63 + cnf.CreateMap<Contractor, ContractorEditDsM>();
60 64 });
61 65  
62 66 services.AddScoped<IBusStopDs, BusStopDs>();
... ... @@ -81,6 +85,8 @@ namespace Maps
81 85 services.AddScoped<ISettlementAddressLinkDs, SettlementAddressLinkDs>();
82 86 services.AddScoped<IRoadToCategoryDs, RoadToCategoryDs>();
83 87 services.AddScoped<IRoadCategoryDs, RoadCategoryDs>();
  88 + services.AddScoped<IAuthorityDs, AuthorityDs>();
  89 + services.AddScoped<IContractorDs, ContractorDs>();
84 90 // Add framework services.
85 91 services.AddApplicationInsightsTelemetry(Configuration);
86 92  
... ...
src/MapsDb/DataService/AuthorityDs.cs 0 → 100644
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Reflection;
  5 +using System.Text.RegularExpressions;
  6 +using System.Threading.Tasks;
  7 +using AutoMapper;
  8 +using MapsDb.Interfaces;
  9 +using MapsDb.Models;
  10 +using MapsModels.DsModels;
  11 +using Microsoft.EntityFrameworkCore;
  12 +
  13 +namespace MapsDb.DataService
  14 +{
  15 + public class AuthorityDs : IAuthorityDs
  16 + {
  17 + private PostgresDbContext _context;
  18 + public AuthorityDs(){
  19 + _context = new PostgresDbContext();
  20 + }
  21 + public Task<IList<AuthorityEditDsM>> GetIndexListAsync(PaginationDsM pagination){
  22 + return Task.Factory.StartNew(()=> { return GetAllAuthority(pagination); });
  23 + }
  24 + private IList<AuthorityEditDsM> GetAllAuthority(PaginationDsM pagination)
  25 + {
  26 +
  27 + var filter = pagination.filter;
  28 +
  29 + IQueryable<Authority> data = _context.Authority
  30 + .Include(d=>d.Road)
  31 + .Include(d=>d.CrossSection);
  32 +
  33 + IQueryable<AuthorityEditDsM> result = data
  34 + .Select(Authority => Mapper.Map<AuthorityEditDsM>(Authority))
  35 + .Skip(pagination.from)
  36 + .Take(pagination.perPage);
  37 +
  38 + switch (pagination.orderType())
  39 + {
  40 + case "ASC":
  41 + return result.OrderBy(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList();
  42 +
  43 + case "DESC":
  44 + return result.OrderByDescending(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList();
  45 +
  46 + default:
  47 + return result.OrderByDescending(i => i.Id).ToList();
  48 + }
  49 +
  50 + }
  51 +
  52 + public Task<Authority> CreateAsync(AuthorityEditDsM data){
  53 + return Task.Factory.StartNew(()=> { return Create(data); });
  54 + }
  55 + private Authority Create(AuthorityEditDsM data)
  56 + {
  57 +
  58 + Authority Model = InsertModel(data);
  59 + _context.Authority.Add(Model);
  60 + _context.SaveChanges();
  61 + return Model;
  62 + }
  63 + public Task<Authority> UpdateAsync(AuthorityEditDsM data, int id){
  64 + return Task.Factory.StartNew(()=> { return Update(data, id); });
  65 + }
  66 + private Authority Update(AuthorityEditDsM data, int id)
  67 + {
  68 + Authority Model = InsertModel(data);
  69 + Model.Id = id;
  70 + _context.Authority.Update(Model);
  71 + _context.SaveChanges();
  72 + return Model;
  73 + }
  74 + public Authority InsertModel(AuthorityEditDsM data){
  75 + Authority Model = Mapper.Map<Authority>(data);
  76 + return Model;
  77 + }
  78 + public async Task<int> DeleteAsync(int Id)
  79 + {
  80 + var authority = await _context.Authority.SingleOrDefaultAsync(x => x.Id == Id);
  81 + _context.Authority.Remove(authority);
  82 + return await _context.SaveChangesAsync();
  83 + }
  84 + }
  85 +}
0 86 \ No newline at end of file
... ...
src/MapsDb/DataService/ContractorDs.cs 0 → 100644
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Reflection;
  5 +using System.Text.RegularExpressions;
  6 +using System.Threading.Tasks;
  7 +using AutoMapper;
  8 +using MapsDb.Interfaces;
  9 +using MapsDb.Models;
  10 +using MapsModels.DsModels;
  11 +using Microsoft.EntityFrameworkCore;
  12 +
  13 +namespace MapsDb.DataService
  14 +{
  15 + public class ContractorDs : IContractorDs
  16 + {
  17 + private PostgresDbContext _context;
  18 + public ContractorDs(){
  19 + _context = new PostgresDbContext();
  20 + }
  21 + public Task<IList<ContractorEditDsM>> GetIndexListAsync(PaginationDsM pagination){
  22 + return Task.Factory.StartNew(()=> { return GetAllContractor(pagination); });
  23 + }
  24 + private IList<ContractorEditDsM> GetAllContractor(PaginationDsM pagination)
  25 + {
  26 +
  27 + var filter = pagination.filter;
  28 +
  29 + IQueryable<Contractor> data = _context.Contractor
  30 + .Include(d=>d.Road)
  31 + .Include(d=>d.CrossSection);
  32 +
  33 + IQueryable<ContractorEditDsM> result = data
  34 + .Select(Contractor => Mapper.Map<ContractorEditDsM>(Contractor))
  35 + .Skip(pagination.from)
  36 + .Take(pagination.perPage);
  37 +
  38 + switch (pagination.orderType())
  39 + {
  40 + case "ASC":
  41 + return result.OrderBy(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList();
  42 +
  43 + case "DESC":
  44 + return result.OrderByDescending(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList();
  45 +
  46 + default:
  47 + return result.OrderByDescending(i => i.Id).ToList();
  48 + }
  49 +
  50 + }
  51 +
  52 + public Task<Contractor> CreateAsync(ContractorEditDsM data){
  53 + return Task.Factory.StartNew(()=> { return Create(data); });
  54 + }
  55 + private Contractor Create(ContractorEditDsM data)
  56 + {
  57 +
  58 + Contractor Model = InsertModel(data);
  59 + _context.Contractor.Add(Model);
  60 + _context.SaveChanges();
  61 + return Model;
  62 + }
  63 + public Task<Contractor> UpdateAsync(ContractorEditDsM data, int id){
  64 + return Task.Factory.StartNew(()=> { return Update(data, id); });
  65 + }
  66 + private Contractor Update(ContractorEditDsM data, int id)
  67 + {
  68 + Contractor Model = InsertModel(data);
  69 + Model.Id = id;
  70 + _context.Contractor.Update(Model);
  71 + _context.SaveChanges();
  72 + return Model;
  73 + }
  74 + public Contractor InsertModel(ContractorEditDsM data){
  75 + Contractor Model = Mapper.Map<Contractor>(data);
  76 + return Model;
  77 + }
  78 + public async Task<int> DeleteAsync(int Id)
  79 + {
  80 + var contractor = await _context.Contractor.SingleOrDefaultAsync(x => x.Id == Id);
  81 + _context.Contractor.Remove(contractor);
  82 + return await _context.SaveChangesAsync();
  83 + }
  84 + }
  85 +}
0 86 \ No newline at end of file
... ...
src/MapsDb/DataService/CrossSectionDs.cs
... ... @@ -14,6 +14,17 @@ namespace MapsDb.DataService
14 14 public CrossSectionDs(){
15 15 _context = new PostgresDbContext();
16 16 }
  17 + public Task<IList<CrossSectionSelectListDsM>> GetSelectListAsync(){
  18 + return Task.Factory.StartNew(GetSelectList);
  19 + }
  20 + private IList<CrossSectionSelectListDsM> GetSelectList()
  21 + {
  22 + return _context.CrossSection.Select(x => new CrossSectionSelectListDsM
  23 + {
  24 + Id = x.Id,
  25 + Name = x.Id.ToString()
  26 + }).ToList();
  27 + }
17 28 public Task<IList<CrossSectionEditDsM>> GetIndexListAsync(PaginationDsM pagination){
18 29 return Task.Factory.StartNew(()=> { return GetAllCrossSection(pagination); });
19 30 }
... ...
src/MapsDb/DataService/RoadDs.cs
... ... @@ -144,5 +144,42 @@ namespace MapsDb.DataService
144 144 }
145 145 return result;
146 146 }
  147 +
  148 + public RoadVm GetByWay(int Id)
  149 + {
  150 + RoadVm road = _context.Road.Where(x => x.RelationToRoad.Any(y => y.Relation.WayToRelation.Any(z => z.WayId == Id))).Include(t => t.RoadType).Select(r => new RoadVm{
  151 + Id = r.Id,
  152 + Name = r.Name,
  153 + Value = r.Value,
  154 + Length = r.Length,
  155 + HistoricalBackground = r.HistoricalBackground,
  156 + EconomicValue = r.EconomicValue,
  157 + LawDoc = r.LawDoc,
  158 + AcceptTransferDoc = r.AcceptTransferDoc,
  159 + AcceptanceDoc = r.AcceptanceDoc,
  160 + AuthorityAct = r.AuthorityAct,
  161 + RoadType = r.RoadType.Value,
  162 + Index = r.Index
  163 + }).FirstOrDefault();
  164 + return road;
  165 + }
  166 + public RoadVm GetByNode(int Id)
  167 + {
  168 + RoadVm road = _context.Road.Where(x => x.RelationToRoad.Any(y => y.Relation.WayToRelation.Any(z => z.Way.NodeToWay.Any(a => a.NodeId == Id)))).Include(t => t.RoadType).Select(r => new RoadVm{
  169 + Id = r.Id,
  170 + Name = r.Name,
  171 + Value = r.Value,
  172 + Length = r.Length,
  173 + HistoricalBackground = r.HistoricalBackground,
  174 + EconomicValue = r.EconomicValue,
  175 + LawDoc = r.LawDoc,
  176 + AcceptTransferDoc = r.AcceptTransferDoc,
  177 + AcceptanceDoc = r.AcceptanceDoc,
  178 + AuthorityAct = r.AuthorityAct,
  179 + RoadType = r.RoadType.Value,
  180 + Index = r.Index
  181 + }).FirstOrDefault();
  182 + return road;
  183 + }
147 184 }
148 185 }
149 186 \ No newline at end of file
... ...
src/MapsDb/Interfaces/IAuthorityDs.cs 0 → 100644
  1 +using System.Collections.Generic;
  2 +using System.Threading.Tasks;
  3 +using MapsModels.DsModels;
  4 +using MapsDb.Models;
  5 +namespace MapsDb.Interfaces
  6 +{
  7 + public interface IAuthorityDs
  8 + {
  9 + Task<IList<AuthorityEditDsM>> GetIndexListAsync(PaginationDsM pagination);
  10 + Task<Authority> CreateAsync(AuthorityEditDsM authority);
  11 + Task<Authority> UpdateAsync(AuthorityEditDsM authority, int id);
  12 + Task<int> DeleteAsync(int Id);
  13 + }
  14 +}
0 15 \ No newline at end of file
... ...
src/MapsDb/Interfaces/IContractorDs.cs 0 → 100644
  1 +using System.Collections.Generic;
  2 +using System.Threading.Tasks;
  3 +using MapsModels.DsModels;
  4 +using MapsDb.Models;
  5 +namespace MapsDb.Interfaces
  6 +{
  7 + public interface IContractorDs
  8 + {
  9 + Task<IList<ContractorEditDsM>> GetIndexListAsync(PaginationDsM pagination);
  10 + Task<Contractor> CreateAsync(ContractorEditDsM contractor);
  11 + Task<Contractor> UpdateAsync(ContractorEditDsM contractor, int id);
  12 + Task<int> DeleteAsync(int Id);
  13 + }
  14 +}
0 15 \ No newline at end of file
... ...
src/MapsDb/Interfaces/ICrossSectionDs.cs
... ... @@ -6,6 +6,7 @@ namespace MapsDb.Interfaces
6 6 {
7 7 public interface ICrossSectionDs
8 8 {
  9 + Task<IList<CrossSectionSelectListDsM>> GetSelectListAsync();
9 10 Task<IList<CrossSectionEditDsM>> GetIndexListAsync(PaginationDsM pagination);
10 11 Task<CrossSection> CreateAsync(CrossSectionEditDsM CrossSection);
11 12 Task<CrossSection> UpdateAsync(CrossSectionEditDsM CrossSection, int id);
... ...
src/MapsDb/Interfaces/IRoadDs.cs
... ... @@ -15,5 +15,7 @@ namespace MapsDb.Interfaces
15 15 Task<Road> UpdateAsync(RoadEditDsM road, int id);
16 16 Task<int> DeleteAsync(int Id);
17 17 List<WayLook> GetRelationAsync(int Id);
  18 + RoadVm GetByWay(int Id);
  19 + RoadVm GetByNode(int Id);
18 20 }
19 21 }
20 22 \ No newline at end of file
... ...
src/MapsDb/Models/Authority.cs 0 → 100644
  1 +using System;
  2 +using System.Collections.Generic;
  3 +
  4 +namespace MapsDb.Models
  5 +{
  6 + public partial class Authority
  7 + {
  8 + public int Id { get; set; }
  9 + public int RoadId { get; set; }
  10 + public int? CrossSectionId { get; set; }
  11 + public string AuthorityName { get; set; }
  12 + public string Info { get; set; }
  13 + public int? RoadSectionNumber { get; set; }
  14 + public decimal Begin { get; set; }
  15 + public decimal End { get; set; }
  16 + public decimal Length { get; set; }
  17 + public string RightCoords { get; set; }
  18 + public string BeginScheme { get; set; }
  19 + public string EndScheme { get; set; }
  20 +
  21 + public virtual CrossSection CrossSection { get; set; }
  22 + public virtual Road Road { get; set; }
  23 + }
  24 +}
0 25 \ No newline at end of file
... ...
src/MapsDb/Models/Contractor.cs 0 → 100644
  1 +using System;
  2 +using System.Collections.Generic;
  3 +
  4 +namespace MapsDb.Models
  5 +{
  6 + public partial class Contractor
  7 + {
  8 + public int Id { get; set; }
  9 + public int RoadId { get; set; }
  10 + public int? CrossSectionId { get; set; }
  11 + public string ContractorName { get; set; }
  12 + public string Info { get; set; }
  13 + public int? RoadSectionNumber { get; set; }
  14 + public int? ContractorSectionNumber { get; set; }
  15 + public decimal? Begin { get; set; }
  16 + public decimal? End { get; set; }
  17 + public decimal Length { get; set; }
  18 + public string RightCoords { get; set; }
  19 + public string BeginScheme { get; set; }
  20 + public string EndScheme { get; set; }
  21 +
  22 + public virtual CrossSection CrossSection { get; set; }
  23 + public virtual Road Road { get; set; }
  24 + }
  25 +}
0 26 \ No newline at end of file
... ...
src/MapsDb/Models/CrossSection.cs
1 1 using System;
2 2 using System.Collections.Generic;
3 3  
4   -namespace MapsDb.Models
  4 +namespace MapsDb.Models
5 5 {
6 6 public partial class CrossSection
7 7 {
  8 + public CrossSection()
  9 + {
  10 + Authority = new HashSet<Authority>();
  11 + Contractor = new HashSet<Contractor>();
  12 + }
  13 +
8 14 public int Id { get; set; }
9 15 public int? RegionId { get; set; }
10 16 public int? RoadId { get; set; }
... ... @@ -23,6 +29,8 @@ namespace MapsDb.Models
23 29 public int? YearRepair { get; set; }
24 30 public int? StateCommonId { get; set; }
25 31  
  32 + public virtual ICollection<Authority> Authority { get; set; }
  33 + public virtual ICollection<Contractor> Contractor { get; set; }
26 34 public virtual Region Region { get; set; }
27 35 public virtual Road Road { get; set; }
28 36 public virtual StateCommon StateCommon { get; set; }
... ...
src/MapsDb/Models/Road.cs
... ... @@ -7,7 +7,9 @@ namespace MapsDb.Models
7 7 {
8 8 public Road()
9 9 {
  10 + Authority = new HashSet<Authority>();
10 11 BusStop = new HashSet<BusStop>();
  12 + Contractor = new HashSet<Contractor>();
11 13 CrossSection = new HashSet<CrossSection>();
12 14 FlowIntensity = new HashSet<FlowIntensity>();
13 15 RelationToRoad = new HashSet<RelationToRoad>();
... ... @@ -33,7 +35,9 @@ namespace MapsDb.Models
33 35 public int? RoadTypeId { get; set; }
34 36 public int Index { get; set; }
35 37  
  38 + public virtual ICollection<Authority> Authority { get; set; }
36 39 public virtual ICollection<BusStop> BusStop { get; set; }
  40 + public virtual ICollection<Contractor> Contractor { get; set; }
37 41 public virtual ICollection<CrossSection> CrossSection { get; set; }
38 42 public virtual ICollection<FlowIntensity> FlowIntensity { get; set; }
39 43 public virtual ICollection<RelationToRoad> RelationToRoad { get; set; }
... ...
src/MapsDb/PostgresDbContext.cs
1 1 using System;
  2 +using MapsDb.Models;
2 3 using Microsoft.EntityFrameworkCore;
3 4 using Microsoft.EntityFrameworkCore.Metadata;
4   -using MapsDb.Models;
  5 +
5 6 namespace MapsDb
6 7 {
7 8 public partial class PostgresDbContext : DbContext
8 9 {
  10 + public virtual DbSet<Authority> Authority { get; set; }
9 11 public virtual DbSet<BusStop> BusStop { get; set; }
  12 + public virtual DbSet<Contractor> Contractor { get; set; }
10 13 public virtual DbSet<CrossSection> CrossSection { get; set; }
11 14 public virtual DbSet<DepartmentAffiliation> DepartmentAffiliation { get; set; }
12 15 public virtual DbSet<FlowIntensity> FlowIntensity { get; set; }
... ... @@ -44,6 +47,60 @@ namespace MapsDb
44 47  
45 48 protected override void OnModelCreating(ModelBuilder modelBuilder)
46 49 {
  50 + modelBuilder.Entity<Authority>(entity =>
  51 + {
  52 + entity.ToTable("authority");
  53 +
  54 + entity.Property(e => e.Id).HasColumnName("id");
  55 +
  56 + entity.Property(e => e.AuthorityName)
  57 + .HasColumnName("authority_name")
  58 + .HasColumnType("varchar")
  59 + .HasMaxLength(255);
  60 +
  61 + entity.Property(e => e.Begin).HasColumnName("begin");
  62 +
  63 + entity.Property(e => e.BeginScheme)
  64 + .HasColumnName("begin_scheme")
  65 + .HasColumnType("varchar")
  66 + .HasMaxLength(255);
  67 +
  68 + entity.Property(e => e.CrossSectionId).HasColumnName("cross_section_id");
  69 +
  70 + entity.Property(e => e.End).HasColumnName("end");
  71 +
  72 + entity.Property(e => e.EndScheme)
  73 + .HasColumnName("end_scheme")
  74 + .HasColumnType("varchar")
  75 + .HasMaxLength(255);
  76 +
  77 + entity.Property(e => e.Info).HasColumnName("info");
  78 +
  79 + entity.Property(e => e.Length)
  80 + .HasColumnName("length")
  81 + .HasDefaultValueSql("0");
  82 +
  83 + entity.Property(e => e.RightCoords)
  84 + .HasColumnName("right_coords")
  85 + .HasColumnType("varchar")
  86 + .HasMaxLength(255);
  87 +
  88 + entity.Property(e => e.RoadId).HasColumnName("road_id");
  89 +
  90 + entity.Property(e => e.RoadSectionNumber).HasColumnName("road_section_number");
  91 +
  92 + entity.HasOne(d => d.CrossSection)
  93 + .WithMany(p => p.Authority)
  94 + .HasForeignKey(d => d.CrossSectionId)
  95 + .HasConstraintName("authority_cross_section_id_fk");
  96 +
  97 + entity.HasOne(d => d.Road)
  98 + .WithMany(p => p.Authority)
  99 + .HasForeignKey(d => d.RoadId)
  100 + .OnDelete(DeleteBehavior.Restrict)
  101 + .HasConstraintName("authority_road_id_fk");
  102 + });
  103 +
47 104 modelBuilder.Entity<BusStop>(entity =>
48 105 {
49 106 entity.ToTable("bus_stop");
... ... @@ -127,6 +184,62 @@ namespace MapsDb
127 184 .HasConstraintName("bus_stop_surface_type_id_fkey");
128 185 });
129 186  
  187 + modelBuilder.Entity<Contractor>(entity =>
  188 + {
  189 + entity.ToTable("contractor");
  190 +
  191 + entity.Property(e => e.Id).HasColumnName("id");
  192 +
  193 + entity.Property(e => e.Begin).HasColumnName("begin");
  194 +
  195 + entity.Property(e => e.BeginScheme)
  196 + .HasColumnName("begin_scheme")
  197 + .HasColumnType("varchar")
  198 + .HasMaxLength(255);
  199 +
  200 + entity.Property(e => e.ContractorName)
  201 + .HasColumnName("contractor_name")
  202 + .HasColumnType("varchar")
  203 + .HasMaxLength(255);
  204 +
  205 + entity.Property(e => e.ContractorSectionNumber).HasColumnName("contractor_section_number");
  206 +
  207 + entity.Property(e => e.CrossSectionId).HasColumnName("cross_section_id");
  208 +
  209 + entity.Property(e => e.End).HasColumnName("end");
  210 +
  211 + entity.Property(e => e.EndScheme)
  212 + .HasColumnName("end_scheme")
  213 + .HasColumnType("varchar")
  214 + .HasMaxLength(255);
  215 +
  216 + entity.Property(e => e.Info).HasColumnName("info");
  217 +
  218 + entity.Property(e => e.Length)
  219 + .HasColumnName("length")
  220 + .HasDefaultValueSql("0");
  221 +
  222 + entity.Property(e => e.RightCoords)
  223 + .HasColumnName("right_coords")
  224 + .HasColumnType("varchar")
  225 + .HasMaxLength(255);
  226 +
  227 + entity.Property(e => e.RoadId).HasColumnName("road_id");
  228 +
  229 + entity.Property(e => e.RoadSectionNumber).HasColumnName("road_section_number");
  230 +
  231 + entity.HasOne(d => d.CrossSection)
  232 + .WithMany(p => p.Contractor)
  233 + .HasForeignKey(d => d.CrossSectionId)
  234 + .HasConstraintName("contractor_cross_section_id_fk");
  235 +
  236 + entity.HasOne(d => d.Road)
  237 + .WithMany(p => p.Contractor)
  238 + .HasForeignKey(d => d.RoadId)
  239 + .OnDelete(DeleteBehavior.Restrict)
  240 + .HasConstraintName("contractor_road_id_fk");
  241 + });
  242 +
130 243 modelBuilder.Entity<CrossSection>(entity =>
131 244 {
132 245 entity.ToTable("cross_section");
... ...
src/MapsModels/DsModels/AuthorityEditDsM.cs 0 → 100644
  1 +namespace MapsModels.DsModels
  2 +{
  3 + public class AuthorityEditDsM
  4 + {
  5 + public int? Id { get; set; }
  6 + public int RoadId { get; set; }
  7 + public int? CrossSectionId { get; set; }
  8 + public string AuthorityName { get; set; }
  9 + public string Info { get; set; }
  10 + public int? RoadSectionNumber { get; set; }
  11 + public decimal Begin { get; set; }
  12 + public decimal End { get; set; }
  13 + public decimal Length { get; set; }
  14 + public string RightCoords { get; set; }
  15 + public string BeginScheme { get; set; }
  16 + public string EndScheme { get; set; }
  17 +
  18 + }
  19 +}
0 20 \ No newline at end of file
... ...
src/MapsModels/DsModels/ContractorEditDsM.cs 0 → 100644
  1 +namespace MapsModels.DsModels
  2 +{
  3 + public class ContractorEditDsM
  4 + {
  5 + public int? Id { get; set; }
  6 + public int RoadId { get; set; }
  7 + public int? CrossSectionId { get; set; }
  8 + public string ContractorName { get; set; }
  9 + public string Info { get; set; }
  10 + public int? RoadSectionNumber { get; set; }
  11 + public int? ContractorSectionNumber { get; set; }
  12 + public decimal? Begin { get; set; }
  13 + public decimal? End { get; set; }
  14 + public decimal Length { get; set; }
  15 + public string RightCoords { get; set; }
  16 + public string BeginScheme { get; set; }
  17 + public string EndScheme { get; set; }
  18 +
  19 + }
  20 +}
0 21 \ No newline at end of file
... ...
src/MapsModels/DsModels/CrossSectionSelectListDsM.cs 0 → 100644
  1 +namespace MapsModels.DsModels
  2 +{
  3 + public class CrossSectionSelectListDsM
  4 + {
  5 + public int Id { get; set; }
  6 + public string Name { get; set; }
  7 + }
  8 +}
0 9 \ No newline at end of file
... ...
src/MapsModels/ViewModels/AuthorityListVm.cs 0 → 100644
  1 +using System.Collections.Generic;
  2 +using MapsModels.DsModels;
  3 +
  4 +namespace MapsModels.ViewModels
  5 +{
  6 + public class AuthorityListVm
  7 + {
  8 + public List<AuthorityEditDsM> AuthorityEditDsM { get; set; }
  9 + }
  10 +}
... ...
src/MapsModels/ViewModels/CatalogListVm.cs
... ... @@ -18,5 +18,6 @@ namespace MapsModels.ViewModels
18 18 public List<OrganizationSelectListDsM> OrganizationSelectListDsM { get; set; }
19 19 public List<SettlementLocationSelectListDsM> SettlementLocationSelectListDsM { get; set; }
20 20 public List<RoadCategorySelectListDsM> RoadCategorySelectListDsM { get; set; }
  21 + public List<CrossSectionSelectListDsM> CrossSectionSelectListDsM { get; set; }
21 22 }
22 23 }
... ...
src/MapsModels/ViewModels/ContractorListVm.cs 0 → 100644
  1 +using System.Collections.Generic;
  2 +using MapsModels.DsModels;
  3 +
  4 +namespace MapsModels.ViewModels
  5 +{
  6 + public class ContractorListVm
  7 + {
  8 + public List<ContractorEditDsM> ContractorEditDsM { get; set; }
  9 + }
  10 +}
... ...
src/MapsModels/ViewModels/RoadVm.cs 0 → 100644
  1 +namespace MapsModels.ViewModels
  2 +{
  3 + public class RoadVm
  4 + {
  5 + public int Id { get; set; }
  6 + public string Name { get; set; }
  7 + public string Value { get; set; }
  8 + public double? Length { get; set; }
  9 + public string HistoricalBackground { get; set; }
  10 + public string EconomicValue { get; set; }
  11 + public string LawDoc { get; set; }
  12 + public string AcceptTransferDoc { get; set; }
  13 + public string AcceptanceDoc { get; set; }
  14 + public string AuthorityAct { get; set; }
  15 + public string RoadType { get; set; }
  16 + public int Index { get; set; }
  17 +
  18 + }
  19 +}
0 20 \ No newline at end of file
... ...