From 7230fa316121442bb67d9e5a63aae4a0ce8bb69b Mon Sep 17 00:00:00 2001 From: yarik Date: Tue, 7 Feb 2017 15:16:27 +0200 Subject: [PATCH] Fixes --- src/Maps/Controllers/BusStopController.cs | 6 +++--- src/MapsDb/DataService/BusStopDs.cs | 9 +++++---- src/MapsDb/Interfaces/IBusStopDs.cs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Maps/Controllers/BusStopController.cs b/src/Maps/Controllers/BusStopController.cs index 4d1720d..8ed88d8 100755 --- a/src/Maps/Controllers/BusStopController.cs +++ b/src/Maps/Controllers/BusStopController.cs @@ -88,14 +88,14 @@ namespace Maps.Controllers [HttpPost] public async Task Create([FromBody] BusStopEditDsF data) { - await _busStopDs.SaveAsync(data); - return Ok(data); + var result = await _busStopDs.SaveAsync(data); + return Json(result); } [HttpPost] public async Task Update(int id, [FromBody] BusStopEditDsF data){ await _busStopDs.SaveAsync(data,id); - return Ok(); + return Json(String.Empty); } // POST: BusStop/Create diff --git a/src/MapsDb/DataService/BusStopDs.cs b/src/MapsDb/DataService/BusStopDs.cs index f258361..9a05ea7 100644 --- a/src/MapsDb/DataService/BusStopDs.cs +++ b/src/MapsDb/DataService/BusStopDs.cs @@ -34,13 +34,13 @@ namespace MapsDb.DataService YearBuild = busStop.YearBuild, YearRepair = busStop.YearRepair, StateCommonId = busStop.StateCommonId - }).ToList(); + }).OrderByDescending(BusStop => BusStop.BusStopId).ToList(); } - public Task SaveAsync(BusStopEditDsF busStop, int? id = null){ - return Task.Factory.StartNew(()=> { Save(busStop, id); }); + public Task SaveAsync(BusStopEditDsF busStop, int? id = null){ + return Task.Factory.StartNew(()=> { return Save(busStop, id); }); } - private async void Save(BusStopEditDsF busStop, int? id) + private BusStop Save(BusStopEditDsF busStop, int? id) { BusStop Bs = new BusStop{ RoadId = busStop.roadId, @@ -79,6 +79,7 @@ namespace MapsDb.DataService _context.BusStop.Add(Bs); } _context.SaveChanges(); + return Bs; } public Task FindOneDetailsAsync(int Id){ return Task.Factory.StartNew(()=> { return FindOneDetails(Id); }); diff --git a/src/MapsDb/Interfaces/IBusStopDs.cs b/src/MapsDb/Interfaces/IBusStopDs.cs index 0fdd66a..0eb1920 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(BusStopEditDsF busStop, int? id = null); + Task SaveAsync(BusStopEditDsF busStop, int? id = null); Task FindOneDetailsAsync(int Id); Task DeleteAsync(int? Id); } -- libgit2 0.21.4