/* * The response is 204 (No Content). According to the HTTP specification, * a PUT request requires the client to send the entire updated entity, not just the changes. */ public async Task <IActionResult> PutRobot(int id, Robot robot) { if (id != robot.IdRobot) { return(BadRequest()); } _context.Entry(robot).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RobotExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <T> AddAsync(T entity) { _context.Set <T>().Add(entity); await _context.SaveChangesAsync(); return(entity); }
public async Task <ActionResult <RobotModel> > PostRobotModel() { RobotModel robot = CreateDefaultRobot(); _context.Robots.Add(robot); await _context.SaveChangesAsync(); return(CreatedAtAction("PostRobotModel", new { id = robot.Id }, robot)); }