예제 #1
0
 private void CreateOrChangeContentLang(SiteContainer context, Content instance, Content cache, Language lang)
 {
    
         ContentLang contenttLang = null;
         if (cache != null)
         {
             contenttLang = context.ContentLang.FirstOrDefault(p => p.ContentId == cache.Id && p.LanguageId == lang.Id);
         }
         if (contenttLang == null)
         {
             var newPostLang = new ContentLang
                                   {
                                       ContentId = instance.Id,
                                       LanguageId = lang.Id,
                                       Title = instance.Title,
                                       Text = HttpUtility.HtmlDecode(instance.Text),
                                       SeoDescription = instance.SeoDescription,
                                       SeoKeywords = instance.SeoKeywords
                                   };
             context.AddToContentLang(newPostLang);
         }
         else
         {
             contenttLang.Title = instance.Title;
             contenttLang.Text = HttpUtility.HtmlDecode(instance.Text);
             contenttLang.SeoDescription = instance.SeoDescription;
             contenttLang.SeoKeywords = instance.SeoKeywords;
         }
         context.SaveChanges();
    
 }
예제 #2
0
        public FactoryCatalogueModel(Language lang, SiteContainer context, string categoryId, string brandId)
            : base(lang, context, "factory")
        {
            Categories = context.Category.ToList();
            foreach (var category in Categories)
            {
                category.CurrentLang = lang.Id;
            }


            if (!string.IsNullOrEmpty(categoryId))
            {
                Category = context.Category.Include("CategoryBrands").First(c => c.Name == categoryId);
                Category.CurrentLang = lang.Id;

                if (!string.IsNullOrEmpty(brandId))
                {
                    Brand = Category.CategoryBrands.First(c => c.Name == brandId);
                    Brand.CategoryBrandItems.Load();
                    foreach (var item in Brand.CategoryBrandItems)
                    {
                        item.CurrentLang = lang.Id;
                    }
                }

            }




        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        public ActionResult Delete(int id)
        {
            using (var context = new SiteContainer())
            {
                var brand = context.CategoryBrand.Include("Category").Include("CategoryBrandItems").First(b => b.Id == id);
                var categoryName = brand.Category.Name;

                foreach (var categoryBrandItem in brand.CategoryBrandItems)
                {
                    categoryBrandItem.CategoryBrandItemLangs.Load();
                }

                while (brand.CategoryBrandItems.Any())
                {
                    var cbi = brand.CategoryBrandItems.First();
                    while (cbi.CategoryBrandItemLangs.Any())
                    {
                        var cbil = cbi.CategoryBrandItemLangs.First();
                        context.DeleteObject(cbil);
                    }
                    context.DeleteObject(cbi);
                }

                context.DeleteObject(brand);
                context.SaveChanges();
                return RedirectToAction("Details", "Category", new { area = "FactoryCatalogue", id = categoryName });
            }
        }
예제 #5
0
        public ActionResult CreateTextBlock(ArticleItem model)
        {
            try
            {
                using (var context = new SiteContainer())
                {
                    var article = context.Article.First(b => b.Id == model.ArticleId);
                    var cache = new ArticleItem
                    {
                        SortOrder = model.SortOrder,
                        ContentType = 1,
                        Article = article,
                        ImageSource = ""
                    };

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

                    return RedirectToAction("Articles", "Home", new { area = "" });
                }
            }
            catch
            {
                return View();
            }
        }
예제 #6
0
        public ActionResult Create(CategoryBrand model)
        {
            try
            {
                using (var context = new SiteContainer())
                {
                    var category = context.Category.First(c => c.Id == model.CategoryId);
                    var cache = new CategoryBrand
                                    {
                                        Category = category,
                                        SortOrder = model.SortOrder,
                                        Name = SiteHelper.UpdatePageWebName(model.Name),
                                        Title = model.Title
                                    };
                    context.AddToCategoryBrand(cache);
                    context.SaveChanges();

                    return RedirectToAction("Details", "Category", new { area = "FactoryCatalogue", id = category.Name });
                }
            }
            catch
            {
                return View();
            }
        }
예제 #7
0
 public ActionResult Edit(int id)
 {
     using (var context = new SiteContainer())
     {
         var brand = context.CategoryBrand.Include("Category").First(b => b.Id == id);
         return View(brand);
     }
 }
예제 #8
0
 public ActionResult Edit(int id)
 {
     using (var context = new SiteContainer())
     {
         Content content = context.Content.First(c => c.Id == id);
         content.CurrentLang = CurrentLang.Id;
         return View(content);
     }
 }
예제 #9
0
 public ActionResult Articles()
 {
     using (var context = new SiteContainer())
     {
         var model = new ArticlesModel(CurrentLang, context);
         ViewBag.CurrentMenuItem = "news";
         return View(model);
     }
 }
예제 #10
0
 public ActionResult Edit(int id)
 {
     using (var context = new SiteContainer())
     {
         var brand = context.Brand.Include("BrandGroup").First(c => c.Id == id);
         brand.CurrentLang = CurrentLang.Id;
         return View(brand);
     }
 }
예제 #11
0
 public ActionResult EditTextBlock(int id)
 {
     using (var context = new SiteContainer())
     {
         var articleItem = context.ArticleItem.Include("Article").First(b => b.Id == id);
         articleItem.CurrentLang = CurrentLang.Id;
         return View(articleItem);
     }
 }
예제 #12
0
 public ActionResult Edit(int id)
 {
     using (var context = new SiteContainer())
     {
         var category = context.Category.First(c => c.Id == id);
         category.CurrentLang = CurrentLang.Id;
         return View(category);
     }
 }
예제 #13
0
 public ActionResult CreateTextBlock(int articleId)
 {
     using (var context = new SiteContainer())
     {
         var brand = context.Article.First(b => b.Id == articleId);
         int maxSortOrder = context.ArticleItem.Where(b => b.ArticleId == brand.Id).Max(c => (int?)c.SortOrder) ?? 0;
         return View(new ArticleItem { SortOrder = maxSortOrder + 1, CurrentLang = CurrentLang.Id, ArticleId = articleId });
     }
 }
예제 #14
0
 public ActionResult BrandDetails(string brandGroup, string id)
 {
     using (var context = new SiteContainer())
     {
         var model = new BrandCatalogueModel(CurrentLang, context, brandGroup, id);
         this.SetSeoContent(model);
         ViewBag.CurrentMenuItem = "brand-details";
         return View(model);
     }
 }
예제 #15
0
        //
        // GET: /FactoryCatalogue/Brand/Details/5

        public ActionResult Details(string categoryId, string id)
        {
            using (var context = new SiteContainer())
            {
                var model = new FactoryCatalogueModel(CurrentLang, context, categoryId, id);
                ViewBag.CurrentBramdName = model.Brand.Name;
                ViewBag.CurrentMenuItem = "factory-details";
                return View(model);
            }
        }
예제 #16
0
 public ActionResult CreateTextBlock(int brandId, int type)
 {
     using (var context = new SiteContainer())
     {
         var brand = context.BrandGroup.First(b => b.Id == brandId);
         ViewBag.BrandGroupName = brand.Name;
         int maxSortOrder = context.BrandGroupItem.Where(b => b.BrandGroupId == brand.Id).Max(c => (int?)c.SortOrder) ?? 0;
         return View(new BrandGroupItem { SortOrder = maxSortOrder + 1, ContentType = type, CurrentLang = CurrentLang.Id, BrandGroupId = brandId });
     }
 }
예제 #17
0
        //
        // GET: /BrandCatalogue/Home/

        public ActionResult Index()
        {
            using (var context = new SiteContainer())
            {
                var model = new BrandCatalogueModel(CurrentLang, context,null, null);
                this.SetSeoContent(model);
                ViewBag.CurrentMenuItem = "gallery";
                return View(model);
            }
        }
예제 #18
0
        public ActionResult EditTextBlock(int id)
        {
            using (var context = new SiteContainer())
            {
                var brandItem = context.BrandGroupItem.Include("BrandGroup").First(b => b.Id == id);

                ViewBag.BrandName = brandItem.BrandGroup.Name;
                brandItem.CurrentLang = CurrentLang.Id;
                return View(brandItem);
            }
        }
예제 #19
0
        public SiteModel(Language lang, SiteContainer context, string contentId)
        {
            Title = "Listelli";
            
            Content = context.Content.FirstOrDefault(c => c.Name == contentId) ?? context.Content.First(c => c.MainPage);
            IsHomePage = Content.MainPage;
            Content.CurrentLang = lang.Id;

            SeoDescription = Content.SeoDescription;
            SeoKeywords = Content.SeoKeywords;
        }
예제 #20
0
 public ActionResult Create()
 {
     using (var context = new SiteContainer())
     {
         int maxSortOrder = context.Category.Max(c => (int?)c.SortOrder) ?? 0;
         var category = new Category
                            {
                                SortOrder = maxSortOrder + 1,
                                CurrentLang = CurrentLang.Id
                            };
         return View(category);
     }
 } 
예제 #21
0
        public ArticlesModel(Language lang, SiteContainer context) : base(lang, context, "news")
        {
            Articles = context.Article.Include("ArticleItems").ToList();
            foreach (var article in Articles)
            {
                article.CurrentLang = lang.Id;

                foreach (var item in article.ArticleItems)
                {
                    item.CurrentLang = lang.Id;
                }
            }
        }
예제 #22
0
 public ActionResult Create()
 {
     using (var context = new SiteContainer())
     {
         int maxSortOrder = context.BrandGroup.Max(c => (int?)c.SortOrder) ?? 0;
         var brand = new BrandGroup
         {
             SortOrder = maxSortOrder + 1,
             CurrentLang = CurrentLang.Id
         };
         return View(brand);
     }
 }
예제 #23
0
 public ActionResult Details(string id)
 {
     using (var context = new SiteContainer())
     {
         var model = new FactoryCatalogueModel(CurrentLang, context, id,null);
         this.SetSeoContent(model);
         ViewBag.CurrentMenuItem = "factory-details";
         if (model.Category.CategoryBrands.Any())
         {
             var minSortOrder = model.Category.CategoryBrands.Min(c => (int?)c.SortOrder) ?? 0;
             return RedirectToAction("Details", "Brand", new {area = "FactoryCatalogue", categoryId=model.Category.Name,id=model.Category.CategoryBrands.First(c=>c.SortOrder==minSortOrder).Name});
         }
         return View(model);
     }
 }
예제 #24
0
 public ActionResult Create(int category)
 {
     using (var context = new SiteContainer())
     {
         var cat = context.Category.First(c => c.Id == category);
         int maxSortOrder = context.CategoryBrand.Where(c => c.CategoryId == cat.Id).Max(c => (int?)c.SortOrder) ?? 0;
         var categoryBrand = new CategoryBrand
         {
             SortOrder = maxSortOrder + 1,
             Category = cat
         };
         ViewBag.CategoryName = cat.Name;
         return View(categoryBrand);
     }
 }
예제 #25
0
        public ActionResult Edit(int id)
        {
            using (var context = new SiteContainer())
            {
                var brandItem = context.CategoryBrandItem.Include("CategoryBrand").First(b => b.Id == id);
                var categoryBrand = context.CategoryBrand.Include("Category").First(c => c.Id == brandItem.CategoryBrandId);

                brandItem.CurrentLang = CurrentLang.Id;

                ViewBag.BrandName = brandItem.CategoryBrand.Name;
                ViewBag.CategoryName = categoryBrand.Category.Name;

                return View(brandItem);
            }
        }
예제 #26
0
 public ActionResult Create(int brandId)
 {
     using (var context = new SiteContainer())
     {
         var brand = context.CategoryBrand.Include("Category").First(b => b.Id == brandId);
         int maxSortOrder = context.CategoryBrandItem.Where(c => c.CategoryBrandId == brandId).Max(c => (int?)c.SortOrder) ?? 0;
         var brandItem = new CategoryBrandItem
                             {
                                 CategoryBrand = brand,
                                 SortOrder = maxSortOrder + 1,
                                 CurrentLang = CurrentLang.Id
                             };
         ViewBag.BrandName = brand.Name;
         ViewBag.CategoryName = brand.Category.Name;
         return View(brandItem);
     }
 } 
예제 #27
0
 public ActionResult Create(int brandId)
 {
     using (var context = new SiteContainer())
     {
         var brandGroup = context.BrandGroup.First(b => b.Id == brandId);
         ViewBag.BrandGroupName = brandGroup.Name;
         ViewBag.BrandId = brandId;
         int maxSortOrder = context.Brand.Max(c => (int?)c.SortOrder) ?? 0;
         var brand = new Brand
                         {
                             SortOrder = maxSortOrder + 1,
                             CurrentLang = CurrentLang.Id
                         };
         return View(brand);
         
     }
 }
예제 #28
0
        //
        // GET: /FactoryCatalogue/Category/

        public ActionResult Index()
        {
            using (var context = new SiteContainer())
            {
      
                var model = new FactoryCatalogueModel(CurrentLang, context, null,null);

                if (!User.Identity.IsAuthenticated)
                {
                    return RedirectToAction("LogOn", "Customer");
                }


                this.SetSeoContent(model);
                ViewBag.CurrentMenuItem = model.Content.Name;
                return View(model);
            }
        }
예제 #29
0
        public ActionResult EditTextBlock(ArticleItem model)
        {
            using (var context = new SiteContainer())
            {
                var cache = context.ArticleItem.Include("Article").First(p => p.Id == model.Id);

                TryUpdateModel(cache, new[] { "SortOrder" });

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


                return RedirectToAction("Articles", "Home", new { area = "" });
            }
        }
예제 #30
0
 public ActionResult Edit(CategoryBrand model)
 {
     try
     {
         using (var context = new SiteContainer())
         {
             var brand = context.CategoryBrand.Include("Category").First(b => b.Id == model.Id);
             TryUpdateModel(brand, new[] { "SortOrder", "Title" });
             brand.Name = SiteHelper.UpdatePageWebName(model.Name);
             context.SaveChanges();
             return RedirectToAction("Details", "Category", new { area = "FactoryCatalogue", id = brand.Category.Name });
         }
     }
     catch
     {
         return View();
     }
 }