Commit 1a6c8f646f3afc119bcc9aa85a4e33604944bacc
1 parent
f2836c7d
Add/update completed
Showing
2 changed files
with
20 additions
and
13 deletions
Show diff stats
src/Maps/Controllers/BusStopController.cs
@@ -86,21 +86,16 @@ namespace Maps.Controllers | @@ -86,21 +86,16 @@ namespace Maps.Controllers | ||
86 | 86 | ||
87 | // GET: BusStop/Create | 87 | // GET: BusStop/Create |
88 | [HttpPost] | 88 | [HttpPost] |
89 | - public async Task<IActionResult> Create(string data) | 89 | + public async Task<IActionResult> Create([FromBody] BusStopEditDsF data) |
90 | { | 90 | { |
91 | + await _busStopDs.SaveAsync(data); | ||
91 | return Ok(data); | 92 | return Ok(data); |
92 | } | 93 | } |
93 | 94 | ||
94 | [HttpPost] | 95 | [HttpPost] |
95 | - public async Task<IActionResult> Update(int id, BusStopEditDsF data){ | ||
96 | - if (ModelState.IsValid) | ||
97 | - { | ||
98 | - await _busStopDs.SaveAsync(data,id); | ||
99 | - return Ok(); | ||
100 | - } else { | ||
101 | - return NotFound(); | ||
102 | - } | ||
103 | - | 96 | + public async Task<IActionResult> Update(int id, [FromBody] BusStopEditDsF data){ |
97 | + await _busStopDs.SaveAsync(data,id); | ||
98 | + return Ok(); | ||
104 | } | 99 | } |
105 | 100 | ||
106 | // POST: BusStop/Create | 101 | // POST: BusStop/Create |
src/MapsDb/DataService/BusStopDs.cs
@@ -40,7 +40,7 @@ namespace MapsDb.DataService | @@ -40,7 +40,7 @@ namespace MapsDb.DataService | ||
40 | public Task SaveAsync(BusStopEditDsF busStop, int? id = null){ | 40 | public Task SaveAsync(BusStopEditDsF busStop, int? id = null){ |
41 | return Task.Factory.StartNew(()=> { Save(busStop, id); }); | 41 | return Task.Factory.StartNew(()=> { Save(busStop, id); }); |
42 | } | 42 | } |
43 | - private void Save(BusStopEditDsF busStop, int? id) | 43 | + private async void Save(BusStopEditDsF busStop, int? id) |
44 | { | 44 | { |
45 | BusStop Bs = new BusStop{ | 45 | BusStop Bs = new BusStop{ |
46 | RoadId = busStop.roadId, | 46 | RoadId = busStop.roadId, |
@@ -57,10 +57,22 @@ namespace MapsDb.DataService | @@ -57,10 +57,22 @@ namespace MapsDb.DataService | ||
57 | YearRepair = busStop.yearRepair, | 57 | YearRepair = busStop.yearRepair, |
58 | StateCommonId = busStop.stateCommonId | 58 | StateCommonId = busStop.stateCommonId |
59 | }; | 59 | }; |
60 | - var busStopFromDb = _context.BusStop.SingleOrDefault(x => x.BusStopId == id); | 60 | + var busStopFromDb = _context.BusStop.FirstOrDefault(x => x.BusStopId == id); |
61 | if(busStopFromDb != null) | 61 | if(busStopFromDb != null) |
62 | { | 62 | { |
63 | - busStopFromDb = Bs; | 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; | ||
64 | } | 76 | } |
65 | else | 77 | else |
66 | { | 78 | { |