public HttpResponseMessage Put(int id, Word updated)
 {
     try
     {
         InitializeUserId();
         var repo = _unity.GetRepository<Word>();
         repo.Update(updated);
         _unity.Commit();
         return GenerateMessage(updated);
     }
     catch (Exception ex)
     {
         MvcApplication.Logger.Error("Error occurred while delete revenue", ex);
         return new HttpResponseMessage(HttpStatusCode.ExpectationFailed);
     }
 }
 private HttpResponseMessage GenerateMessage(Word word)
 {
     var resp = new HttpResponseMessage(HttpStatusCode.Created);
     resp.Content = new StringContent(word.UserId.ToString());
     resp.Headers.Location = new Uri(Url.Link("DefaultApi", new { action = "get", id = word.Id }));
     return resp;
 }
        public HttpResponseMessage PostComlex(Word newWord)
        {
            if (newWord == null)
                throw new HttpResponseException(HttpStatusCode.BadRequest);

            try
            {
                InitializeUserId();

                if (newWord.UserId <= 0 && _userId > 0)
                    newWord.UserId = _userId;

                var repo = _unity.GetRepository<Word>();
                repo.Add(newWord);
                _unity.Commit();

                var found = repo.FindSingle(x => x.UserId == newWord.UserId && x.ForeignWord.Equals(newWord.ForeignWord, StringComparison.OrdinalIgnoreCase)
                                && x.Translation.Equals(newWord.Translation, StringComparison.OrdinalIgnoreCase)
                                && x.Complicated == newWord.Complicated);
                if (found != null)
                    return GenerateMessage(found);

                return new HttpResponseMessage(HttpStatusCode.InternalServerError);
            }
            catch (Exception ex)
            {
                MvcApplication.Logger.Error("GetAll", ex);
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }