Commit 27918c1fe9c1251c80fac6dab2ffec84078fe07d
1 parent
7230fa31
add service object
Showing
20 changed files
with
265 additions
and
326 deletions
Show diff stats
src/Maps/Controllers/BusStopController.cs
| ... | ... | @@ -37,7 +37,7 @@ namespace Maps.Controllers |
| 37 | 37 | { |
| 38 | 38 | var busStops = await _busStopDs.GetIndexListAsync(); |
| 39 | 39 | |
| 40 | - ListBusStopVm vm = new ListBusStopVm | |
| 40 | + BusStopListVm vm = new BusStopListVm | |
| 41 | 41 | { |
| 42 | 42 | BusStopEditDsM = busStops.ToList() |
| 43 | 43 | }; |
| ... | ... | @@ -53,7 +53,7 @@ namespace Maps.Controllers |
| 53 | 53 | var Road = await _roadDs.GetSelectListAsync(); |
| 54 | 54 | var Region = await _regionDs.GetSelectListAsync(); |
| 55 | 55 | |
| 56 | - CreateBusStopVm vm = new CreateBusStopVm | |
| 56 | + CatalogListVm vm = new CatalogListVm | |
| 57 | 57 | { |
| 58 | 58 | SurfaceTypeSelectListDsM = SurfaceType.ToList(), |
| 59 | 59 | StateCommonSelectListDsM = StateCommon.ToList(), |
| ... | ... | @@ -64,72 +64,21 @@ namespace Maps.Controllers |
| 64 | 64 | return Json(vm); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - // GET: BusStop/Details/5 | |
| 68 | - public async Task<IActionResult> Details(int id) | |
| 69 | - { | |
| 70 | - try{ | |
| 71 | - var busStop = await _busStopDs.FindOneDetailsAsync(id); | |
| 72 | - if (busStop == null) | |
| 73 | - { | |
| 74 | - return NotFound(); | |
| 75 | - } | |
| 76 | - DetailsBusStopVm vm = new DetailsBusStopVm | |
| 77 | - { | |
| 78 | - busStopDetailsDsM = busStop | |
| 79 | - }; | |
| 80 | - return Json(vm); | |
| 81 | - } catch { | |
| 82 | - return Json(false); | |
| 83 | - } | |
| 84 | - | |
| 85 | - } | |
| 86 | 67 | |
| 87 | - // GET: BusStop/Create | |
| 88 | 68 | [HttpPost] |
| 89 | - public async Task<IActionResult> Create([FromBody] BusStopEditDsF data) | |
| 69 | + public async Task<IActionResult> Create([FromBody] BusStopEditDsM data) | |
| 90 | 70 | { |
| 91 | 71 | var result = await _busStopDs.SaveAsync(data); |
| 92 | 72 | return Json(result); |
| 93 | 73 | } |
| 94 | 74 | |
| 95 | 75 | [HttpPost] |
| 96 | - public async Task<IActionResult> Update(int id, [FromBody] BusStopEditDsF data){ | |
| 76 | + public async Task<IActionResult> Update(int id, [FromBody] BusStopEditDsM data){ | |
| 97 | 77 | await _busStopDs.SaveAsync(data,id); |
| 98 | 78 | return Json(String.Empty); |
| 99 | 79 | } |
| 100 | 80 | |
| 101 | - // POST: BusStop/Create | |
| 102 | - // To protect from overposting attacks, please enable the specific properties you want to bind to, for | |
| 103 | - // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | |
| 104 | - // [HttpPost] | |
| 105 | - // [ValidateAntiForgeryToken] | |
| 106 | - // public async Task<IActionResult> Create(BusStopEditDsM busStop) | |
| 107 | - // { | |
| 108 | - // if (ModelState.IsValid) | |
| 109 | - // { | |
| 110 | - // await _busStopDs.SaveAsync(busStop); | |
| 111 | - // return Ok(); | |
| 112 | - // } else { | |
| 113 | - // return NotFound(); | |
| 114 | - // } | |
| 115 | - | |
| 116 | - // // var SurfaceType = await _surfaceTypeDs.GetSelectListAsync(); | |
| 117 | - // // var StateCommon = await _stateCommonDs.GetSelectListAsync(); | |
| 118 | - // // var Settlement = await _settlementDs.GetSelectListAsync(); | |
| 119 | - // // var Road = await _roadDs.GetSelectListAsync(); | |
| 120 | - // // var Region = await _regionDc.GetSelectListAsync(); | |
| 121 | - | |
| 122 | - // // CreateBusStopVm vm = new CreateBusStopVm | |
| 123 | - // // { | |
| 124 | - // // SurfaceTypeSelectListDsM = SurfaceType.ToList(), | |
| 125 | - // // StateCommonSelectListDsM = StateCommon.ToList(), | |
| 126 | - // // SettlementSelectListDsM = Settlement.ToList(), | |
| 127 | - // // RoadSelectListDsM = Road.ToList(), | |
| 128 | - // // RegionSelectListDsM = Region.ToList() | |
| 129 | - // // }; | |
| 130 | - // // return Json(vm); | |
| 131 | - // } | |
| 132 | - | |
| 81 | + | |
| 133 | 82 | [HttpDelete] |
| 134 | 83 | public async Task<IActionResult> Delete(int? id) |
| 135 | 84 | { |
| ... | ... | @@ -148,100 +97,5 @@ namespace Maps.Controllers |
| 148 | 97 | return NotFound(); |
| 149 | 98 | } |
| 150 | 99 | } |
| 151 | - | |
| 152 | - | |
| 153 | - // // GET: BusStop/Edit/5 | |
| 154 | - // public async Task<IActionResult> Edit(int? id) | |
| 155 | - // { | |
| 156 | - // if (id == null) | |
| 157 | - // { | |
| 158 | - // return NotFound(); | |
| 159 | - // } | |
| 160 | - | |
| 161 | - // var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 162 | - // if (busStop == null) | |
| 163 | - // { | |
| 164 | - // return NotFound(); | |
| 165 | - // } | |
| 166 | - // ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 167 | - // ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 168 | - // ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 169 | - // ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 170 | - // ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 171 | - // return View(busStop); | |
| 172 | - // } | |
| 173 | - | |
| 174 | - // // POST: BusStop/Edit/5 | |
| 175 | - // // To protect from overposting attacks, please enable the specific properties you want to bind to, for | |
| 176 | - // // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | |
| 177 | - // [HttpPost] | |
| 178 | - // [ValidateAntiForgeryToken] | |
| 179 | - // public async Task<IActionResult> Edit(int id, [Bind("BusStopId,AreaLandAvailability,AreaStopAvailability,BalanceCost,BusStationCardId,CrossSectionNumber,DateActual,LocationLeft,LocationRight,PocketAvailability,Position,RegionId,RepairCertificate,RoadId,SettlementId,StateCommonId,SurfaceTypeId,ToiletAvailability,YearBuild,YearRepair")] BusStop busStop) | |
| 180 | - // { | |
| 181 | - // if (id != busStop.BusStopId) | |
| 182 | - // { | |
| 183 | - // return NotFound(); | |
| 184 | - // } | |
| 185 | - | |
| 186 | - // if (ModelState.IsValid) | |
| 187 | - // { | |
| 188 | - // try | |
| 189 | - // { | |
| 190 | - // _context.Update(busStop); | |
| 191 | - // await _context.SaveChangesAsync(); | |
| 192 | - // } | |
| 193 | - // catch (DbUpdateConcurrencyException) | |
| 194 | - // { | |
| 195 | - // if (!BusStopExists(busStop.BusStopId)) | |
| 196 | - // { | |
| 197 | - // return NotFound(); | |
| 198 | - // } | |
| 199 | - // else | |
| 200 | - // { | |
| 201 | - // throw; | |
| 202 | - // } | |
| 203 | - // } | |
| 204 | - // return RedirectToAction("Index"); | |
| 205 | - // } | |
| 206 | - // ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 207 | - // ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 208 | - // ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 209 | - // ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 210 | - // ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 211 | - // return View(busStop); | |
| 212 | - // } | |
| 213 | - | |
| 214 | - // // GET: BusStop/Delete/5 | |
| 215 | - // public async Task<IActionResult> Delete(int? id) | |
| 216 | - // { | |
| 217 | - // if (id == null) | |
| 218 | - // { | |
| 219 | - // return NotFound(); | |
| 220 | - // } | |
| 221 | - | |
| 222 | - // var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 223 | - // if (busStop == null) | |
| 224 | - // { | |
| 225 | - // return NotFound(); | |
| 226 | - // } | |
| 227 | - | |
| 228 | - // return View(busStop); | |
| 229 | - // } | |
| 230 | - | |
| 231 | - // // POST: BusStop/Delete/5 | |
| 232 | - // [HttpPost, ActionName("Delete")] | |
| 233 | - // [ValidateAntiForgeryToken] | |
| 234 | - // public async Task<IActionResult> DeleteConfirmed(int id) | |
| 235 | - // { | |
| 236 | - // var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 237 | - // _context.BusStop.Remove(busStop); | |
| 238 | - // await _context.SaveChangesAsync(); | |
| 239 | - // return RedirectToAction("Index"); | |
| 240 | - // } | |
| 241 | - | |
| 242 | - // private bool BusStopExists(int id) | |
| 243 | - // { | |
| 244 | - // return _context.BusStop.Any(e => e.BusStopId == id); | |
| 245 | - // } | |
| 246 | 100 | } |
| 247 | 101 | } | ... | ... |
src/Maps/Controllers/DirectoryController.cs renamed to src/Maps/Controllers/ServiceObjectController.cs
100644 → 100755
| 1 | -using Microsoft.AspNetCore.Mvc; | |
| 2 | 1 | using System.Linq; |
| 3 | 2 | using System.Threading.Tasks; |
| 4 | 3 | using Microsoft.AspNetCore.Mvc; |
| ... | ... | @@ -10,84 +9,89 @@ using MapsDb.DataService; |
| 10 | 9 | using MapsModels.ViewModels; |
| 11 | 10 | using MapsModels.DsModels; |
| 12 | 11 | using System; |
| 12 | + | |
| 13 | 13 | namespace Maps.Controllers |
| 14 | 14 | { |
| 15 | - | |
| 16 | - public class DirectoryController : Controller{ | |
| 17 | - | |
| 15 | + public class ServiceObjectController : Controller | |
| 16 | + { | |
| 17 | + private readonly IServiceObjectDs _serviceObjectDs; | |
| 18 | 18 | private readonly IRoadDs _roadDs; |
| 19 | 19 | private readonly ISettlementDs _settlementDs; |
| 20 | - private readonly IStateCommonDs _stateCommonDs; | |
| 21 | 20 | private readonly IRegionDs _regionDs; |
| 22 | - private readonly ISurfaceTypeDs _surfaceTypeDs; | |
| 23 | - public DirectoryController( | |
| 24 | - IBusStopDs BusStopDs, | |
| 25 | - IRoadDs RoadDs, | |
| 26 | - ISettlementDs SettlementDs, | |
| 27 | - IRegionDs RegionDs, | |
| 28 | - IStateCommonDs StateCommonDs, | |
| 29 | - ISurfaceTypeDs SurfaceTypeDs | |
| 30 | - ){ | |
| 21 | + private readonly IDepartmentAffiliationDs _departmentAffiliationDs; | |
| 22 | + | |
| 23 | + public ServiceObjectController(IServiceObjectDs ServiceObjectDs, IRoadDs RoadDs, ISettlementDs SettlementDs, IRegionDs RegionDs, IDepartmentAffiliationDs DepartmentAffiliationDs) | |
| 24 | + { | |
| 25 | + _serviceObjectDs = ServiceObjectDs; | |
| 31 | 26 | _roadDs = RoadDs; |
| 32 | 27 | _settlementDs = SettlementDs; |
| 33 | - _stateCommonDs = StateCommonDs; | |
| 34 | 28 | _regionDs = RegionDs; |
| 35 | - _surfaceTypeDs = SurfaceTypeDs; | |
| 29 | + _departmentAffiliationDs = DepartmentAffiliationDs; | |
| 36 | 30 | } |
| 37 | 31 | |
| 38 | - public async Task<IActionResult> SurfaceTypeDs() | |
| 32 | + // GET: BusStop | |
| 33 | + [HttpGet] | |
| 34 | + public async Task<IActionResult> Index() | |
| 39 | 35 | { |
| 40 | - var SurfaceType = await _surfaceTypeDs.GetSelectListAsync(); | |
| 36 | + var Data = await _serviceObjectDs.GetIndexListAsync(); | |
| 41 | 37 | |
| 42 | - DirectoryVm vm = new DirectoryVm | |
| 38 | + ServiceObjectListVm vm = new ServiceObjectListVm | |
| 43 | 39 | { |
| 44 | - SurfaceTypeSelectListDsM = SurfaceType.ToList(), | |
| 40 | + ServiceObjectEditDsM = Data.ToList() | |
| 45 | 41 | }; |
| 46 | - return Json(vm); | |
| 47 | - } | |
| 48 | - public async Task<IActionResult> SettlementDs() | |
| 49 | - { | |
| 50 | - var Settlement = await _settlementDs.GetSelectListAsync(); | |
| 51 | - | |
| 52 | 42 | |
| 53 | - DirectoryVm vm = new DirectoryVm | |
| 54 | - { | |
| 55 | - SettlementSelectListDsM = Settlement.ToList(), | |
| 56 | - }; | |
| 57 | 43 | return Json(vm); |
| 58 | 44 | } |
| 59 | - public async Task<IActionResult> RoadDs() | |
| 60 | - { | |
| 61 | - var Road = await _roadDs.GetSelectListAsync(); | |
| 62 | - | |
| 63 | 45 | |
| 64 | - DirectoryVm vm = new DirectoryVm | |
| 65 | - { | |
| 66 | - RoadSelectListDsM = Road.ToList(), | |
| 67 | - }; | |
| 68 | - return Json(vm); | |
| 69 | - } | |
| 70 | - public async Task<IActionResult> RegionDs() | |
| 71 | - { | |
| 46 | + [HttpGet] | |
| 47 | + public async Task<IActionResult> Directory(){ | |
| 48 | + var DepartmentAffiliation = await _departmentAffiliationDs.GetSelectListAsync(); | |
| 49 | + var Settlement = await _settlementDs.GetSelectListAsync(); | |
| 50 | + var Road = await _roadDs.GetSelectListAsync(); | |
| 72 | 51 | var Region = await _regionDs.GetSelectListAsync(); |
| 73 | 52 | |
| 74 | - DirectoryVm vm = new DirectoryVm | |
| 53 | + CatalogListVm vm = new CatalogListVm | |
| 75 | 54 | { |
| 55 | + DepartmentAffiliationDsM = DepartmentAffiliation.ToList(), | |
| 56 | + SettlementSelectListDsM = Settlement.ToList(), | |
| 57 | + RoadSelectListDsM = Road.ToList(), | |
| 76 | 58 | RegionSelectListDsM = Region.ToList() |
| 77 | 59 | }; |
| 78 | 60 | return Json(vm); |
| 79 | 61 | } |
| 80 | - public async Task<IActionResult> StateCommonDs() | |
| 62 | + | |
| 63 | + | |
| 64 | + [HttpPost] | |
| 65 | + public async Task<IActionResult> Create([FromBody] ServiceObjectEditDsM data) | |
| 81 | 66 | { |
| 82 | - var StateCommon = await _stateCommonDs.GetSelectListAsync(); | |
| 67 | + var result = await _serviceObjectDs.SaveAsync(data); | |
| 68 | + return Json(result); | |
| 69 | + } | |
| 83 | 70 | |
| 71 | + [HttpPost] | |
| 72 | + public async Task<IActionResult> Update(int id, [FromBody] ServiceObjectEditDsM data){ | |
| 73 | + await _serviceObjectDs.SaveAsync(data,id); | |
| 74 | + return Json(String.Empty); | |
| 75 | + } | |
| 84 | 76 | |
| 85 | - DirectoryVm vm = new DirectoryVm | |
| 77 | + | |
| 78 | + [HttpDelete] | |
| 79 | + public async Task<IActionResult> Delete(int? id) | |
| 80 | + { | |
| 81 | + try | |
| 86 | 82 | { |
| 87 | - StateCommonSelectListDsM = StateCommon.ToList(), | |
| 88 | - }; | |
| 89 | - return Json(vm); | |
| 83 | + if (id == null) | |
| 84 | + { | |
| 85 | + return NotFound(); | |
| 86 | + } | |
| 87 | + | |
| 88 | + int data = await _serviceObjectDs.DeleteAsync(id); | |
| 89 | + return Json(data); | |
| 90 | + } | |
| 91 | + catch (ArgumentNullException ) | |
| 92 | + { | |
| 93 | + return NotFound(); | |
| 94 | + } | |
| 90 | 95 | } |
| 91 | 96 | } |
| 92 | - | |
| 93 | -} | |
| 94 | 97 | \ No newline at end of file |
| 98 | +} | ... | ... |
src/Maps/Startup.cs
| ... | ... | @@ -45,11 +45,13 @@ namespace Maps |
| 45 | 45 | services.AddScoped<PostgresDbContext>(); |
| 46 | 46 | |
| 47 | 47 | services.AddScoped<IBusStopDs, BusStopDs>(); |
| 48 | - services.AddScoped<IRoadDs, RoadDc>(); | |
| 48 | + services.AddScoped<IRoadDs, RoadDs>(); | |
| 49 | 49 | services.AddScoped<IRegionDs, RegionDs>(); |
| 50 | - services.AddScoped<IStateCommonDs, StateCommonDc>(); | |
| 51 | - services.AddScoped<ISurfaceTypeDs, SurfaceTypeDc>(); | |
| 52 | - services.AddScoped<ISettlementDs, SettlementDc>(); | |
| 50 | + services.AddScoped<IStateCommonDs, StateCommonDs>(); | |
| 51 | + services.AddScoped<ISurfaceTypeDs, SurfaceTypeDs>(); | |
| 52 | + services.AddScoped<IServiceObjectDs, ServiceObjectDs>(); | |
| 53 | + services.AddScoped<ISettlementDs, SettlementDs>(); | |
| 54 | + services.AddScoped<IDepartmentAffiliationDs, DepartmentAffiliationDs>(); | |
| 53 | 55 | // Add framework services. |
| 54 | 56 | services.AddApplicationInsightsTelemetry(Configuration); |
| 55 | 57 | ... | ... |
src/MapsDb/DataService/BusStopDs.cs
| ... | ... | @@ -37,42 +37,42 @@ namespace MapsDb.DataService |
| 37 | 37 | }).OrderByDescending(BusStop => BusStop.BusStopId).ToList(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public Task<BusStop> SaveAsync(BusStopEditDsF busStop, int? id = null){ | |
| 40 | + public Task<BusStop> SaveAsync(BusStopEditDsM busStop, int? id = null){ | |
| 41 | 41 | return Task.Factory.StartNew(()=> { return Save(busStop, id); }); |
| 42 | 42 | } |
| 43 | - private BusStop Save(BusStopEditDsF busStop, int? id) | |
| 43 | + private BusStop Save(BusStopEditDsM busStop, int? id) | |
| 44 | 44 | { |
| 45 | 45 | BusStop Bs = new BusStop{ |
| 46 | - RoadId = busStop.roadId, | |
| 47 | - RegionId = busStop.regionId, | |
| 48 | - SettlementId = busStop.settlementId, | |
| 49 | - LocationLeft = busStop.locationLeft, | |
| 50 | - LocationRight = busStop.locationRight, | |
| 51 | - SurfaceTypeId = busStop.surfaceTypeId, | |
| 52 | - AreaStopAvailability = busStop.areaStopAvailability, | |
| 53 | - AreaLandAvailability = busStop.areaLandAvailability, | |
| 54 | - PocketAvailability = busStop.pocketAvailability, | |
| 55 | - ToiletAvailability = busStop.toiletAvailability, | |
| 56 | - YearBuild = busStop.yearBuild, | |
| 57 | - YearRepair = busStop.yearRepair, | |
| 58 | - StateCommonId = busStop.stateCommonId | |
| 46 | + RoadId = busStop.RoadId, | |
| 47 | + RegionId = busStop.RegionId, | |
| 48 | + SettlementId = busStop.SettlementId, | |
| 49 | + LocationLeft = busStop.LocationLeft, | |
| 50 | + LocationRight = busStop.LocationRight, | |
| 51 | + SurfaceTypeId = busStop.SurfaceTypeId, | |
| 52 | + AreaStopAvailability = busStop.AreaStopAvailability, | |
| 53 | + AreaLandAvailability = busStop.AreaLandAvailability, | |
| 54 | + PocketAvailability = busStop.PocketAvailability, | |
| 55 | + ToiletAvailability = busStop.ToiletAvailability, | |
| 56 | + YearBuild = busStop.YearBuild, | |
| 57 | + YearRepair = busStop.YearRepair, | |
| 58 | + StateCommonId = busStop.StateCommonId | |
| 59 | 59 | }; |
| 60 | 60 | var busStopFromDb = _context.BusStop.FirstOrDefault(x => x.BusStopId == id); |
| 61 | 61 | if(busStopFromDb != null) |
| 62 | 62 | { |
| 63 | - busStopFromDb.RoadId = busStop.roadId; | |
| 64 | - busStopFromDb.RegionId = busStop.regionId; | |
| 65 | - busStopFromDb.SettlementId = busStop.settlementId; | |
| 66 | - busStopFromDb.LocationLeft = busStop.locationLeft; | |
| 67 | - busStopFromDb.LocationRight = busStop.locationRight; | |
| 68 | - busStopFromDb.SurfaceTypeId = busStop.surfaceTypeId; | |
| 69 | - busStopFromDb.AreaStopAvailability = busStop.areaStopAvailability; | |
| 70 | - busStopFromDb.AreaLandAvailability = busStop.areaLandAvailability; | |
| 71 | - busStopFromDb.PocketAvailability = busStop.pocketAvailability; | |
| 72 | - busStopFromDb.ToiletAvailability = busStop.toiletAvailability; | |
| 73 | - busStopFromDb.YearBuild = busStop.yearBuild; | |
| 74 | - busStopFromDb.YearRepair = busStop.yearRepair; | |
| 75 | - busStopFromDb.StateCommonId = busStop.stateCommonId; | |
| 63 | + busStopFromDb.RoadId = busStop.RoadId; | |
| 64 | + busStopFromDb.RegionId = busStop.RegionId; | |
| 65 | + busStopFromDb.SettlementId = busStop.SettlementId; | |
| 66 | + busStopFromDb.LocationLeft = busStop.LocationLeft; | |
| 67 | + busStopFromDb.LocationRight = busStop.LocationRight; | |
| 68 | + busStopFromDb.SurfaceTypeId = busStop.SurfaceTypeId; | |
| 69 | + busStopFromDb.AreaStopAvailability = busStop.AreaStopAvailability; | |
| 70 | + busStopFromDb.AreaLandAvailability = busStop.AreaLandAvailability; | |
| 71 | + busStopFromDb.PocketAvailability = busStop.PocketAvailability; | |
| 72 | + busStopFromDb.ToiletAvailability = busStop.ToiletAvailability; | |
| 73 | + busStopFromDb.YearBuild = busStop.YearBuild; | |
| 74 | + busStopFromDb.YearRepair = busStop.YearRepair; | |
| 75 | + busStopFromDb.StateCommonId = busStop.StateCommonId; | |
| 76 | 76 | } |
| 77 | 77 | else |
| 78 | 78 | { |
| ... | ... | @@ -81,26 +81,6 @@ namespace MapsDb.DataService |
| 81 | 81 | _context.SaveChanges(); |
| 82 | 82 | return Bs; |
| 83 | 83 | } |
| 84 | - public Task<BusStopDetailsDsM> FindOneDetailsAsync(int Id){ | |
| 85 | - return Task.Factory.StartNew(()=> { return FindOneDetails(Id); }); | |
| 86 | - } | |
| 87 | - private BusStopDetailsDsM FindOneDetails(int Id){ | |
| 88 | - return _context.BusStop.Where(x => x.BusStopId == Id).Select(x => new BusStopDetailsDsM{ | |
| 89 | - BusStopId = x.BusStopId, | |
| 90 | - Road = x.Road.Name, | |
| 91 | - Region = x.Region.Name, | |
| 92 | - Settlement = x.Settlement.Name, | |
| 93 | - LocationLeft = x.LocationLeft, | |
| 94 | - LocationRight = x.LocationRight, | |
| 95 | - StateCommon = x.StateCommon.Value, | |
| 96 | - AreaStopAvailability = x.AreaStopAvailability, | |
| 97 | - AreaLandAvailability = x.AreaLandAvailability, | |
| 98 | - PocketAvailability = x.PocketAvailability, | |
| 99 | - ToiletAvailability = x.ToiletAvailability, | |
| 100 | - YearBuild = x.YearBuild, | |
| 101 | - YearRepair = x.YearRepair | |
| 102 | - }).Single(); | |
| 103 | - } | |
| 104 | 84 | public async Task<int> DeleteAsync(int? Id) |
| 105 | 85 | { |
| 106 | 86 | var busStop = await _context.BusStop.SingleOrDefaultAsync(x => x.BusStopId == Id); | ... | ... |
| 1 | +using System.Collections.Generic; | |
| 2 | +using System.Linq; | |
| 3 | +using System.Threading.Tasks; | |
| 4 | +using MapsDb.Interfaces; | |
| 5 | +using MapsDb.Models; | |
| 6 | +using MapsModels.DsModels; | |
| 7 | +namespace MapsDb.DataService | |
| 8 | +{ | |
| 9 | + public class DepartmentAffiliationDs : IDepartmentAffiliationDs | |
| 10 | + { | |
| 11 | + private PostgresDbContext _context; | |
| 12 | + public DepartmentAffiliationDs(){ | |
| 13 | + _context = new PostgresDbContext(); | |
| 14 | + } | |
| 15 | + public Task<IList<DepartmentAffiliationListDsM>> GetSelectListAsync(){ | |
| 16 | + return Task.Factory.StartNew(GetSelectList); | |
| 17 | + } | |
| 18 | + private IList<DepartmentAffiliationListDsM> GetSelectList() | |
| 19 | + { | |
| 20 | + return _context.DepartmentAffiliation.Select(x => new DepartmentAffiliationListDsM | |
| 21 | + { | |
| 22 | + DepartmentAffiliationId = x.DepartmentAffiliationId, | |
| 23 | + Name = x.Name | |
| 24 | + }).ToList(); | |
| 25 | + } | |
| 26 | + | |
| 27 | + } | |
| 28 | +} | |
| 0 | 29 | \ No newline at end of file | ... | ... |
src/MapsDb/DataService/RoadDs.cs
| ... | ... | @@ -6,10 +6,10 @@ using MapsDb.Models; |
| 6 | 6 | using MapsModels.DsModels; |
| 7 | 7 | namespace MapsDb.DataService |
| 8 | 8 | { |
| 9 | - public class RoadDc : IRoadDs | |
| 9 | + public class RoadDs : IRoadDs | |
| 10 | 10 | { |
| 11 | 11 | private PostgresDbContext _context; |
| 12 | - public RoadDc(){ | |
| 12 | + public RoadDs(){ | |
| 13 | 13 | _context = new PostgresDbContext(); |
| 14 | 14 | } |
| 15 | 15 | public Task<IList<RoadSelectListDsM>> GetSelectListAsync(){ | ... | ... |
| 1 | +using System.Collections.Generic; | |
| 2 | +using System.Linq; | |
| 3 | +using System.Threading.Tasks; | |
| 4 | +using MapsDb.Interfaces; | |
| 5 | +using MapsDb.Models; | |
| 6 | +using MapsModels.DsModels; | |
| 7 | +using Microsoft.EntityFrameworkCore; | |
| 8 | +namespace MapsDb.DataService | |
| 9 | +{ | |
| 10 | + public class ServiceObjectDs : IServiceObjectDs | |
| 11 | + { | |
| 12 | + private PostgresDbContext _context; | |
| 13 | + public ServiceObjectDs(){ | |
| 14 | + _context = new PostgresDbContext(); | |
| 15 | + } | |
| 16 | + public Task<IList<ServiceObjectEditDsM>> GetIndexListAsync(){ | |
| 17 | + return Task.Factory.StartNew(GetAllServiceObject); | |
| 18 | + } | |
| 19 | + private IList<ServiceObjectEditDsM> GetAllServiceObject() | |
| 20 | + { | |
| 21 | + return _context.ServiceObject.Select(ServiceObject => new ServiceObjectEditDsM | |
| 22 | + { | |
| 23 | + ServiceObjectId = ServiceObject.ServiceObjectId, | |
| 24 | + RoadId = ServiceObject.RoadId, | |
| 25 | + RegionId = ServiceObject.RegionId, | |
| 26 | + SettlementId = ServiceObject.SettlementId, | |
| 27 | + LocationLeft = ServiceObject.LocationLeft, | |
| 28 | + LocationRight = ServiceObject.LocationRight, | |
| 29 | + ServiceObjectTypeId = ServiceObject.ServiceObjectTypeId, | |
| 30 | + DepartmentAffiliationId = ServiceObject.DepartmentAffiliationId, | |
| 31 | + LocationAxis = ServiceObject.LocationAxis, | |
| 32 | + Distance = ServiceObject.Distance, | |
| 33 | + Capacity = ServiceObject.Capacity, | |
| 34 | + ArrangementElements = ServiceObject.ArrangementElements, | |
| 35 | + }).OrderByDescending(ServiceObject => ServiceObject.ServiceObjectId).ToList(); | |
| 36 | + } | |
| 37 | + | |
| 38 | + public Task<ServiceObject> SaveAsync(ServiceObjectEditDsM serviceObject, int? id = null){ | |
| 39 | + return Task.Factory.StartNew(()=> { return Save(serviceObject, id); }); | |
| 40 | + } | |
| 41 | + private ServiceObject Save(ServiceObjectEditDsM serviceObject, int? id) | |
| 42 | + { | |
| 43 | + ServiceObject Data = new ServiceObject{ | |
| 44 | + ServiceObjectId = serviceObject.ServiceObjectId, | |
| 45 | + RoadId = serviceObject.RoadId, | |
| 46 | + RegionId = serviceObject.RegionId, | |
| 47 | + SettlementId = serviceObject.SettlementId, | |
| 48 | + LocationLeft = serviceObject.LocationLeft, | |
| 49 | + LocationRight = serviceObject.LocationRight, | |
| 50 | + ServiceObjectTypeId = serviceObject.ServiceObjectTypeId, | |
| 51 | + DepartmentAffiliationId = serviceObject.DepartmentAffiliationId, | |
| 52 | + LocationAxis = serviceObject.LocationAxis, | |
| 53 | + Distance = serviceObject.Distance, | |
| 54 | + Capacity = serviceObject.Capacity, | |
| 55 | + ArrangementElements = serviceObject.ArrangementElements, | |
| 56 | + }; | |
| 57 | + var ServiceObjectFromDb = _context.ServiceObject.FirstOrDefault(x => x.ServiceObjectId == id); | |
| 58 | + if(ServiceObjectFromDb != null) | |
| 59 | + { | |
| 60 | + ServiceObjectFromDb.ServiceObjectId = Data.ServiceObjectId; | |
| 61 | + ServiceObjectFromDb.RoadId = Data.RoadId; | |
| 62 | + ServiceObjectFromDb.RegionId = Data.RegionId; | |
| 63 | + ServiceObjectFromDb.SettlementId = Data.SettlementId; | |
| 64 | + ServiceObjectFromDb.LocationLeft = Data.LocationLeft; | |
| 65 | + ServiceObjectFromDb.LocationRight = Data.LocationRight; | |
| 66 | + ServiceObjectFromDb.ServiceObjectTypeId = Data.ServiceObjectTypeId; | |
| 67 | + ServiceObjectFromDb.DepartmentAffiliationId = Data.DepartmentAffiliationId; | |
| 68 | + ServiceObjectFromDb.LocationAxis = Data.LocationAxis; | |
| 69 | + ServiceObjectFromDb.Distance = Data.Distance; | |
| 70 | + ServiceObjectFromDb.Capacity = Data.Capacity; | |
| 71 | + ServiceObjectFromDb.ArrangementElements = Data.ArrangementElements; | |
| 72 | + } | |
| 73 | + else | |
| 74 | + { | |
| 75 | + _context.ServiceObject.Add(Data); | |
| 76 | + } | |
| 77 | + _context.SaveChanges(); | |
| 78 | + return Data; | |
| 79 | + } | |
| 80 | + public async Task<int> DeleteAsync(int? Id) | |
| 81 | + { | |
| 82 | + var ServiceObject = await _context.ServiceObject.SingleOrDefaultAsync(x => x.ServiceObjectId == Id); | |
| 83 | + _context.ServiceObject.Remove(ServiceObject); | |
| 84 | + return await _context.SaveChangesAsync(); | |
| 85 | + } | |
| 86 | + } | |
| 87 | +} | |
| 0 | 88 | \ No newline at end of file | ... | ... |
src/MapsDb/DataService/SettlementDs.cs
| ... | ... | @@ -6,10 +6,10 @@ using MapsDb.Models; |
| 6 | 6 | using MapsModels.DsModels; |
| 7 | 7 | namespace MapsDb.DataService |
| 8 | 8 | { |
| 9 | - public class SettlementDc : ISettlementDs | |
| 9 | + public class SettlementDs : ISettlementDs | |
| 10 | 10 | { |
| 11 | 11 | private PostgresDbContext _context; |
| 12 | - public SettlementDc(){ | |
| 12 | + public SettlementDs(){ | |
| 13 | 13 | _context = new PostgresDbContext(); |
| 14 | 14 | } |
| 15 | 15 | public Task<IList<SettlementSelectListDsM>> GetSelectListAsync(){ | ... | ... |
src/MapsDb/DataService/StateCommonDs.cs
| ... | ... | @@ -6,10 +6,10 @@ using MapsDb.Models; |
| 6 | 6 | using MapsModels.DsModels; |
| 7 | 7 | namespace MapsDb.DataService |
| 8 | 8 | { |
| 9 | - public class StateCommonDc : IStateCommonDs | |
| 9 | + public class StateCommonDs : IStateCommonDs | |
| 10 | 10 | { |
| 11 | 11 | private PostgresDbContext _context; |
| 12 | - public StateCommonDc(){ | |
| 12 | + public StateCommonDs(){ | |
| 13 | 13 | _context = new PostgresDbContext(); |
| 14 | 14 | } |
| 15 | 15 | public Task<IList<StateCommonSelectListDsM>> GetSelectListAsync(){ | ... | ... |
src/MapsDb/DataService/SurfaceTypeDs.cs
| ... | ... | @@ -6,10 +6,10 @@ using MapsDb.Models; |
| 6 | 6 | using MapsModels.DsModels; |
| 7 | 7 | namespace MapsDb.DataService |
| 8 | 8 | { |
| 9 | - public class SurfaceTypeDc : ISurfaceTypeDs | |
| 9 | + public class SurfaceTypeDs : ISurfaceTypeDs | |
| 10 | 10 | { |
| 11 | 11 | private PostgresDbContext _context; |
| 12 | - public SurfaceTypeDc(){ | |
| 12 | + public SurfaceTypeDs(){ | |
| 13 | 13 | _context = new PostgresDbContext(); |
| 14 | 14 | } |
| 15 | 15 | public Task<IList<SurfaceTypeSelectListDsM>> GetSelectListAsync(){ | ... | ... |
src/MapsDb/Interfaces/IBusStopDs.cs
| ... | ... | @@ -7,8 +7,7 @@ namespace MapsDb.Interfaces |
| 7 | 7 | public interface IBusStopDs |
| 8 | 8 | { |
| 9 | 9 | Task<IList<BusStopEditDsM>> GetIndexListAsync(); |
| 10 | - Task<BusStop> SaveAsync(BusStopEditDsF busStop, int? id = null); | |
| 11 | - Task<BusStopDetailsDsM> FindOneDetailsAsync(int Id); | |
| 10 | + Task<BusStop> SaveAsync(BusStopEditDsM busStop, int? id = null); | |
| 12 | 11 | Task<int> DeleteAsync(int? Id); |
| 13 | 12 | } |
| 14 | 13 | } |
| 15 | 14 | \ No newline at end of file | ... | ... |
src/MapsModels/ViewModels/DirectoryVm.cs renamed to src/MapsDb/Interfaces/IDepartmentAffiliationDs.cs
| 1 | 1 | using System.Collections.Generic; |
| 2 | +using System.Threading.Tasks; | |
| 2 | 3 | using MapsModels.DsModels; |
| 3 | - | |
| 4 | -namespace MapsModels.ViewModels | |
| 4 | +using MapsDb.Models; | |
| 5 | +namespace MapsDb.Interfaces | |
| 5 | 6 | { |
| 6 | - public class DirectoryVm | |
| 7 | + public interface IDepartmentAffiliationDs | |
| 7 | 8 | { |
| 8 | - public List<SurfaceTypeSelectListDsM> SurfaceTypeSelectListDsM { get; set; } | |
| 9 | - public List<StateCommonSelectListDsM> StateCommonSelectListDsM { get; set; } | |
| 10 | - public List<SettlementSelectListDsM> SettlementSelectListDsM { get; set; } | |
| 11 | - public List<RoadSelectListDsM> RoadSelectListDsM { get; set; } | |
| 12 | - public List<RegionSelectListDsM> RegionSelectListDsM { get; set; } | |
| 9 | + Task<IList<DepartmentAffiliationListDsM>> GetSelectListAsync(); | |
| 13 | 10 | } |
| 14 | 11 | -} |
| 12 | +} | |
| 15 | 13 | \ No newline at end of file | ... | ... |
| 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 IServiceObjectDs | |
| 8 | + { | |
| 9 | + Task<IList<ServiceObjectEditDsM>> GetIndexListAsync(); | |
| 10 | + Task<ServiceObject> SaveAsync(ServiceObjectEditDsM serviceObject, int? id = null); | |
| 11 | + Task<int> DeleteAsync(int? Id); | |
| 12 | + | |
| 13 | + } | |
| 14 | +} | |
| 0 | 15 | \ No newline at end of file | ... | ... |
src/MapsModels/DsModels/BusStopDetailsDsM.cs deleted
| 1 | -namespace MapsModels.DsModels | |
| 2 | -{ | |
| 3 | - public class BusStopDetailsDsM | |
| 4 | - { | |
| 5 | - public int BusStopId { get; set; } | |
| 6 | - public string Road { get; set; } | |
| 7 | - public string Region { get; set; } | |
| 8 | - public string Settlement { get; set; } | |
| 9 | - public double? LocationLeft { get; set; } | |
| 10 | - public double? LocationRight { get; set; } | |
| 11 | - public string SurfaceType { get; set; } | |
| 12 | - public int? AreaStopAvailability { get; set; } | |
| 13 | - public int? AreaLandAvailability { get; set; } | |
| 14 | - public int? PocketAvailability { get; set; } | |
| 15 | - public int? ToiletAvailability { get; set; } | |
| 16 | - public int? YearBuild { get; set; } | |
| 17 | - public int? YearRepair { get; set; } | |
| 18 | - public string StateCommon { get; set; } | |
| 19 | - | |
| 20 | - } | |
| 21 | -} | |
| 22 | 0 | \ No newline at end of file |
src/MapsModels/DsModels/BusStopEditDsF.cs deleted
| 1 | -namespace MapsModels.DsModels | |
| 2 | -{ | |
| 3 | - public class BusStopEditDsF | |
| 4 | - { | |
| 5 | - public int? busStopId { get; set; } | |
| 6 | - public int? roadId { get; set; } | |
| 7 | - public int? regionId { get; set; } | |
| 8 | - public int? settlementId { get; set; } | |
| 9 | - public double? locationLeft { get; set; } | |
| 10 | - public double? locationRight { get; set; } | |
| 11 | - public int? surfaceTypeId { get; set; } | |
| 12 | - public int? areaStopAvailability { get; set; } | |
| 13 | - public int? areaLandAvailability { get; set; } | |
| 14 | - public int? pocketAvailability { get; set; } | |
| 15 | - public int? toiletAvailability { get; set; } | |
| 16 | - public int? yearBuild { get; set; } | |
| 17 | - public int? yearRepair { get; set; } | |
| 18 | - public int? stateCommonId { get; set; } | |
| 19 | - | |
| 20 | - } | |
| 21 | -} | |
| 22 | 0 | \ No newline at end of file |
src/MapsModels/DsModels/BusStopListDsM.cs renamed to src/MapsModels/DsModels/DepartmentAffiliationListDsM.cs
| 1 | 1 | namespace MapsModels.DsModels |
| 2 | 2 | { |
| 3 | - public class BusStopListDsM | |
| 3 | + public class DepartmentAffiliationListDsM | |
| 4 | 4 | { |
| 5 | - public string Road { get; set; } | |
| 6 | - public string Region { get; set; } | |
| 7 | - public string Settlement { get; set; } | |
| 8 | - public double? LocationLeft { get; set; } | |
| 9 | - public double? LocationRight { get; set; } | |
| 10 | - public string StateCommon { get; set; } | |
| 5 | + public int DepartmentAffiliationId { get; set; } | |
| 6 | + public string Name { get; set; } | |
| 11 | 7 | } |
| 12 | 8 | } |
| 13 | 9 | \ No newline at end of file | ... | ... |
| 1 | +namespace MapsModels.DsModels | |
| 2 | +{ | |
| 3 | + public class ServiceObjectEditDsM | |
| 4 | + { | |
| 5 | + public int ServiceObjectId { get; set; } | |
| 6 | + public int? RoadId { get; set; } | |
| 7 | + public int? RegionId { get; set; } | |
| 8 | + public int? ServiceObjectTypeId { get; set; } | |
| 9 | + public int? SettlementId { get; set; } | |
| 10 | + public int? DepartmentAffiliationId { get; set; } | |
| 11 | + public double? LocationRight { get; set; } | |
| 12 | + public double? LocationLeft { get; set; } | |
| 13 | + public double? LocationAxis { get; set; } | |
| 14 | + public double? Distance { get; set; } | |
| 15 | + public double? Capacity { get; set; } | |
| 16 | + public string ArrangementElements { get; set; } | |
| 17 | + | |
| 18 | + } | |
| 19 | +} | |
| 0 | 20 | \ No newline at end of file | ... | ... |
src/MapsModels/ViewModels/ListBusStopVm.cs renamed to src/MapsModels/ViewModels/BusStopListVm.cs
src/MapsModels/ViewModels/CreateBusStopVm.cs renamed to src/MapsModels/ViewModels/CatalogListVm.cs
| ... | ... | @@ -3,8 +3,9 @@ using MapsModels.DsModels; |
| 3 | 3 | |
| 4 | 4 | namespace MapsModels.ViewModels |
| 5 | 5 | { |
| 6 | - public class CreateBusStopVm | |
| 6 | + public class CatalogListVm | |
| 7 | 7 | { |
| 8 | + public List<DepartmentAffiliationListDsM> DepartmentAffiliationDsM { get; set; } | |
| 8 | 9 | public List<SurfaceTypeSelectListDsM> SurfaceTypeSelectListDsM { get; set; } |
| 9 | 10 | public List<StateCommonSelectListDsM> StateCommonSelectListDsM { get; set; } |
| 10 | 11 | public List<SettlementSelectListDsM> SettlementSelectListDsM { get; set; } | ... | ... |
src/MapsModels/ViewModels/DetailsBusStopVm.cs renamed to src/MapsModels/ViewModels/ServiceObjectListVm.cs
| ... | ... | @@ -3,8 +3,8 @@ using MapsModels.DsModels; |
| 3 | 3 | |
| 4 | 4 | namespace MapsModels.ViewModels |
| 5 | 5 | { |
| 6 | - public class DetailsBusStopVm | |
| 6 | + public class ServiceObjectListVm | |
| 7 | 7 | { |
| 8 | - public BusStopDetailsDsM busStopDetailsDsM { get; set; } | |
| 8 | + public List<ServiceObjectEditDsM> ServiceObjectEditDsM { get; set; } | |
| 9 | 9 | } |
| 10 | 10 | } | ... | ... |