public async Task <IActionResult> Post([FromBody] Models.Plane nPlane) { if (ModelState.IsValid) { var newPlane = await uow.Planes.Create(nPlane).ConfigureAwait(false); return(Ok(newPlane)); } return(BadRequest()); }
public async Task <IActionResult> Put([FromBody] Models.Plane nPlane, int id) { if (ModelState.IsValid) { if (id == nPlane?.PlaneId) { await uow.Planes.Update(nPlane).ConfigureAwait(false); return(Ok()); } } return(BadRequest()); }
public ActionResult Update(Models.Plane plane) { var planeInDb = _dbContext.Planes.SingleOrDefault(v => v.ID == plane.ID); if (planeInDb == null) { return(HttpNotFound()); } planeInDb.Name = plane.Name; planeInDb.Description = plane.Description; planeInDb.Stock = plane.Stock; _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Add(Models.Plane plane) { _dbContext.Planes.Add(plane); _dbContext.SaveChanges(); return(RedirectToAction("Index")); }