public ActionResult Translate(string culture, int id) { var category = _repository.Find(id); var compared = new CategoryModel(category); var translated = new CategoryModel { Id = category.Id }; var diff = new CategoryModel { Id = category.Id }; var translation = _translationStore.Find(CultureInfo.GetCultureInfo(culture), new EntityKey(typeof(Category), category.Id)); if (translation != null) { translated.Name = translation.GetTranslatedText("Name"); translated.Description = translation.GetTranslatedText("Description"); diff.Name = DiffHelper.GetDiffHtml(translation.GetOriginalText("Name"), category.Name); diff.Description = DiffHelper.GetDiffHtml(translation.GetOriginalText("Description"), category.Description); } ViewBag.Compared = compared; ViewBag.Difference = diff; return(View(translated)); }
public ActionResult Index(string culture, string search, int page = 1, int pageSize = 50) { var query = _brandService.Query(); if (!String.IsNullOrWhiteSpace(search)) { search = search.Trim(); query = query.Where(b => b.Name.Contains(search)); } var list = query.OrderByDescending(b => b.Id) .Paginate(page - 1, pageSize) .Transform(b => new BrandGridItemModel(b)) .ToPagedList(); var brands = list.ToList(); var brandKeys = brands.Select(x => new EntityKey(typeof(Brand), x.Id)).ToArray(); var translations = _translationStore.Find(CultureInfo.GetCultureInfo(culture), brandKeys); for (var i = 0; i < translations.Length; i++) { if (translations[i] != null) { var brand = brands[i]; brand.TranslatedName = translations[i].GetTranslatedText("Name"); brand.IsTranslated = true; brand.IsOutOfDate = translations[i].IsOutOfDate; } } return(View(list)); }
public ActionResult Index(string culture, string search, int page = 1, int pageSize = 50) { var query = CurrentInstance.Database.Repository <Product>().Query(); if (!String.IsNullOrWhiteSpace(search)) { search = search.Trim(); query = query.Where(p => p.Name.Contains(search)); } var list = query.OrderByDescending(p => p.Id) .Paginate(page - 1, pageSize) .Transform(p => new ProductGridItemModel { Id = p.Id, Name = p.Name }) .ToPagedList(); var products = list.ToList(); var productKeys = products.Select(p => new EntityKey(typeof(Product), p.Id)).ToArray(); var translations = _translationStore.Find(CultureInfo.GetCultureInfo(culture), productKeys); for (var i = 0; i < translations.Length; i++) { var translation = translations[i]; if (translation != null) { var product = products[i]; product.TranslatedName = translation.GetTranslatedText("Name"); product.IsTranslated = true; product.IsOutOfDate = translation.IsOutOfDate; } } return(View(list)); }
public ActionResult Index(string culture, int page = 1, int pageSize = 50) { var models = _repository.Query() .OrderBy(t => t.Id) .Paginate(page - 1, pageSize) .Transform(t => new ProductTypeGridItemModel { Id = t.Id, Name = t.Name }) .ToPagedList(); foreach (var model in models) { var translation = _translationStore.Find(CultureInfo.GetCultureInfo(culture), new EntityKey(typeof(ProductType), model.Id)); if (translation != null) { model.IsTranslated = true; model.IsOutOfDate = translation.IsOutOfDate; } } return(View(models)); }