public async Task <ActionResult <ChargingPoint> > PostChargingPoint(ChargingPoint chargingPoint) { _context.ChargingPoints.Add(chargingPoint); await _context.SaveChangesAsync(); return(CreatedAtAction("GetChargingPoint", new { id = chargingPoint.Id }, chargingPoint)); }
public async Task <IActionResult> PutChargingPoint(int id, ChargingPoint chargingPoint) { if (id != chargingPoint.Id) { return(BadRequest()); } _context.Entry(chargingPoint).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChargingPointExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { ChargingPoint chargingPoint = db.ChargingPoints.Find(id); db.ChargingPoints.Remove(chargingPoint); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Status")] ChargingPoint chargingPoint) { if (ModelState.IsValid) { db.Entry(chargingPoint).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chargingPoint)); }
// GET: ChargingPoints/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChargingPoint chargingPoint = db.ChargingPoints.Find(id); if (chargingPoint == null) { return(HttpNotFound()); } return(View(chargingPoint)); }
public ActionResult Create(int ChargingModeId, int StationId) { if (ModelState.IsValid) { var chargingMode = db.ChargingModes.Where(e => e.Id == ChargingModeId).FirstOrDefault(); var station = db.Stations.Where(e => e.Id == StationId).FirstOrDefault(); var chargingPoint = new ChargingPoint(); chargingPoint.Status = "On"; chargingPoint.Station = station; chargingPoint.ChargingModes.Add(chargingMode); db.ChargingPoints.Add(chargingPoint); db.SaveChanges(); return(RedirectToAction("Index", "Stations", new { sucess = 1 })); } return(View()); }