public async Task <IHttpActionResult> PutVocabulary(int id, Vocabulary item) { VocabularyBL vocabularyBL = new VocabularyBL(_context); if (!id.Equals(item.vocaID)) { return(BadRequest()); } else if (!vocabularyBL.VocabularyExists(id)) { var ItemId = await vocabularyBL.CreateNewVocabulary(item); if (ItemId == null) { return(InternalServerError()); } return(Created(Request.RequestUri, item)); } var isUpdated = await vocabularyBL.UpdateVocabulary(item); if (isUpdated == false) { return(InternalServerError()); } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostVocabulary(Vocabulary item) { VocabularyBL vocabularyBL = new VocabularyBL(_context); var Id = await vocabularyBL.CreateNewVocabulary(item); if (Id == null) { return(InternalServerError()); } return(Created(String.Format("{0}/{1}", Request.RequestUri, Id), item)); }