public async Task <ActionResult <Shared.Word> > PutWord(string text, Shared.Word word) { if (text != word.Text) { return(BadRequest()); } var newWord = _mapper.Map <Domain.Word>(word); _context.Entry(newWord).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WordExists(text)) { return(NotFound()); } else { throw; } } return(_mapper.Map <Shared.Word>(newWord)); }
public async Task <ActionResult <Word> > PostWord(Shared.Word word) { var newWord = new Domain.Word() { Text = word.Text }; _context.Word.Add(newWord); await _context.SaveChangesAsync(); return(CreatedAtAction("GetWord", new { text = word.Text }, _mapper.Map <Shared.Word>(newWord))); }