Пример #1
0
        public HttpResponseMessage UpdateDictionaryItem(DictionarySearchItem updatedItem)
        {
            int    langId = Int32.Parse(updatedItem.Id);
            string key    = updatedItem.Key;
            string value  = updatedItem.Value;
            var    ls     = Services.LocalizationService;

            ILanguage lang = ls.GetLanguageById(langId);

            if (lang == null)
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound));
            }
            if (!ls.DictionaryItemExists(key))
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound));
            }

            var dicItem = ls.GetDictionaryItemByKey(key);

            foreach (var dicTran in dicItem.Translations)
            {
                if (dicTran.Language.Id == lang.Id)
                {
                    dicTran.Value = value;
                }
            }

            ls.Save(dicItem);


            return(new HttpResponseMessage(System.Net.HttpStatusCode.OK));
        }
        public HttpResponseMessage UpdateDictionaryItem(DictionarySearchItem updatedItem)
        {

            int langId = Int32.Parse(updatedItem.Id);
            string key = updatedItem.Key;
            string value = updatedItem.Value;
              var ls = Services.LocalizationService;

            ILanguage lang = ls.GetLanguageById(langId);
            if (lang == null){
                   return new HttpResponseMessage(System.Net.HttpStatusCode.NotFound);
            }
            if (!ls.DictionaryItemExists(key))
            {
                return new HttpResponseMessage(System.Net.HttpStatusCode.NotFound);
            }
      
            var dicItem = ls.GetDictionaryItemByKey(key);

            foreach(var dicTran in dicItem.Translations){
                if (dicTran.Language.Id == lang.Id ){
           
                    dicTran.Value = value;
                }
            }
 
            ls.Save(dicItem);
    
       
            return new HttpResponseMessage(System.Net.HttpStatusCode.OK);
        }