Commit 1b4d46a3e05240b99a964023eeece9afcd8bc3b4
pull on code first
Showing
3 changed files
with
52 additions
and
0 deletions
Show diff stats
src/Maps/Controllers/BusStopController.cs
| @@ -7,6 +7,8 @@ using MapsDb; | @@ -7,6 +7,8 @@ using MapsDb; | ||
| 7 | using MapsDb.Interfaces; | 7 | using MapsDb.Interfaces; |
| 8 | using MapsDb.DataService; | 8 | using MapsDb.DataService; |
| 9 | using MapsModels.ViewModels; | 9 | using MapsModels.ViewModels; |
| 10 | +using System; | ||
| 11 | + | ||
| 10 | namespace Maps.Controllers | 12 | namespace Maps.Controllers |
| 11 | { | 13 | { |
| 12 | public class BusStopController : Controller | 14 | public class BusStopController : Controller |
| @@ -83,6 +85,7 @@ namespace Maps.Controllers | @@ -83,6 +85,7 @@ namespace Maps.Controllers | ||
| 83 | return Json(vm); | 85 | return Json(vm); |
| 84 | } | 86 | } |
| 85 | 87 | ||
| 88 | +<<<<<<< HEAD | ||
| 86 | // POST: BusStop/Create | 89 | // POST: BusStop/Create |
| 87 | // To protect from overposting attacks, please enable the specific properties you want to bind to, for | 90 | // To protect from overposting attacks, please enable the specific properties you want to bind to, for |
| 88 | // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | 91 | // more details see http://go.microsoft.com/fwlink/?LinkId=317598. |
| @@ -103,6 +106,47 @@ namespace Maps.Controllers | @@ -103,6 +106,47 @@ namespace Maps.Controllers | ||
| 103 | ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | 106 | ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); |
| 104 | return View(busStop); | 107 | return View(busStop); |
| 105 | } | 108 | } |
| 109 | +======= | ||
| 110 | + [HttpDelete] | ||
| 111 | + public async Task<IActionResult> Delete(int? id) | ||
| 112 | + { | ||
| 113 | + if (id == null) | ||
| 114 | + { | ||
| 115 | + return NotFound(); | ||
| 116 | + } | ||
| 117 | + int busStop; | ||
| 118 | + try | ||
| 119 | + { | ||
| 120 | + busStop = await _busStopDs.DeleteAsync(id); | ||
| 121 | + } | ||
| 122 | + catch (ArgumentNullException e) | ||
| 123 | + { | ||
| 124 | + return NotFound(); | ||
| 125 | + } | ||
| 126 | + return Json(busStop); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + // // POST: BusStop/Create | ||
| 130 | + // // To protect from overposting attacks, please enable the specific properties you want to bind to, for | ||
| 131 | + // // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | ||
| 132 | + // [HttpPost] | ||
| 133 | + // [ValidateAntiForgeryToken] | ||
| 134 | + // public async Task<IActionResult> Create([Bind("BusStopId,AreaLandAvailability,AreaStopAvailability,BalanceCost,BusStationCardId,CrossSectionNumber,DateActual,LocationLeft,LocationRight,PocketAvailability,Position,RegionId,RepairCertificate,RoadId,SettlementId,StateCommonId,SurfaceTypeId,ToiletAvailability,YearBuild,YearRepair")] BusStop busStop) | ||
| 135 | + // { | ||
| 136 | + // if (ModelState.IsValid) | ||
| 137 | + // { | ||
| 138 | + // _context.Add(busStop); | ||
| 139 | + // await _context.SaveChangesAsync(); | ||
| 140 | + // return RedirectToAction("Index"); | ||
| 141 | + // } | ||
| 142 | + // ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | ||
| 143 | + // ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | ||
| 144 | + // ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | ||
| 145 | + // ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | ||
| 146 | + // ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | ||
| 147 | + // return View(busStop); | ||
| 148 | + // } | ||
| 149 | +>>>>>>> 94ffda14065b6ab5d25c52ed714e112165a70cae | ||
| 106 | 150 | ||
| 107 | // // GET: BusStop/Edit/5 | 151 | // // GET: BusStop/Edit/5 |
| 108 | // public async Task<IActionResult> Edit(int? id) | 152 | // public async Task<IActionResult> Edit(int? id) |
src/MapsDb/DataService/BusStopDs.cs
| @@ -4,6 +4,7 @@ using System.Threading.Tasks; | @@ -4,6 +4,7 @@ using System.Threading.Tasks; | ||
| 4 | using MapsDb.Interfaces; | 4 | using MapsDb.Interfaces; |
| 5 | using MapsDb.Models; | 5 | using MapsDb.Models; |
| 6 | using MapsModels.DsModels; | 6 | using MapsModels.DsModels; |
| 7 | +using Microsoft.EntityFrameworkCore; | ||
| 7 | 8 | ||
| 8 | namespace MapsDb.DataService | 9 | namespace MapsDb.DataService |
| 9 | { | 10 | { |
| @@ -64,5 +65,11 @@ namespace MapsDb.DataService | @@ -64,5 +65,11 @@ namespace MapsDb.DataService | ||
| 64 | YearRepair = x.YearRepair | 65 | YearRepair = x.YearRepair |
| 65 | }).Single(); | 66 | }).Single(); |
| 66 | } | 67 | } |
| 68 | + public async Task<int> DeleteAsync(int? Id) | ||
| 69 | + { | ||
| 70 | + var busStop = await _context.BusStop.SingleOrDefaultAsync(x => x.BusStopId == Id); | ||
| 71 | + _context.BusStop.Remove(busStop); | ||
| 72 | + return await _context.SaveChangesAsync(); | ||
| 73 | + } | ||
| 67 | } | 74 | } |
| 68 | } | 75 | } |
| 69 | \ No newline at end of file | 76 | \ No newline at end of file |
src/MapsDb/Interfaces/IBusStopDs.cs
| @@ -9,5 +9,6 @@ namespace MapsDb.Interfaces | @@ -9,5 +9,6 @@ namespace MapsDb.Interfaces | ||
| 9 | Task<IList<BusStopListDsM>> GetIndexListAsync(); | 9 | Task<IList<BusStopListDsM>> GetIndexListAsync(); |
| 10 | Task SaveAsync(BusStop busStop); | 10 | Task SaveAsync(BusStop busStop); |
| 11 | Task<BusStopDetailsDsM> FindOneDetailsAsync(int Id); | 11 | Task<BusStopDetailsDsM> FindOneDetailsAsync(int Id); |
| 12 | + Task<int> DeleteAsync(int? Id); | ||
| 12 | } | 13 | } |
| 13 | } | 14 | } |
| 14 | \ No newline at end of file | 15 | \ No newline at end of file |