From f2836c7d48dbb5e9e17f70d128e6014a58e0b35f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 3 Feb 2017 16:54:14 +0200 Subject: [PATCH] Update --- src/Maps/Controllers/BusStopController.cs | 11 +++++++++-- src/MapsDb/DataService/BusStopDs.cs | 30 +++++++++++++++--------------- src/MapsDb/Interfaces/IBusStopDs.cs | 2 +- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/Maps/Controllers/BusStopController.cs b/src/Maps/Controllers/BusStopController.cs index 3351c41..ce8f1c1 100755 --- a/src/Maps/Controllers/BusStopController.cs +++ b/src/Maps/Controllers/BusStopController.cs @@ -92,8 +92,15 @@ namespace Maps.Controllers } [HttpPost] - public IActionResult Update(int id, BusStopEditDsF data){ - return Ok(data); + public async Task Update(int id, BusStopEditDsF data){ + if (ModelState.IsValid) + { + await _busStopDs.SaveAsync(data,id); + return Ok(); + } else { + return NotFound(); + } + } // POST: BusStop/Create diff --git a/src/MapsDb/DataService/BusStopDs.cs b/src/MapsDb/DataService/BusStopDs.cs index 3710bdf..b718e4b 100644 --- a/src/MapsDb/DataService/BusStopDs.cs +++ b/src/MapsDb/DataService/BusStopDs.cs @@ -37,25 +37,25 @@ namespace MapsDb.DataService }).ToList(); } - public Task SaveAsync(BusStopEditDsM busStop, int? id = null){ + public Task SaveAsync(BusStopEditDsF busStop, int? id = null){ return Task.Factory.StartNew(()=> { Save(busStop, id); }); } - private void Save(BusStopEditDsM busStop, int? id) + private void Save(BusStopEditDsF busStop, int? id) { BusStop Bs = new BusStop{ - RoadId = busStop.RoadId, - RegionId = busStop.RegionId, - SettlementId = busStop.SettlementId, - LocationLeft = busStop.LocationLeft, - LocationRight = busStop.LocationRight, - SurfaceTypeId = busStop.SurfaceTypeId, - AreaStopAvailability = busStop.AreaStopAvailability, - AreaLandAvailability = busStop.AreaLandAvailability, - PocketAvailability = busStop.PocketAvailability, - ToiletAvailability = busStop.ToiletAvailability, - YearBuild = busStop.YearBuild, - YearRepair = busStop.YearRepair, - StateCommonId = busStop.StateCommonId + RoadId = busStop.roadId, + RegionId = busStop.regionId, + SettlementId = busStop.settlementId, + LocationLeft = busStop.locationLeft, + LocationRight = busStop.locationRight, + SurfaceTypeId = busStop.surfaceTypeId, + AreaStopAvailability = busStop.areaStopAvailability, + AreaLandAvailability = busStop.areaLandAvailability, + PocketAvailability = busStop.pocketAvailability, + ToiletAvailability = busStop.toiletAvailability, + YearBuild = busStop.yearBuild, + YearRepair = busStop.yearRepair, + StateCommonId = busStop.stateCommonId }; var busStopFromDb = _context.BusStop.SingleOrDefault(x => x.BusStopId == id); if(busStopFromDb != null) diff --git a/src/MapsDb/Interfaces/IBusStopDs.cs b/src/MapsDb/Interfaces/IBusStopDs.cs index 0537e2b..0fdd66a 100644 --- a/src/MapsDb/Interfaces/IBusStopDs.cs +++ b/src/MapsDb/Interfaces/IBusStopDs.cs @@ -7,7 +7,7 @@ namespace MapsDb.Interfaces public interface IBusStopDs { Task> GetIndexListAsync(); - Task SaveAsync(BusStopEditDsM busStop, int? id = null); + Task SaveAsync(BusStopEditDsF busStop, int? id = null); Task FindOneDetailsAsync(int Id); Task DeleteAsync(int? Id); } -- libgit2 0.21.4