public IActionResult PutExpertLevel([FromRoute] int id, [FromBody] ExpertLevel expertLevel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != expertLevel.Id) { return(BadRequest()); } _context.Entry(expertLevel).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(Ok(String.Format("Expert level {0} updated successfully.", expertLevel.Level))); }
public async Task <IActionResult> PostExpertLevel([FromBody] ExpertLevel expertLevel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ExpertLevels.Add(expertLevel); await _context.SaveChangesAsync(); return(Ok(String.Format("Expert level {0} created successfully.", expertLevel.Level))); }