コード例 #1
0
        public async Task <ActionResult <ChargingPoint> > PostChargingPoint(ChargingPoint chargingPoint)
        {
            _context.ChargingPoints.Add(chargingPoint);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChargingPoint", new { id = chargingPoint.Id }, chargingPoint));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ChargingPoint chargingPoint = db.ChargingPoints.Find(id);

            db.ChargingPoints.Remove(chargingPoint);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 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));
 }
コード例 #5
0
        // 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));
        }
コード例 #6
0
        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());
        }