protected override ActionResult Update()
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var scope = new UnitOfWorkScope())
                    {
                        Localization currentLocalization = _repository.Get(Convert.ToInt32(GridModel.Id));

                        if (currentLocalization == null)
                        {
                            throw new DuplicateKeyException();
                        }
                        currentLocalization.SetValue(GridModel.Value);


                        _repository.Update(currentLocalization);
                        scope.Commit();
                    }
                    return(Json(GridModel));
                }
            }
            catch (DuplicateKeyException)
            {
                ModelState.AddModelError(string.Empty, string.Format("This type of Localization {0} already exists in the system.", GridModel.Key));
            }
            throw CreateModelException(GridModel);
        }
        public LocalizationEditModel GetLocalizationAsEditModel(Guid localizationId)
        {
            var entity = _repository.Get(localizationId);

            if (entity == null)
            {
                throw new Exception(LOCALIZATION_LOCALIZATIONCLASS_NOT_FOUND);
            }

            return(LocalizationMapper.MapToLocalizationEditModel(entity));
        }
Esempio n. 3
0
        public void ExportCsv()
        {
            var testGuid = Guid.NewGuid();

            var resourceKey1 = new LocaleResourceKey
            {
                DateAdded = DateTime.UtcNow,
                Id        = Guid.NewGuid(),
                Name      = "testKey1",
                Notes     = "test notes"
            };

            var resourceValue1 = new LocaleStringResource
            {
                LocaleResourceKey = resourceKey1,
                ResourceValue     = "testValue1"
            };

            var resourceKey2 = new LocaleResourceKey
            {
                DateAdded = DateTime.UtcNow,
                Id        = Guid.NewGuid(),
                Name      = "testKey2",
                Notes     = "test notes"
            };

            var resourceValue2 = new LocaleStringResource
            {
                LocaleResourceKey = resourceKey2,
                ResourceValue     = "testValue2"
            };

            var language = new Language {
                Id = testGuid, LanguageCulture = "en-GB", Name = "TestLanguage"
            };

            _localizationRepositorySub.AllLanguageResources(testGuid).Returns(new List <LocaleStringResource> {
                resourceValue1, resourceValue2
            });
            _localizationRepositorySub.Get(testGuid).Returns(language);

            var csv = _localizationService.ToCsv(language);

            Assert.AreEqual(csv, "testKey1,testValue1\r\ntestKey2,testValue2\r\n");
        }
Esempio n. 4
0
 /// <summary>
 /// Get an individual language
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Language Get(Guid id)
 {
     return(_localizationRepository.Get(id));
 }
Esempio n. 5
0
 /// <summary>
 /// Get an individual language
 /// </summary>
 /// <param name="id"></param>
 /// <param name="removeTracking"></param>
 /// <returns></returns>
 public Language Get(Guid id, bool removeTracking = false)
 {
     return(_localizationRepository.Get(id, removeTracking));
 }