コード例 #1
0
        public ActionResult Create(CategoryBrandItem model)
        {
            try
            {
                using (var context = new SiteContainer())
                {
                    var brand = context.CategoryBrand.Include("Category").First(b => b.Id == model.CategoryBrandId);

                    var cache = new CategoryBrandItem
                    {
                        CategoryBrand = brand,
                        Content = HttpUtility.HtmlDecode(model.Content),
                        SortOrder = model.SortOrder
                    };

                    context.AddToCategoryBrandItem(cache);

                    var lang = context.Language.FirstOrDefault(p => p.Id == model.CurrentLang);
                    if (lang != null)
                    {
                        CreateOrChangeContentLang(context, model, cache, lang);
                    }

                    return RedirectToAction("Details", "Brand",
                                            new
                                                {
                                                    area = "FactoryCatalogue",
                                                    categoryId = brand.Category.Name,
                                                    id = brand.Name
                                                });
                }
            }
            catch
            {
                return View();
            }
        }