public ActionResult CreateTextBlock(BrandGroupItem model) { try { using (var context = new SiteContainer()) { var brand = context.BrandGroup.First(b => b.Id == model.BrandGroupId); var cache = new BrandGroupItem { SortOrder = model.SortOrder, ContentType = model.ContentType, BrandGroup = brand }; model.Text = HttpUtility.HtmlDecode(model.Text); var lang = context.Language.FirstOrDefault(p => p.Id == model.CurrentLang); if (lang != null) { CreateOrChangeContentLang(context, model, cache, lang); } return RedirectToAction("BrandGroupDetails", "Home", new { area = "BrandCatalogue", id = brand.Name }); } } catch { return View(); } }
public ActionResult EditTextBlock(BrandGroupItem model) { using (var context = new SiteContainer()) { var cache = context.BrandGroupItem.Include("BrandGroup").First(p => p.Id == model.Id); //var brand = context.Brand.Include("BrandGroup").First(b => b.Id == model.BrandId); model.Text = HttpUtility.HtmlDecode(model.Text); //cache.Text = model.Text; TryUpdateModel(cache, new[] { "SortOrder" }); var lang = context.Language.FirstOrDefault(p => p.Id == model.CurrentLang); if (lang != null) { CreateOrChangeContentLang(context, model, cache, lang); } return RedirectToAction("BrandGroupDetails", "Home", new { area = "BrandCatalogue", id = cache.BrandGroup.Name }); } }
/// <summary> /// Deprecated Method for adding a new object to the BrandGroupItem EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBrandGroupItem(BrandGroupItem brandGroupItem) { base.AddObject("BrandGroupItem", brandGroupItem); }
private void CreateOrChangeContentLang(SiteContainer context, BrandGroupItem instance, BrandGroupItem cache, Language lang) { BrandGroupItemLang contenttLang = null; if (cache != null) { contenttLang = context.BrandGroupItemLang.FirstOrDefault(p => p.BrandGroupItemId == cache.Id && p.LanguageId == lang.Id); } if (contenttLang == null) { var newPostLang = new BrandGroupItemLang { BrandGroupItemId = instance.Id, LanguageId = lang.Id, Text = instance.Text }; context.AddToBrandGroupItemLang(newPostLang); } else { contenttLang.Text = instance.Text; } context.SaveChanges(); }
/// <summary> /// Create a new BrandGroupItem object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="contentType">Initial value of the ContentType property.</param> /// <param name="sortOrder">Initial value of the SortOrder property.</param> /// <param name="brandGroupId">Initial value of the BrandGroupId property.</param> public static BrandGroupItem CreateBrandGroupItem(global::System.Int32 id, global::System.Int32 contentType, global::System.Int32 sortOrder, global::System.Int32 brandGroupId) { BrandGroupItem brandGroupItem = new BrandGroupItem(); brandGroupItem.Id = id; brandGroupItem.ContentType = contentType; brandGroupItem.SortOrder = sortOrder; brandGroupItem.BrandGroupId = brandGroupId; return brandGroupItem; }