From c386d9eb04e796da1a5645ebc09e3a082589441d Mon Sep 17 00:00:00 2001 From: yarik Date: Tue, 28 Feb 2017 19:36:17 +0200 Subject: [PATCH] Big commit --- src/MapConsole/OsmImport.cs | 25 ++++++++----------------- src/MapConsole/Program.cs | 5 +++++ src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.dll | Bin 270336 -> 0 bytes src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.pdb | Bin 4480 -> 0 bytes src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.dll | Bin 167424 -> 0 bytes src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.pdb | Bin 33140 -> 0 bytes src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.dll | Bin 33280 -> 0 bytes src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.pdb | Bin 12516 -> 0 bytes src/Maps/Controllers/AuthorityController.cs | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Maps/Controllers/ContractorController.cs | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Maps/Controllers/RoadController.cs | 22 ++++++++++++++++++++++ src/Maps/Startup.cs | 6 ++++++ src/MapsDb/DataService/AuthorityDs.cs | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/MapsDb/DataService/ContractorDs.cs | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/MapsDb/DataService/CrossSectionDs.cs | 11 +++++++++++ src/MapsDb/DataService/RoadDs.cs | 37 +++++++++++++++++++++++++++++++++++++ src/MapsDb/Interfaces/IAuthorityDs.cs | 14 ++++++++++++++ src/MapsDb/Interfaces/IContractorDs.cs | 14 ++++++++++++++ src/MapsDb/Interfaces/ICrossSectionDs.cs | 1 + src/MapsDb/Interfaces/IRoadDs.cs | 2 ++ src/MapsDb/Models/Authority.cs | 24 ++++++++++++++++++++++++ src/MapsDb/Models/Contractor.cs | 25 +++++++++++++++++++++++++ src/MapsDb/Models/CrossSection.cs | 10 +++++++++- src/MapsDb/Models/Road.cs | 4 ++++ src/MapsDb/PostgresDbContext.cs | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/MapsModels/DsModels/AuthorityEditDsM.cs | 19 +++++++++++++++++++ src/MapsModels/DsModels/ContractorEditDsM.cs | 20 ++++++++++++++++++++ src/MapsModels/DsModels/CrossSectionSelectListDsM.cs | 8 ++++++++ src/MapsModels/ViewModels/AuthorityListVm.cs | 10 ++++++++++ src/MapsModels/ViewModels/CatalogListVm.cs | 1 + src/MapsModels/ViewModels/ContractorListVm.cs | 10 ++++++++++ src/MapsModels/ViewModels/RoadVm.cs | 19 +++++++++++++++++++ 32 files changed, 729 insertions(+), 19 deletions(-) create mode 100755 src/Maps/Controllers/AuthorityController.cs create mode 100755 src/Maps/Controllers/ContractorController.cs create mode 100644 src/MapsDb/DataService/AuthorityDs.cs create mode 100644 src/MapsDb/DataService/ContractorDs.cs create mode 100644 src/MapsDb/Interfaces/IAuthorityDs.cs create mode 100644 src/MapsDb/Interfaces/IContractorDs.cs create mode 100644 src/MapsDb/Models/Authority.cs create mode 100644 src/MapsDb/Models/Contractor.cs create mode 100644 src/MapsModels/DsModels/AuthorityEditDsM.cs create mode 100644 src/MapsModels/DsModels/ContractorEditDsM.cs create mode 100644 src/MapsModels/DsModels/CrossSectionSelectListDsM.cs create mode 100644 src/MapsModels/ViewModels/AuthorityListVm.cs create mode 100644 src/MapsModels/ViewModels/ContractorListVm.cs create mode 100644 src/MapsModels/ViewModels/RoadVm.cs diff --git a/src/MapConsole/OsmImport.cs b/src/MapConsole/OsmImport.cs index 9a30f6c..e0c5363 100644 --- a/src/MapConsole/OsmImport.cs +++ b/src/MapConsole/OsmImport.cs @@ -153,6 +153,14 @@ namespace MapConsole Console.WriteLine(doc.ToString()); } + public async Task Relation(int Id) + { + await Task.Run(async () => { + Curl curl = new Curl(); + string result = await curl.GetRelation(Id); + this.SaveRelation(result); + }); + } public async Task Relation() { await Task.Run(async () => { @@ -184,23 +192,6 @@ namespace MapConsole XElement relationEl = doc.Root.Element("relation"); string relationRemoteId = relationEl.Attribute("id").Value; string[] inserted = { - // "443032", - // "395707", - // "2143285", - // "2143788", - // "2162219", - // "2683872", - // "1613996", - // "1147187", - // "1147852", - // "23751", - // "2143724", - // "451785", - // "2141546", - // "2143335", - // "1151237", - // "975415", - // "1602684" }; if (inserted.Contains(relationRemoteId)) { Console.WriteLine("Skipped relation " + relationRemoteId); diff --git a/src/MapConsole/Program.cs b/src/MapConsole/Program.cs index 345527f..95cbe0b 100755 --- a/src/MapConsole/Program.cs +++ b/src/MapConsole/Program.cs @@ -30,6 +30,11 @@ namespace MapConsole case "relation": osm.Relation().Wait(); break; + case "relationId": + Console.WriteLine("Введите ID"); + string line = Console.ReadLine(); + osm.Relation(Int32.Parse(line)).Wait(); + break; } } } diff --git a/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.dll b/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.dll index d50af01..0af714f 100755 Binary files a/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.dll and b/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.dll differ diff --git a/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.pdb b/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.pdb index 57bc912..1bf47d2 100755 Binary files a/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.pdb and b/src/MapConsole/bin/Debug/netcoreapp1.0/MapConsole.pdb differ diff --git a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.dll b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.dll index f33926d..1814ad5 100755 Binary files a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.dll and b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.dll differ diff --git a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.pdb b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.pdb index c60b1ef..5504d30 100755 Binary files a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.pdb and b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsDb.pdb differ diff --git a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.dll b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.dll index 51bdc43..8cb044b 100755 Binary files a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.dll and b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.dll differ diff --git a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.pdb b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.pdb index 1785cbe..88f7b0f 100755 Binary files a/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.pdb and b/src/MapConsole/bin/Debug/netcoreapp1.0/MapsModels.pdb differ diff --git a/src/Maps/Controllers/AuthorityController.cs b/src/Maps/Controllers/AuthorityController.cs new file mode 100755 index 0000000..c211238 --- /dev/null +++ b/src/Maps/Controllers/AuthorityController.cs @@ -0,0 +1,88 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.EntityFrameworkCore; +using MapsDb; +using MapsDb.Interfaces; +using MapsDb.DataService; +using MapsModels.ViewModels; +using MapsModels.DsModels; +using System; + +namespace Maps.Controllers +{ + public class AuthorityController : Controller + { + private readonly IAuthorityDs _authorityDs; + private readonly IRoadDs _roadDs; + private readonly ICrossSectionDs _crossSectionDs; + + public AuthorityController(IAuthorityDs AuthorityDs, IRoadDs RoadDs, ICrossSectionDs CrossSectionDs, IRegionDs RegionDs) + { + _authorityDs = AuthorityDs; + _roadDs = RoadDs; + _crossSectionDs = CrossSectionDs; + } + + // GET: Authority + [HttpGet] + public async Task Index([FromQuery] PaginationDsM data) + { + + var authoritys = await _authorityDs.GetIndexListAsync(data); + + AuthorityListVm vm = new AuthorityListVm + { + AuthorityEditDsM = authoritys.ToList() + }; + + return Json(vm); + + + + } + + [HttpGet] + public async Task Directory(){ + var Road = await _roadDs.GetSelectListAsync(); + var CrossSection = await _crossSectionDs.GetSelectListAsync(); + + CatalogListVm vm = new CatalogListVm + { + RoadSelectListDsM = Road.ToList(), + CrossSectionSelectListDsM = CrossSection.ToList(), + }; + return Json(vm); + } + + + [HttpPost] + public async Task Create([FromBody] AuthorityEditDsM data) + { + var result = await _authorityDs.CreateAsync(data); + return Json(result); + } + + [HttpPost] + public async Task Update(int id, [FromBody] AuthorityEditDsM data){ + await _authorityDs.UpdateAsync(data,id); + return Json(String.Empty); + } + + + [HttpDelete] + public async Task Delete(int id) + { + try + { + int authority = await _authorityDs.DeleteAsync(id); + return Json(authority); + } + catch (ArgumentNullException ) + { + return NotFound(); + } + } + } +} diff --git a/src/Maps/Controllers/ContractorController.cs b/src/Maps/Controllers/ContractorController.cs new file mode 100755 index 0000000..d998b1c --- /dev/null +++ b/src/Maps/Controllers/ContractorController.cs @@ -0,0 +1,88 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.EntityFrameworkCore; +using MapsDb; +using MapsDb.Interfaces; +using MapsDb.DataService; +using MapsModels.ViewModels; +using MapsModels.DsModels; +using System; + +namespace Maps.Controllers +{ + public class ContractorController : Controller + { + private readonly IContractorDs _contractorDs; + private readonly IRoadDs _roadDs; + private readonly ICrossSectionDs _crossSectionDs; + + public ContractorController(IContractorDs ContractorDs, IRoadDs RoadDs, ICrossSectionDs CrossSectionDs, IRegionDs RegionDs) + { + _contractorDs = ContractorDs; + _roadDs = RoadDs; + _crossSectionDs = CrossSectionDs; + } + + // GET: Contractor + [HttpGet] + public async Task Index([FromQuery] PaginationDsM data) + { + + var contractors = await _contractorDs.GetIndexListAsync(data); + + ContractorListVm vm = new ContractorListVm + { + ContractorEditDsM = contractors.ToList() + }; + + return Json(vm); + + + + } + + [HttpGet] + public async Task Directory(){ + var Road = await _roadDs.GetSelectListAsync(); + var CrossSection = await _crossSectionDs.GetSelectListAsync(); + + CatalogListVm vm = new CatalogListVm + { + RoadSelectListDsM = Road.ToList(), + CrossSectionSelectListDsM = CrossSection.ToList(), + }; + return Json(vm); + } + + + [HttpPost] + public async Task Create([FromBody] ContractorEditDsM data) + { + var result = await _contractorDs.CreateAsync(data); + return Json(result); + } + + [HttpPost] + public async Task Update(int id, [FromBody] ContractorEditDsM data){ + await _contractorDs.UpdateAsync(data,id); + return Json(String.Empty); + } + + + [HttpDelete] + public async Task Delete(int id) + { + try + { + int contractor = await _contractorDs.DeleteAsync(id); + return Json(contractor); + } + catch (ArgumentNullException ) + { + return NotFound(); + } + } + } +} diff --git a/src/Maps/Controllers/RoadController.cs b/src/Maps/Controllers/RoadController.cs index 2991f85..63864d7 100755 --- a/src/Maps/Controllers/RoadController.cs +++ b/src/Maps/Controllers/RoadController.cs @@ -94,5 +94,27 @@ namespace Maps.Controllers List result = _roadDs.GetRelationAsync(Id); return Json(result); } + + [HttpGet] + public async Task RoadByWay(int Id) + { + RoadVm result = _roadDs.GetByWay(Id); + if (result == null) { + return NotFound(); + } else { + return Json(result); + } + } + + [HttpGet] + public async Task RoadByNode(int Id) + { + RoadVm result = _roadDs.GetByNode(Id); + if (result == null) { + return NotFound(); + } else { + return Json(result); + } + } } } diff --git a/src/Maps/Startup.cs b/src/Maps/Startup.cs index 01016d1..5b49e8a 100644 --- a/src/Maps/Startup.cs +++ b/src/Maps/Startup.cs @@ -57,6 +57,10 @@ namespace Maps cnf.CreateMap(); cnf.CreateMap(); cnf.CreateMap(); + cnf.CreateMap(); + cnf.CreateMap(); + cnf.CreateMap(); + cnf.CreateMap(); }); services.AddScoped(); @@ -81,6 +85,8 @@ namespace Maps services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); + services.AddScoped(); // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); diff --git a/src/MapsDb/DataService/AuthorityDs.cs b/src/MapsDb/DataService/AuthorityDs.cs new file mode 100644 index 0000000..047e163 --- /dev/null +++ b/src/MapsDb/DataService/AuthorityDs.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using AutoMapper; +using MapsDb.Interfaces; +using MapsDb.Models; +using MapsModels.DsModels; +using Microsoft.EntityFrameworkCore; + +namespace MapsDb.DataService +{ + public class AuthorityDs : IAuthorityDs + { + private PostgresDbContext _context; + public AuthorityDs(){ + _context = new PostgresDbContext(); + } + public Task> GetIndexListAsync(PaginationDsM pagination){ + return Task.Factory.StartNew(()=> { return GetAllAuthority(pagination); }); + } + private IList GetAllAuthority(PaginationDsM pagination) + { + + var filter = pagination.filter; + + IQueryable data = _context.Authority + .Include(d=>d.Road) + .Include(d=>d.CrossSection); + + IQueryable result = data + .Select(Authority => Mapper.Map(Authority)) + .Skip(pagination.from) + .Take(pagination.perPage); + + switch (pagination.orderType()) + { + case "ASC": + return result.OrderBy(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList(); + + case "DESC": + return result.OrderByDescending(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList(); + + default: + return result.OrderByDescending(i => i.Id).ToList(); + } + + } + + public Task CreateAsync(AuthorityEditDsM data){ + return Task.Factory.StartNew(()=> { return Create(data); }); + } + private Authority Create(AuthorityEditDsM data) + { + + Authority Model = InsertModel(data); + _context.Authority.Add(Model); + _context.SaveChanges(); + return Model; + } + public Task UpdateAsync(AuthorityEditDsM data, int id){ + return Task.Factory.StartNew(()=> { return Update(data, id); }); + } + private Authority Update(AuthorityEditDsM data, int id) + { + Authority Model = InsertModel(data); + Model.Id = id; + _context.Authority.Update(Model); + _context.SaveChanges(); + return Model; + } + public Authority InsertModel(AuthorityEditDsM data){ + Authority Model = Mapper.Map(data); + return Model; + } + public async Task DeleteAsync(int Id) + { + var authority = await _context.Authority.SingleOrDefaultAsync(x => x.Id == Id); + _context.Authority.Remove(authority); + return await _context.SaveChangesAsync(); + } + } +} \ No newline at end of file diff --git a/src/MapsDb/DataService/ContractorDs.cs b/src/MapsDb/DataService/ContractorDs.cs new file mode 100644 index 0000000..c3368d4 --- /dev/null +++ b/src/MapsDb/DataService/ContractorDs.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using AutoMapper; +using MapsDb.Interfaces; +using MapsDb.Models; +using MapsModels.DsModels; +using Microsoft.EntityFrameworkCore; + +namespace MapsDb.DataService +{ + public class ContractorDs : IContractorDs + { + private PostgresDbContext _context; + public ContractorDs(){ + _context = new PostgresDbContext(); + } + public Task> GetIndexListAsync(PaginationDsM pagination){ + return Task.Factory.StartNew(()=> { return GetAllContractor(pagination); }); + } + private IList GetAllContractor(PaginationDsM pagination) + { + + var filter = pagination.filter; + + IQueryable data = _context.Contractor + .Include(d=>d.Road) + .Include(d=>d.CrossSection); + + IQueryable result = data + .Select(Contractor => Mapper.Map(Contractor)) + .Skip(pagination.from) + .Take(pagination.perPage); + + switch (pagination.orderType()) + { + case "ASC": + return result.OrderBy(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList(); + + case "DESC": + return result.OrderByDescending(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList(); + + default: + return result.OrderByDescending(i => i.Id).ToList(); + } + + } + + public Task CreateAsync(ContractorEditDsM data){ + return Task.Factory.StartNew(()=> { return Create(data); }); + } + private Contractor Create(ContractorEditDsM data) + { + + Contractor Model = InsertModel(data); + _context.Contractor.Add(Model); + _context.SaveChanges(); + return Model; + } + public Task UpdateAsync(ContractorEditDsM data, int id){ + return Task.Factory.StartNew(()=> { return Update(data, id); }); + } + private Contractor Update(ContractorEditDsM data, int id) + { + Contractor Model = InsertModel(data); + Model.Id = id; + _context.Contractor.Update(Model); + _context.SaveChanges(); + return Model; + } + public Contractor InsertModel(ContractorEditDsM data){ + Contractor Model = Mapper.Map(data); + return Model; + } + public async Task DeleteAsync(int Id) + { + var contractor = await _context.Contractor.SingleOrDefaultAsync(x => x.Id == Id); + _context.Contractor.Remove(contractor); + return await _context.SaveChangesAsync(); + } + } +} \ No newline at end of file diff --git a/src/MapsDb/DataService/CrossSectionDs.cs b/src/MapsDb/DataService/CrossSectionDs.cs index 833d253..cfd1d2c 100644 --- a/src/MapsDb/DataService/CrossSectionDs.cs +++ b/src/MapsDb/DataService/CrossSectionDs.cs @@ -14,6 +14,17 @@ namespace MapsDb.DataService public CrossSectionDs(){ _context = new PostgresDbContext(); } + public Task> GetSelectListAsync(){ + return Task.Factory.StartNew(GetSelectList); + } + private IList GetSelectList() + { + return _context.CrossSection.Select(x => new CrossSectionSelectListDsM + { + Id = x.Id, + Name = x.Id.ToString() + }).ToList(); + } public Task> GetIndexListAsync(PaginationDsM pagination){ return Task.Factory.StartNew(()=> { return GetAllCrossSection(pagination); }); } diff --git a/src/MapsDb/DataService/RoadDs.cs b/src/MapsDb/DataService/RoadDs.cs index 155de62..b6b9043 100644 --- a/src/MapsDb/DataService/RoadDs.cs +++ b/src/MapsDb/DataService/RoadDs.cs @@ -144,5 +144,42 @@ namespace MapsDb.DataService } return result; } + + public RoadVm GetByWay(int Id) + { + 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{ + Id = r.Id, + Name = r.Name, + Value = r.Value, + Length = r.Length, + HistoricalBackground = r.HistoricalBackground, + EconomicValue = r.EconomicValue, + LawDoc = r.LawDoc, + AcceptTransferDoc = r.AcceptTransferDoc, + AcceptanceDoc = r.AcceptanceDoc, + AuthorityAct = r.AuthorityAct, + RoadType = r.RoadType.Value, + Index = r.Index + }).FirstOrDefault(); + return road; + } + public RoadVm GetByNode(int Id) + { + 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{ + Id = r.Id, + Name = r.Name, + Value = r.Value, + Length = r.Length, + HistoricalBackground = r.HistoricalBackground, + EconomicValue = r.EconomicValue, + LawDoc = r.LawDoc, + AcceptTransferDoc = r.AcceptTransferDoc, + AcceptanceDoc = r.AcceptanceDoc, + AuthorityAct = r.AuthorityAct, + RoadType = r.RoadType.Value, + Index = r.Index + }).FirstOrDefault(); + return road; + } } } \ No newline at end of file diff --git a/src/MapsDb/Interfaces/IAuthorityDs.cs b/src/MapsDb/Interfaces/IAuthorityDs.cs new file mode 100644 index 0000000..67c08a7 --- /dev/null +++ b/src/MapsDb/Interfaces/IAuthorityDs.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using MapsModels.DsModels; +using MapsDb.Models; +namespace MapsDb.Interfaces +{ + public interface IAuthorityDs + { + Task> GetIndexListAsync(PaginationDsM pagination); + Task CreateAsync(AuthorityEditDsM authority); + Task UpdateAsync(AuthorityEditDsM authority, int id); + Task DeleteAsync(int Id); + } +} \ No newline at end of file diff --git a/src/MapsDb/Interfaces/IContractorDs.cs b/src/MapsDb/Interfaces/IContractorDs.cs new file mode 100644 index 0000000..7bb0b38 --- /dev/null +++ b/src/MapsDb/Interfaces/IContractorDs.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using MapsModels.DsModels; +using MapsDb.Models; +namespace MapsDb.Interfaces +{ + public interface IContractorDs + { + Task> GetIndexListAsync(PaginationDsM pagination); + Task CreateAsync(ContractorEditDsM contractor); + Task UpdateAsync(ContractorEditDsM contractor, int id); + Task DeleteAsync(int Id); + } +} \ No newline at end of file diff --git a/src/MapsDb/Interfaces/ICrossSectionDs.cs b/src/MapsDb/Interfaces/ICrossSectionDs.cs index 7e088e2..c272b7e 100644 --- a/src/MapsDb/Interfaces/ICrossSectionDs.cs +++ b/src/MapsDb/Interfaces/ICrossSectionDs.cs @@ -6,6 +6,7 @@ namespace MapsDb.Interfaces { public interface ICrossSectionDs { + Task> GetSelectListAsync(); Task> GetIndexListAsync(PaginationDsM pagination); Task CreateAsync(CrossSectionEditDsM CrossSection); Task UpdateAsync(CrossSectionEditDsM CrossSection, int id); diff --git a/src/MapsDb/Interfaces/IRoadDs.cs b/src/MapsDb/Interfaces/IRoadDs.cs index eb77b84..9304bdd 100644 --- a/src/MapsDb/Interfaces/IRoadDs.cs +++ b/src/MapsDb/Interfaces/IRoadDs.cs @@ -15,5 +15,7 @@ namespace MapsDb.Interfaces Task UpdateAsync(RoadEditDsM road, int id); Task DeleteAsync(int Id); List GetRelationAsync(int Id); + RoadVm GetByWay(int Id); + RoadVm GetByNode(int Id); } } \ No newline at end of file diff --git a/src/MapsDb/Models/Authority.cs b/src/MapsDb/Models/Authority.cs new file mode 100644 index 0000000..a470887 --- /dev/null +++ b/src/MapsDb/Models/Authority.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +namespace MapsDb.Models +{ + public partial class Authority + { + public int Id { get; set; } + public int RoadId { get; set; } + public int? CrossSectionId { get; set; } + public string AuthorityName { get; set; } + public string Info { get; set; } + public int? RoadSectionNumber { get; set; } + public decimal Begin { get; set; } + public decimal End { get; set; } + public decimal Length { get; set; } + public string RightCoords { get; set; } + public string BeginScheme { get; set; } + public string EndScheme { get; set; } + + public virtual CrossSection CrossSection { get; set; } + public virtual Road Road { get; set; } + } +} \ No newline at end of file diff --git a/src/MapsDb/Models/Contractor.cs b/src/MapsDb/Models/Contractor.cs new file mode 100644 index 0000000..7c70db6 --- /dev/null +++ b/src/MapsDb/Models/Contractor.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace MapsDb.Models +{ + public partial class Contractor + { + public int Id { get; set; } + public int RoadId { get; set; } + public int? CrossSectionId { get; set; } + public string ContractorName { get; set; } + public string Info { get; set; } + public int? RoadSectionNumber { get; set; } + public int? ContractorSectionNumber { get; set; } + public decimal? Begin { get; set; } + public decimal? End { get; set; } + public decimal Length { get; set; } + public string RightCoords { get; set; } + public string BeginScheme { get; set; } + public string EndScheme { get; set; } + + public virtual CrossSection CrossSection { get; set; } + public virtual Road Road { get; set; } + } +} \ No newline at end of file diff --git a/src/MapsDb/Models/CrossSection.cs b/src/MapsDb/Models/CrossSection.cs index 3dd0b00..decd95b 100644 --- a/src/MapsDb/Models/CrossSection.cs +++ b/src/MapsDb/Models/CrossSection.cs @@ -1,10 +1,16 @@ using System; using System.Collections.Generic; -namespace MapsDb.Models +namespace MapsDb.Models { public partial class CrossSection { + public CrossSection() + { + Authority = new HashSet(); + Contractor = new HashSet(); + } + public int Id { get; set; } public int? RegionId { get; set; } public int? RoadId { get; set; } @@ -23,6 +29,8 @@ namespace MapsDb.Models public int? YearRepair { get; set; } public int? StateCommonId { get; set; } + public virtual ICollection Authority { get; set; } + public virtual ICollection Contractor { get; set; } public virtual Region Region { get; set; } public virtual Road Road { get; set; } public virtual StateCommon StateCommon { get; set; } diff --git a/src/MapsDb/Models/Road.cs b/src/MapsDb/Models/Road.cs index fa79307..116631b 100644 --- a/src/MapsDb/Models/Road.cs +++ b/src/MapsDb/Models/Road.cs @@ -7,7 +7,9 @@ namespace MapsDb.Models { public Road() { + Authority = new HashSet(); BusStop = new HashSet(); + Contractor = new HashSet(); CrossSection = new HashSet(); FlowIntensity = new HashSet(); RelationToRoad = new HashSet(); @@ -33,7 +35,9 @@ namespace MapsDb.Models public int? RoadTypeId { get; set; } public int Index { get; set; } + public virtual ICollection Authority { get; set; } public virtual ICollection BusStop { get; set; } + public virtual ICollection Contractor { get; set; } public virtual ICollection CrossSection { get; set; } public virtual ICollection FlowIntensity { get; set; } public virtual ICollection RelationToRoad { get; set; } diff --git a/src/MapsDb/PostgresDbContext.cs b/src/MapsDb/PostgresDbContext.cs index ed76f11..26274ec 100644 --- a/src/MapsDb/PostgresDbContext.cs +++ b/src/MapsDb/PostgresDbContext.cs @@ -1,12 +1,15 @@ using System; +using MapsDb.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; -using MapsDb.Models; + namespace MapsDb { public partial class PostgresDbContext : DbContext { + public virtual DbSet Authority { get; set; } public virtual DbSet BusStop { get; set; } + public virtual DbSet Contractor { get; set; } public virtual DbSet CrossSection { get; set; } public virtual DbSet DepartmentAffiliation { get; set; } public virtual DbSet FlowIntensity { get; set; } @@ -44,6 +47,60 @@ namespace MapsDb protected override void OnModelCreating(ModelBuilder modelBuilder) { + modelBuilder.Entity(entity => + { + entity.ToTable("authority"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.AuthorityName) + .HasColumnName("authority_name") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.Begin).HasColumnName("begin"); + + entity.Property(e => e.BeginScheme) + .HasColumnName("begin_scheme") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.CrossSectionId).HasColumnName("cross_section_id"); + + entity.Property(e => e.End).HasColumnName("end"); + + entity.Property(e => e.EndScheme) + .HasColumnName("end_scheme") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.Info).HasColumnName("info"); + + entity.Property(e => e.Length) + .HasColumnName("length") + .HasDefaultValueSql("0"); + + entity.Property(e => e.RightCoords) + .HasColumnName("right_coords") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.RoadId).HasColumnName("road_id"); + + entity.Property(e => e.RoadSectionNumber).HasColumnName("road_section_number"); + + entity.HasOne(d => d.CrossSection) + .WithMany(p => p.Authority) + .HasForeignKey(d => d.CrossSectionId) + .HasConstraintName("authority_cross_section_id_fk"); + + entity.HasOne(d => d.Road) + .WithMany(p => p.Authority) + .HasForeignKey(d => d.RoadId) + .OnDelete(DeleteBehavior.Restrict) + .HasConstraintName("authority_road_id_fk"); + }); + modelBuilder.Entity(entity => { entity.ToTable("bus_stop"); @@ -127,6 +184,62 @@ namespace MapsDb .HasConstraintName("bus_stop_surface_type_id_fkey"); }); + modelBuilder.Entity(entity => + { + entity.ToTable("contractor"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.Begin).HasColumnName("begin"); + + entity.Property(e => e.BeginScheme) + .HasColumnName("begin_scheme") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.ContractorName) + .HasColumnName("contractor_name") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.ContractorSectionNumber).HasColumnName("contractor_section_number"); + + entity.Property(e => e.CrossSectionId).HasColumnName("cross_section_id"); + + entity.Property(e => e.End).HasColumnName("end"); + + entity.Property(e => e.EndScheme) + .HasColumnName("end_scheme") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.Info).HasColumnName("info"); + + entity.Property(e => e.Length) + .HasColumnName("length") + .HasDefaultValueSql("0"); + + entity.Property(e => e.RightCoords) + .HasColumnName("right_coords") + .HasColumnType("varchar") + .HasMaxLength(255); + + entity.Property(e => e.RoadId).HasColumnName("road_id"); + + entity.Property(e => e.RoadSectionNumber).HasColumnName("road_section_number"); + + entity.HasOne(d => d.CrossSection) + .WithMany(p => p.Contractor) + .HasForeignKey(d => d.CrossSectionId) + .HasConstraintName("contractor_cross_section_id_fk"); + + entity.HasOne(d => d.Road) + .WithMany(p => p.Contractor) + .HasForeignKey(d => d.RoadId) + .OnDelete(DeleteBehavior.Restrict) + .HasConstraintName("contractor_road_id_fk"); + }); + modelBuilder.Entity(entity => { entity.ToTable("cross_section"); diff --git a/src/MapsModels/DsModels/AuthorityEditDsM.cs b/src/MapsModels/DsModels/AuthorityEditDsM.cs new file mode 100644 index 0000000..f4326dc --- /dev/null +++ b/src/MapsModels/DsModels/AuthorityEditDsM.cs @@ -0,0 +1,19 @@ +namespace MapsModels.DsModels +{ + public class AuthorityEditDsM + { + public int? Id { get; set; } + public int RoadId { get; set; } + public int? CrossSectionId { get; set; } + public string AuthorityName { get; set; } + public string Info { get; set; } + public int? RoadSectionNumber { get; set; } + public decimal Begin { get; set; } + public decimal End { get; set; } + public decimal Length { get; set; } + public string RightCoords { get; set; } + public string BeginScheme { get; set; } + public string EndScheme { get; set; } + + } +} \ No newline at end of file diff --git a/src/MapsModels/DsModels/ContractorEditDsM.cs b/src/MapsModels/DsModels/ContractorEditDsM.cs new file mode 100644 index 0000000..b82f374 --- /dev/null +++ b/src/MapsModels/DsModels/ContractorEditDsM.cs @@ -0,0 +1,20 @@ +namespace MapsModels.DsModels +{ + public class ContractorEditDsM + { + public int? Id { get; set; } + public int RoadId { get; set; } + public int? CrossSectionId { get; set; } + public string ContractorName { get; set; } + public string Info { get; set; } + public int? RoadSectionNumber { get; set; } + public int? ContractorSectionNumber { get; set; } + public decimal? Begin { get; set; } + public decimal? End { get; set; } + public decimal Length { get; set; } + public string RightCoords { get; set; } + public string BeginScheme { get; set; } + public string EndScheme { get; set; } + + } +} \ No newline at end of file diff --git a/src/MapsModels/DsModels/CrossSectionSelectListDsM.cs b/src/MapsModels/DsModels/CrossSectionSelectListDsM.cs new file mode 100644 index 0000000..2de3484 --- /dev/null +++ b/src/MapsModels/DsModels/CrossSectionSelectListDsM.cs @@ -0,0 +1,8 @@ +namespace MapsModels.DsModels +{ + public class CrossSectionSelectListDsM + { + public int Id { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/MapsModels/ViewModels/AuthorityListVm.cs b/src/MapsModels/ViewModels/AuthorityListVm.cs new file mode 100644 index 0000000..ee5d358 --- /dev/null +++ b/src/MapsModels/ViewModels/AuthorityListVm.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using MapsModels.DsModels; + +namespace MapsModels.ViewModels +{ + public class AuthorityListVm + { + public List AuthorityEditDsM { get; set; } + } +} diff --git a/src/MapsModels/ViewModels/CatalogListVm.cs b/src/MapsModels/ViewModels/CatalogListVm.cs index b24489f..9724521 100644 --- a/src/MapsModels/ViewModels/CatalogListVm.cs +++ b/src/MapsModels/ViewModels/CatalogListVm.cs @@ -18,5 +18,6 @@ namespace MapsModels.ViewModels public List OrganizationSelectListDsM { get; set; } public List SettlementLocationSelectListDsM { get; set; } public List RoadCategorySelectListDsM { get; set; } + public List CrossSectionSelectListDsM { get; set; } } } diff --git a/src/MapsModels/ViewModels/ContractorListVm.cs b/src/MapsModels/ViewModels/ContractorListVm.cs new file mode 100644 index 0000000..271b0e2 --- /dev/null +++ b/src/MapsModels/ViewModels/ContractorListVm.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using MapsModels.DsModels; + +namespace MapsModels.ViewModels +{ + public class ContractorListVm + { + public List ContractorEditDsM { get; set; } + } +} diff --git a/src/MapsModels/ViewModels/RoadVm.cs b/src/MapsModels/ViewModels/RoadVm.cs new file mode 100644 index 0000000..ba4dc6f --- /dev/null +++ b/src/MapsModels/ViewModels/RoadVm.cs @@ -0,0 +1,19 @@ +namespace MapsModels.ViewModels +{ + public class RoadVm + { + public int Id { get; set; } + public string Name { get; set; } + public string Value { get; set; } + public double? Length { get; set; } + public string HistoricalBackground { get; set; } + public string EconomicValue { get; set; } + public string LawDoc { get; set; } + public string AcceptTransferDoc { get; set; } + public string AcceptanceDoc { get; set; } + public string AuthorityAct { get; set; } + public string RoadType { get; set; } + public int Index { get; set; } + + } +} \ No newline at end of file -- libgit2 0.21.4