// PUT api/Translation/5 public async Task <IHttpActionResult> PutTranslation(int id, TranslationDto translationDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = translationDto.ToEntity(); if (entity == null) { return(BadRequest()); } entity.Id = id; db.Entry(entity).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TranslationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// PUT api/Word/5 public async Task <IHttpActionResult> PutWord(int id, Word word) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != word.Id) { return(BadRequest()); } db.Entry(word).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WordExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }