Exemplo n.º 1
0
        public IActionResult Search(TranslateViewModel model)
        {
            Models.Translator dict        = new Models.Translator("dict.txt");
            string            translation = dict.Transalte(model.WordToTranslate.ToLower());
            var translaedWord             = new TranslateViewModel()
            {
                WordToTranslate = model.WordToTranslate, TranslatedWord = translation
            };

            if (String.IsNullOrEmpty(translation))
            {
                return(new NotFoundObjectResult(new { error = "Word not found", model.WordToTranslate })
                {
                    StatusCode = 404
                });
            }

            //return Content(translation);
            return(View("Translate", translaedWord));
        }
Exemplo n.º 2
0
        // GET:
        public IActionResult Translate(string id)
        {
            Models.Translator dict        = new Models.Translator("dict.txt");
            string            translation = dict.Transalte(id);
            var translaedWord             = new TranslateViewModel()
            {
                WordToTranslate = id, TranslatedWord = translation
            };

            if (String.IsNullOrEmpty(translation))
            {
                return(new NotFoundObjectResult(new { error = "Word not found", id })
                {
                    StatusCode = 404
                });
            }

            //return Content(translation);
            return(View(translaedWord));
        }