public JsonResult Create(LocalizationViewModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") })); } var toCreate = new Models.LocalizationModel() { Key = model.Key, Value = model.Value, Culture = model.Culture, LastModDate = DateTime.Now, ModUser = User.Identity.Name, TranslationStatus = Enums.EnumTranslationStatus.Undefined, WasHit = false }; try { var dbobj = localizationRepository.Create(toCreate, User.Identity.Name); db.SaveChanges(); return(Json(new { Result = "OK", Record = dbobj.ToLocalizationViewModel() })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public static ViewModels.LocalizationViewModel ToLocalizationViewModel(this Models.LocalizationModel model) { return(new LocalizationViewModel() { Culture = model.Culture, Key = model.Key, LastModDate = model.LastModDate, ModUser = model.ModUser, TranslationStatus = model.TranslationStatus, Id = model.ID, Value = model.Value, WasHit = model.WasHit }); }
public Models.LocalizationModel Update(Models.LocalizationModel model, string ModUser) { var freshObj = db.Localization.FirstOrDefault(ln => ln.ID == model.ID); freshObj.Culture = model.Culture; freshObj.Key = model.Key; freshObj.Value = model.Value; freshObj.LastModDate = DateTime.Now; freshObj.ModUser = ModUser; freshObj.TranslationStatus = Enums.EnumTranslationStatus.Approved; freshObj.WasHit = false; db.SaveChanges(); return(freshObj); }
public Models.LocalizationModel Create(Models.LocalizationModel model, string ModUser) { var dbobj = db.Localization.Add(new Models.LocalizationModel() { Key = model.Key, Value = model.Value, Culture = model.Culture, LastModDate = DateTime.Now, ModUser = ModUser, TranslationStatus = Enums.EnumTranslationStatus.Undefined, WasHit = false }); db.SaveChanges(); return(dbobj); }
public string GetResourceValueFromDb(string sKey) { string resourceValue = string.Empty; string culture = Utils.CultureHelper.GetImplementedCulture(CultureInfo.CurrentCulture.Name); if (instance.cache.ContainsKey(buildCacheKey(sKey, culture))) { instance.cache.TryGetValue(buildCacheKey(sKey, culture), out resourceValue); } else { db = new DAL.ServiceContext(); Models.LocalizationModel localization = db.Localization.FirstOrDefault(l => l.Key == sKey && l.Culture == culture); resourceValue = localization != null ? localization.Value : string.Format("{0}(!!)", sKey); instance.cache.Add(buildCacheKey(sKey, culture), resourceValue); if (localization != null && localization.WasHit == false) { localization.WasHit = true; db.SaveChanges(); } } return(resourceValue); }