public async Task <IActionResult> PutElearning([FromRoute] int id, [FromBody] Elearning elearning) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != elearning.Id) { return(BadRequest()); } _context.Entry(elearning).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ElearningExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostElearning([FromBody] Elearning elearning) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Elearning.Add(elearning); await _context.SaveChangesAsync(); return(CreatedAtAction("GetElearning", new { id = elearning.Id }, elearning)); }