public WebText GetTranslation(WebText webText, string targetLang)
 {
     var wText = new WebText
     {
         View = webText.View,
         Lang = targetLang,
         Name = webText.Name,
         HtmlText = "Översatt Text " + targetLang + "??????" + webText.Name,
         Translator = "Bing"
     };
     return wText;
 }
 public override void DealWithIt(string name, string defaultText)
 {
     //TODO: move this to repository and if exist make an update instead. Change to Upsert?
     //Check if it exist. It is possible that two keys are on same page and they are
     if (_webTextRepo.WebTextExist(name: name, viewName: ViewKey, lang: DEFAULT_LANG)) return;
     var missingWebText = new WebText(translator: "MissingWebTextFixer")
         {
             View = ViewKey,
             Name = name,
             HtmlText = defaultText,
             Lang = DEFAULT_LANG
         };
     _webTextRepo.AddWebText(missingWebText);
 }
 public ActionResult Create( string view,string name,string targetLang,FormCollection values)
 {
     WebText tLWebText = new WebText();
     try
     {
         // TODO: Add insert logic here
         tLWebText.HtmlText = values["TargetLang.HtmlText"];
         tLWebText.Translator = values["TargetLang.Translator"];
         tLWebText.Comment = values["TargetLang.Comment"];
         tLWebText.Lang = targetLang;
         tLWebText.Name = name;
         tLWebText.View = view;
         this.WebTextRepo.StoreWebText(tLWebText);
         // http://localhost:52332/home/index/sv/translate/en
         // url: "{controllername}/{actionname}/{langname}/translate/{fromlang}",
         return RedirectToAction("Index", new { controllername = view, actionname="index",langname=targetLang,fromLang="en" });
     }
     catch
     {
         return View();
     }
 }
        public WebText Get([FromBody] WebText webText,[FromUri] string targetLang)
        {
            var fum = "foo";
            // string targetLang = "sv";
            var wText = new WebText
            {
                View = webText.View,
                Lang = targetLang,
                Name = webText.Name,
                HtmlText = "Översatt Text " + targetLang + " 赤春の花の木 " + webText.Name,
                Translator = "Bing"
            };
            return wText;
            /*
             {
               "WebText": {
               "View": "home",
               "Lang": "ja",
               "Name": "Welcome",
               "HtmlText": "Översatt Text 赤春の花の木",
               "Translator": "Bing"
               },
               "targetLang": "sv"
             * {
            "Id": "0",
            "View": "home",
            "Name": "Welcome",
            "Lang": "ja",
            "HtmlText": "Översatt Text ja赤春の花の木home",
            "Comment": null,
            "CreationTime": "2013-10-08T21:44:32.4214516Z",
            "Translator": "Bing"
            }
            }

             */
        }
 public void UpdateWebText(WebText tLWebText)
 {
     using (RavenSession)
     {
         Debug.Assert(RavenSession != null, "RavenSession != null");
         Debug.Assert(tLWebText != null, "webText != null");
         tLWebText.CreationTime = DateTime.Now;
         tLWebText.Translator = tLWebText.Translator ?? "Unknown";
         RavenSession.Store(tLWebText);
         RavenSession.SaveChanges();
     }
 }
 public void AddWebText(WebText webText)
 {
     RavenSession.Store(webText);
     RavenSession.SaveChanges();
 }
 public void AddWebText(WebText webText)
 {
     throw new NotImplementedException();
 }
 public void UpdateWebText(WebText tLWebText)
 {
     throw new NotImplementedException();
 }
        public ActionResult Edit(string view, string name, string targetLang, string targetLangId, FormCollection values)
        {
            WebText tLWebText = new WebText();
            try
            {
                tLWebText.HtmlText = values["TargetLang.HtmlText"];
                tLWebText.Translator = values["TargetLang.Translator"];
                tLWebText.Comment = values["TargetLang.Comment"];
                tLWebText.Lang = targetLang;
                tLWebText.View = view;
                tLWebText.Name = name;
                tLWebText.Id = targetLangId;

                this.WebTextRepo.UpdateWebText(tLWebText);

                return RedirectToAction("Index", new { controllername = view, actionname = "index", langname = targetLang, fromLang = "en" });
            }
            catch
            {
                return View();
            }
        }
 public WebText GetTranslation(WebText webText,  string targetLang)
 {
     throw new NotImplementedException();
 }