Commit 44582203488667fabf9d1f1e463613685a5d902b
1 parent
32912d0b
bag fix
Showing
2 changed files
with
143 additions
and
140 deletions
Show diff stats
src/Maps/Controllers/BusStopController.cs
| ... | ... | @@ -33,143 +33,146 @@ namespace Maps.Controllers |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | - // GET: BusStop/Details/5 | |
| 37 | - public async Task<IActionResult> Details(int id) | |
| 38 | - { | |
| 39 | - | |
| 40 | - var busStop = await _busStopDs.FindOneDetailsAsync(id); | |
| 41 | - if (busStop == null) | |
| 42 | - { | |
| 43 | - return NotFound(); | |
| 44 | - } | |
| 45 | - | |
| 46 | - return View(busStop); | |
| 47 | - } | |
| 48 | - | |
| 49 | - // GET: BusStop/Create | |
| 50 | - public IActionResult Create() | |
| 51 | - { | |
| 52 | - ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId"); | |
| 53 | - ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "Name"); | |
| 54 | - ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name"); | |
| 55 | - ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "Value"); | |
| 56 | - ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "Name"); | |
| 57 | - return View(); | |
| 58 | - } | |
| 59 | - | |
| 60 | - // POST: BusStop/Create | |
| 61 | - // To protect from overposting attacks, please enable the specific properties you want to bind to, for | |
| 62 | - // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | |
| 63 | - [HttpPost] | |
| 64 | - [ValidateAntiForgeryToken] | |
| 65 | - 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) | |
| 66 | - { | |
| 67 | - if (ModelState.IsValid) | |
| 68 | - { | |
| 69 | - _context.Add(busStop); | |
| 70 | - await _context.SaveChangesAsync(); | |
| 71 | - return RedirectToAction("Index"); | |
| 72 | - } | |
| 73 | - ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 74 | - ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 75 | - ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 76 | - ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 77 | - ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 78 | - return View(busStop); | |
| 79 | - } | |
| 80 | - | |
| 81 | - // GET: BusStop/Edit/5 | |
| 82 | - public async Task<IActionResult> Edit(int? id) | |
| 83 | - { | |
| 84 | - if (id == null) | |
| 85 | - { | |
| 86 | - return NotFound(); | |
| 87 | - } | |
| 88 | - | |
| 89 | - var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 90 | - if (busStop == null) | |
| 91 | - { | |
| 92 | - return NotFound(); | |
| 93 | - } | |
| 94 | - ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 95 | - ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 96 | - ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 97 | - ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 98 | - ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 99 | - return View(busStop); | |
| 100 | - } | |
| 101 | - | |
| 102 | - // POST: BusStop/Edit/5 | |
| 103 | - // To protect from overposting attacks, please enable the specific properties you want to bind to, for | |
| 104 | - // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | |
| 105 | - [HttpPost] | |
| 106 | - [ValidateAntiForgeryToken] | |
| 107 | - public async Task<IActionResult> Edit(int id, [Bind("BusStopId,AreaLandAvailability,AreaStopAvailability,BalanceCost,BusStationCardId,CrossSectionNumber,DateActual,LocationLeft,LocationRight,PocketAvailability,Position,RegionId,RepairCertificate,RoadId,SettlementId,StateCommonId,SurfaceTypeId,ToiletAvailability,YearBuild,YearRepair")] BusStop busStop) | |
| 108 | - { | |
| 109 | - if (id != busStop.BusStopId) | |
| 110 | - { | |
| 111 | - return NotFound(); | |
| 112 | - } | |
| 113 | - | |
| 114 | - if (ModelState.IsValid) | |
| 115 | - { | |
| 116 | - try | |
| 117 | - { | |
| 118 | - _context.Update(busStop); | |
| 119 | - await _context.SaveChangesAsync(); | |
| 120 | - } | |
| 121 | - catch (DbUpdateConcurrencyException) | |
| 122 | - { | |
| 123 | - if (!BusStopExists(busStop.BusStopId)) | |
| 124 | - { | |
| 125 | - return NotFound(); | |
| 126 | - } | |
| 127 | - else | |
| 128 | - { | |
| 129 | - throw; | |
| 130 | - } | |
| 131 | - } | |
| 132 | - return RedirectToAction("Index"); | |
| 133 | - } | |
| 134 | - ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 135 | - ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 136 | - ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 137 | - ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 138 | - ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 139 | - return View(busStop); | |
| 140 | - } | |
| 141 | - | |
| 142 | - // GET: BusStop/Delete/5 | |
| 143 | - public async Task<IActionResult> Delete(int? id) | |
| 144 | - { | |
| 145 | - if (id == null) | |
| 146 | - { | |
| 147 | - return NotFound(); | |
| 148 | - } | |
| 149 | - | |
| 150 | - var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 151 | - if (busStop == null) | |
| 152 | - { | |
| 153 | - return NotFound(); | |
| 154 | - } | |
| 155 | - | |
| 156 | - return View(busStop); | |
| 157 | - } | |
| 158 | - | |
| 159 | - // POST: BusStop/Delete/5 | |
| 160 | - [HttpPost, ActionName("Delete")] | |
| 161 | - [ValidateAntiForgeryToken] | |
| 162 | - public async Task<IActionResult> DeleteConfirmed(int id) | |
| 163 | - { | |
| 164 | - var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 165 | - _context.BusStop.Remove(busStop); | |
| 166 | - await _context.SaveChangesAsync(); | |
| 167 | - return RedirectToAction("Index"); | |
| 168 | - } | |
| 169 | - | |
| 170 | - private bool BusStopExists(int id) | |
| 171 | - { | |
| 172 | - return _context.BusStop.Any(e => e.BusStopId == id); | |
| 173 | - } | |
| 36 | + // // GET: BusStop/Details/5 | |
| 37 | + // public async Task<IActionResult> Details(int id) | |
| 38 | + // { | |
| 39 | + | |
| 40 | + // var busStop = await _busStopDs.FindOneDetailsAsync(id); | |
| 41 | + // if (busStop == null) | |
| 42 | + // { | |
| 43 | + // return NotFound(); | |
| 44 | + // } | |
| 45 | + // DetailsBusStopVm vm = new DetailsBusStopVm | |
| 46 | + // { | |
| 47 | + // BusStopDetailsDs = busStop | |
| 48 | + // }; | |
| 49 | + // return Json(vm); | |
| 50 | + // } | |
| 51 | + | |
| 52 | + // // GET: BusStop/Create | |
| 53 | + // public IActionResult Create() | |
| 54 | + // { | |
| 55 | + // ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId"); | |
| 56 | + // ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "Name"); | |
| 57 | + // ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name"); | |
| 58 | + // ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "Value"); | |
| 59 | + // ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "Name"); | |
| 60 | + // return View(); | |
| 61 | + // } | |
| 62 | + | |
| 63 | + // // POST: BusStop/Create | |
| 64 | + // // To protect from overposting attacks, please enable the specific properties you want to bind to, for | |
| 65 | + // // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | |
| 66 | + // [HttpPost] | |
| 67 | + // [ValidateAntiForgeryToken] | |
| 68 | + // 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) | |
| 69 | + // { | |
| 70 | + // if (ModelState.IsValid) | |
| 71 | + // { | |
| 72 | + // _context.Add(busStop); | |
| 73 | + // await _context.SaveChangesAsync(); | |
| 74 | + // return RedirectToAction("Index"); | |
| 75 | + // } | |
| 76 | + // ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 77 | + // ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 78 | + // ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 79 | + // ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 80 | + // ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 81 | + // return View(busStop); | |
| 82 | + // } | |
| 83 | + | |
| 84 | + // // GET: BusStop/Edit/5 | |
| 85 | + // public async Task<IActionResult> Edit(int? id) | |
| 86 | + // { | |
| 87 | + // if (id == null) | |
| 88 | + // { | |
| 89 | + // return NotFound(); | |
| 90 | + // } | |
| 91 | + | |
| 92 | + // var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 93 | + // if (busStop == null) | |
| 94 | + // { | |
| 95 | + // return NotFound(); | |
| 96 | + // } | |
| 97 | + // ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 98 | + // ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 99 | + // ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 100 | + // ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 101 | + // ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 102 | + // return View(busStop); | |
| 103 | + // } | |
| 104 | + | |
| 105 | + // // POST: BusStop/Edit/5 | |
| 106 | + // // To protect from overposting attacks, please enable the specific properties you want to bind to, for | |
| 107 | + // // more details see http://go.microsoft.com/fwlink/?LinkId=317598. | |
| 108 | + // [HttpPost] | |
| 109 | + // [ValidateAntiForgeryToken] | |
| 110 | + // public async Task<IActionResult> Edit(int id, [Bind("BusStopId,AreaLandAvailability,AreaStopAvailability,BalanceCost,BusStationCardId,CrossSectionNumber,DateActual,LocationLeft,LocationRight,PocketAvailability,Position,RegionId,RepairCertificate,RoadId,SettlementId,StateCommonId,SurfaceTypeId,ToiletAvailability,YearBuild,YearRepair")] BusStop busStop) | |
| 111 | + // { | |
| 112 | + // if (id != busStop.BusStopId) | |
| 113 | + // { | |
| 114 | + // return NotFound(); | |
| 115 | + // } | |
| 116 | + | |
| 117 | + // if (ModelState.IsValid) | |
| 118 | + // { | |
| 119 | + // try | |
| 120 | + // { | |
| 121 | + // _context.Update(busStop); | |
| 122 | + // await _context.SaveChangesAsync(); | |
| 123 | + // } | |
| 124 | + // catch (DbUpdateConcurrencyException) | |
| 125 | + // { | |
| 126 | + // if (!BusStopExists(busStop.BusStopId)) | |
| 127 | + // { | |
| 128 | + // return NotFound(); | |
| 129 | + // } | |
| 130 | + // else | |
| 131 | + // { | |
| 132 | + // throw; | |
| 133 | + // } | |
| 134 | + // } | |
| 135 | + // return RedirectToAction("Index"); | |
| 136 | + // } | |
| 137 | + // ViewData["RegionId"] = new SelectList(_context.Region, "RegionId", "RegionId", busStop.RegionId); | |
| 138 | + // ViewData["RoadId"] = new SelectList(_context.Road, "RoadId", "RoadId", busStop.RoadId); | |
| 139 | + // ViewData["SettlementId"] = new SelectList(_context.Settlement, "SettlementId", "Name", busStop.SettlementId); | |
| 140 | + // ViewData["StateCommonId"] = new SelectList(_context.StateCommon, "StateCommonId", "StateCommonId", busStop.StateCommonId); | |
| 141 | + // ViewData["SurfaceTypeId"] = new SelectList(_context.SurfaceType, "SurfaceTypeId", "SurfaceTypeId", busStop.SurfaceTypeId); | |
| 142 | + // return View(busStop); | |
| 143 | + // } | |
| 144 | + | |
| 145 | + // // GET: BusStop/Delete/5 | |
| 146 | + // public async Task<IActionResult> Delete(int? id) | |
| 147 | + // { | |
| 148 | + // if (id == null) | |
| 149 | + // { | |
| 150 | + // return NotFound(); | |
| 151 | + // } | |
| 152 | + | |
| 153 | + // var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 154 | + // if (busStop == null) | |
| 155 | + // { | |
| 156 | + // return NotFound(); | |
| 157 | + // } | |
| 158 | + | |
| 159 | + // return View(busStop); | |
| 160 | + // } | |
| 161 | + | |
| 162 | + // // POST: BusStop/Delete/5 | |
| 163 | + // [HttpPost, ActionName("Delete")] | |
| 164 | + // [ValidateAntiForgeryToken] | |
| 165 | + // public async Task<IActionResult> DeleteConfirmed(int id) | |
| 166 | + // { | |
| 167 | + // var busStop = await _context.BusStop.SingleOrDefaultAsync(m => m.BusStopId == id); | |
| 168 | + // _context.BusStop.Remove(busStop); | |
| 169 | + // await _context.SaveChangesAsync(); | |
| 170 | + // return RedirectToAction("Index"); | |
| 171 | + // } | |
| 172 | + | |
| 173 | + // private bool BusStopExists(int id) | |
| 174 | + // { | |
| 175 | + // return _context.BusStop.Any(e => e.BusStopId == id); | |
| 176 | + // } | |
| 174 | 177 | } |
| 175 | 178 | } | ... | ... |
src/MapsDb/DataService/BusStopDs.cs
| ... | ... | @@ -50,7 +50,7 @@ namespace MapsDb.DataService |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | public Task<BusStopDetailsDs> FindOneDetailsAsync(int Id){ |
| 53 | - return Task.Factory.StartNew(()=> { FindOneDetails(Id); }); | |
| 53 | + return Task.Factory.StartNew(()=> { return FindOneDetails(Id); }); | |
| 54 | 54 | } |
| 55 | 55 | private BusStopDetailsDs FindOneDetails(int Id){ |
| 56 | 56 | return _context.BusStop.Where(x => x.BusStopId == Id).Select(x => new BusStopDetailsDs{ |
| ... | ... | @@ -67,7 +67,7 @@ namespace MapsDb.DataService |
| 67 | 67 | ToiletAvailability = x.ToiletAvailability, |
| 68 | 68 | YearBuild = x.YearBuild, |
| 69 | 69 | YearRepair = x.YearRepair |
| 70 | - }); | |
| 70 | + }).Single(); | |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | \ No newline at end of file | ... | ... |