public async Task <IActionResult> PostEditAccelerationModeApi(int id, [FromBody] AccelerationMode AccelerationMode) { if (ModelState.IsValid) { try { AccelerationMode.AccelerationModeId = id; _context.Update(AccelerationMode); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccelerationModeExists(AccelerationMode.AccelerationModeId)) { return(NotFound()); } else { throw; } } return(Json("Success")); } return(Json("Fail")); }
public async Task <IActionResult> Edit(int id, [Bind("AccelerationModeId,Capacity,Type,Price,Weight,RunningCost,Range")] AccelerationMode accelerationMode) { if (id != accelerationMode.AccelerationModeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(accelerationMode); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccelerationModeExists(accelerationMode.AccelerationModeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(accelerationMode)); }
// [FromBody]dynamic AccelerationMode public async Task <IActionResult> PostAddAccelerationModeApi([FromBody] AccelerationMode AccelerationMode) { Console.WriteLine(AccelerationMode); _context.Add(AccelerationMode); await _context.SaveChangesAsync(); // return Json(_context.AccelerationMode.Single(a => a.Capacity == AccelerationMode.Capacity)); return(Json("Success")); }
public async Task <IActionResult> Create([Bind("AccelerationModeId,Capacity,Type,Price,Weight,RunningCost,Range")] AccelerationMode accelerationMode) { if (ModelState.IsValid) { _context.Add(accelerationMode); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(accelerationMode)); }