diff --git a/src/Maps/Controllers/BusStopController.cs b/src/Maps/Controllers/BusStopController.cs index 07e8147..6e7aadf 100755 --- a/src/Maps/Controllers/BusStopController.cs +++ b/src/Maps/Controllers/BusStopController.cs @@ -7,6 +7,8 @@ using MapsDb; using MapsDb.Interfaces; using MapsDb.DataService; using MapsModels.ViewModels; +using System; + namespace Maps.Controllers { public class BusStopController : Controller @@ -83,6 +85,25 @@ namespace Maps.Controllers return Json(vm); } + [HttpDelete] + public async Task Delete(int? id) + { + if (id == null) + { + return NotFound(); + } + int busStop; + try + { + busStop = await _busStopDs.DeleteAsync(id); + } + catch (ArgumentNullException e) + { + return NotFound(); + } + return Json(busStop); + } + // // POST: BusStop/Create // // To protect from overposting attacks, please enable the specific properties you want to bind to, for // // more details see http://go.microsoft.com/fwlink/?LinkId=317598. diff --git a/src/MapsDb/DataService/BusStopDs.cs b/src/MapsDb/DataService/BusStopDs.cs index 26bd3c8..0ffd5ad 100644 --- a/src/MapsDb/DataService/BusStopDs.cs +++ b/src/MapsDb/DataService/BusStopDs.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using MapsDb.Interfaces; using MapsDb.Models; using MapsModels.DsModels; +using Microsoft.EntityFrameworkCore; namespace MapsDb.DataService { @@ -64,5 +65,11 @@ namespace MapsDb.DataService YearRepair = x.YearRepair }).Single(); } + public async Task DeleteAsync(int? Id) + { + var busStop = await _context.BusStop.SingleOrDefaultAsync(x => x.BusStopId == Id); + _context.BusStop.Remove(busStop); + return await _context.SaveChangesAsync(); + } } } \ No newline at end of file diff --git a/src/MapsDb/Interfaces/IBusStopDs.cs b/src/MapsDb/Interfaces/IBusStopDs.cs index 1353e52..531e66e 100644 --- a/src/MapsDb/Interfaces/IBusStopDs.cs +++ b/src/MapsDb/Interfaces/IBusStopDs.cs @@ -9,5 +9,6 @@ namespace MapsDb.Interfaces Task> GetIndexListAsync(); Task SaveAsync(BusStop busStop); Task FindOneDetailsAsync(int Id); + Task DeleteAsync(int? Id); } } \ No newline at end of file -- libgit2 0.21.4