public List <DetailsResponse> GetSynonyms(WordRequest model)
        {
            string path = "https://wordsapiv1.p.mashape.com/words/";
            var    key  = WebConfigurationManager.AppSettings["X-Mashape-Key"].ToString();
            var    host = WebConfigurationManager.AppSettings["X-Mashape-Host"].ToString();

            List <DetailsResponse> response = new List <DetailsResponse>();

            for (int i = 0; i < model.Word.Length; i++)
            {
                HttpWebRequest client = (HttpWebRequest)WebRequest.Create(path + model.Word[i] + "/synonyms");
                client.Method = "GET";
                // user agent
                client.Headers.Add("X-Mashape-Key", key);
                client.Accept = "application/json";

                //gets Response as a string
                string r = GetResponse(client);
                if (r != null)
                {
                    //this converts string to some JSON
                    var oResp = (DetailsResponse)deserialize(r, typeof(DetailsResponse));
                    response.Add(oResp);
                }
                else
                {
                    return(null);
                }
            }
            return(response);
        }
Exemplo n.º 2
0
        public IActionResult Largest(WordRequest request)
        {
            var phrase      = request.Phrase;
            var largestWord = retriever.Retrieve(phrase ?? "");

            return(View(new WordResponse {
                Word = largestWord
            }));
        }
Exemplo n.º 3
0
 public void TryProcessNext()
 {
     if (!isProcessing && requests.Count > 0)
     {
         currentWordRequest = requests.Dequeue();
         isProcessing       = true;
         StartCoroutine(ProcessRequests());
     }
 }
Exemplo n.º 4
0
 public ActionResult <WordResponse> FlipWord(WordRequest word)
 {
     try
     {
         var          returnedWord = _wordService.InternalArrayReverse(word);
         WordResponse response     = Mapper.Map <WordResponse>(returnedWord);
         return(new ActionResult <WordResponse>(response));
     }
     catch (Exception ex)
     {
         return(new ActionResult <WordResponse>(new WordResponse()));
     }
 }
Exemplo n.º 5
0
 //use a post to go and look up word in model
 public HttpResponseMessage Post(WordRequest model)
 {
     try
     {
         List <DetailsResponse> response = new List <DetailsResponse>();
         response = _wSS.GetSynonyms(model);
         return(Request.CreateResponse(HttpStatusCode.OK, response));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
        public string IterateReverse(WordRequest wordToReverse)
        {
            string str = wordToReverse.InitialWord.ToString(), reverse = "";
            int    Length = 0;

            Length = str.Length - 1;
            while (Length >= 0)
            {
                reverse = reverse + str[Length];
                Length--;
            }

            return(reverse);
        }
        public ActionResult Create(WordRequest r)
        {
            if (ModelState.IsValid)
            {
                string uid  = User.Identity.GetUserId();
                var    user = _uw.db.Users.Find(uid);
                r.Person = user;
                _uw.WordRequests.Add(r);
                _uw.Complete();
                return(RedirectToAction("Index"));
            }

            ViewBag.Langs = _uw.Languages.GetAll().Select(x => new SelectListItem
            {
                Text  = x.Name,
                Value = x.Id.ToString()
            });
            return(View(r));
        }
Exemplo n.º 8
0
        public BaseResponse KelimeEkle(WordRequest wordRequest)
        {
            var          user         = _kullaniciRepository.Find(x => x.KullaniciAdi == wordRequest.kullanici && x.isOKey == true);
            BaseResponse baseResponse = new BaseResponse();

            if (user != null)
            {
                Kelimeler kelimeler = new Kelimeler();
                kelimeler.Kelime         = wordRequest.kelime;
                kelimeler.KelimeAnlami   = wordRequest.anlami;
                kelimeler.isOKey         = false;
                kelimeler.KullanicilarId = user.Id;
                _kelimeRepository.Insert(kelimeler);
                baseResponse.isOkey  = true;
                baseResponse.message = "Kayıt Başarılı";
            }
            else
            {
                baseResponse.isOkey  = false;
                baseResponse.message = "Lütfen kullanıcı adınızı düzenledikten sonra kelime ekleyin";
            }

            return(baseResponse);
        }
        public IActionResult PostKelimeEkle(WordRequest wordRequest)
        {
            var users = _wordAppService.KelimeEkle(wordRequest);

            return(Ok(users));
        }
 public string InternalArrayReverse(WordRequest wordToReverse)
 {
     char[] charArray = wordToReverse.InitialWord.ToCharArray();
     Array.Reverse(charArray);
     return(new string(charArray));
 }