Exemplo n.º 1
0
        public ActionResult Create(FormCollection form, int brandId, IEnumerable<HttpPostedFileBase> fileUpload, IList<string> fileTitles, string filter)
        {
            try
            {
                using (var context = new CatalogueContainer())
                {
                    var brand = context.Brand.Include("Category").First(b => b.Id == brandId);

                    foreach (var file in fileUpload)
                    {
                        if (file != null)
                        {
                            var product = new Product { Brand = brand };
                            string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                            string filePath = Server.MapPath("~/Content/Images");
                            filePath = Path.Combine(filePath, fileName);
                            file.SaveAs(filePath);
                            product.ImageSource = fileName;

                            context.AddToProduct(product);
                        }
                    }

                    context.SaveChanges();

                    return RedirectToAction("Index", "Catalogue", new { Area = "", brand = brand.Name, category=brand.Category.Name, filter = filter });
                }
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id, FormCollection form, string filter)
        {
            using (var context = new CatalogueContainer())
            {
                var brand = context.Brand.Include("Category").First(b => b.Id == id);
                //var category = context.Category.Include("CategoryAttributes").First(c => c.Id == brand.CategoryId);


                brand.CategoryAttributes.Clear();
                PostCheckboxesData cbData = form.ProcessPostCheckboxesData("attr");
                foreach (var kvp in cbData)
                {
                    var attrId = kvp.Key;
                    bool attrValue = kvp.Value;
                    if (attrValue)
                    {
                        var attribute = context.CategoryAttribute.First(c => c.Id == attrId);
                        brand.CategoryAttributes.Add(attribute);
                    }
                }

                string categoryName = brand.Category.Name;
                TryUpdateModel(brand, new[] { "Title", "Name", "SortOrder", "Href", "DescriptionTitle" });
                brand.Name = brand.Name.ToLower().Replace(" ", "");
                brand.Description = HttpUtility.HtmlDecode(form["Description"]);
                context.SaveChanges();


                return RedirectToAction("Index", "Catalogue", new { area = "", category = categoryName,filter=filter });
            }
        }
Exemplo n.º 3
0
 public ActionResult Edit(int id, FormCollection form)
 {
     try
     {
         using (var context = new CatalogueContainer())
         {
             var project = context.Project.First(p => p.Id == id);
             TryUpdateModel(project, new[]
                                         {
                                             "Name", 
                                             "Title", 
                                             "DescriptionTitle",
                                             "SortOrder",
                                             "SeoDescription",
                                             "SeoKeywords"
                                         });
             project.Description = HttpUtility.HtmlDecode(form["Description"]);
             project.Name = project.Name.ToLower().Replace(" ", "");
             context.SaveChanges();
             return RedirectToAction("Index", "Projects", new { Area = "", project = project.Name });
         }
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 4
0
 public ActionResult Index()
 {
     using (var context = new CatalogueContainer())
     {
         var images = context.MainPageImage.ToList();
         return View(images);
     }
 }
Exemplo n.º 5
0
        //
        // GET: /Admin/Article/Edit/5

        public ActionResult Edit(int id)
        {
            using (var context = new CatalogueContainer())
            {
                var article = context.Article.First(a => a.Id == id);
                return View(article);
            }
        }
Exemplo n.º 6
0
        //
        // GET: /Admin/Project/Edit/5

        public ActionResult Edit(int id)
        {
            using (var context = new CatalogueContainer())
            {
                var project = context.Project.First(p => p.Id == id);
                return View(project);
            }
        }
Exemplo n.º 7
0
 public ActionResult Edit(int id)
 {
     using (var context = new CatalogueContainer())
     {
         var content = context.Content.First(c => c.Id == id);
         return View(content);
     }
 }
 public ActionResult Edit(int id)
 {
     using (var context = new CatalogueContainer())
     {
         var attribute = context.CategoryAttribute.First(a => a.Id == id);
         return View(attribute);
     }
 }
Exemplo n.º 9
0
 public ActionResult Create(int id, string filter)
 {
     using (var context = new CatalogueContainer())
     {
         var brand = context.Brand.First(c => c.Id == id);
         ViewBag.Filter = filter;
         return View(new Product { Brand = brand });
     }
 }
Exemplo n.º 10
0
 public ActionResult Create()
 {
     using (var context = new CatalogueContainer())
     {
         var category = new Category { SortOrder = 0 };
         var attributes = context.CategoryAttribute.ToList();
         ViewBag.Attributes = attributes;
         return View(category);
     }
 }
Exemplo n.º 11
0
 public ActionResult Index()
 {
     using (var context = new CatalogueContainer())
     {
         ViewBag.Categories = context.Category.ToList();
         ViewBag.Projects = context.Project.ToList();
         var pa = context.CategoryAttribute.ToList();
         return View(pa);
     }
 }
Exemplo n.º 12
0
        //
        // GET: /Admin/Article/Delete/5

        public ActionResult Delete(int id)
        {
            using (var context = new CatalogueContainer())
            {
                var article = context.Article.First(a => a.Id == id);
                context.DeleteObject(article);
                context.SaveChanges();
                return RedirectToAction("Index", "Articles", new { area = "" });
            }
        }
Exemplo n.º 13
0
        public SiteViewModel(CatalogueContainer context, string contentName)
        {

            var categories = context.Category.ToList();
            Categories = categories;

            var projects = context.Project.ToList();
            Projects = projects;

            var contents = context.Content.Where(c => !c.MainPage).ToList();
            Menu = new Menu();
            foreach (var content in contents)
            {
                Menu.Add(new MenuItem
                             {
                                 ContentId = content.Id,
                                 ContentName = content.Name,
                                 Current = content.Name == contentName,
                                 SortOrder = content.SortOrder,
                                 Title = content.Title
                             });
            }


            if (contentName == null)
            {
                Content = context.Content.First(c => c.MainPage);
                if (context.MainPageImage.FirstOrDefault() != null)
                {
                    MainPageImage = context.MainPageImage.RandomElement(new Random());
                    //MainPageImages = context.MainPageImage.ToList();
                }
            }
            else
            {
                Content = context.Content.FirstOrDefault(c => c.Name == contentName);
                if (Content == null)
                {
                    throw new HttpNotFoundException();
                }
            }



            Title = Content.Title;
            SeoDescription = Content.SeoDescription;
            SeoKeywords = Content.SeoKeywords;
            if (Content.MainPage)
            {
                IsHomePage = true;
                //Layouts = context.Layout.Include("Parent").Include("Children").ToList();
            }


        }
Exemplo n.º 14
0
 public ActionResult Create(int id, string filter)
 {
     using (var context = new CatalogueContainer())
     {
         var category = context.Category.Include("CategoryAttributes").First(c => c.Id == id);
         ViewBag.CategoryAttributes = category.CategoryAttributes.ToList();
         ViewBag.CategoryId = id;
         ViewBag.Filter = filter;
         return View(new Brand{Category = category});
     }
 }
Exemplo n.º 15
0
 public ActionResult Delete(int id)
 {
     using (var context = new CatalogueContainer())
     {
         var attribute = context.CategoryAttribute.First(a => a.Id == id);
         attribute.Categories.Clear();
         attribute.Brands.Clear();
         context.DeleteObject(attribute);
         context.SaveChanges();
     }
     return RedirectToAction("Index");
 }
Exemplo n.º 16
0
        //
        // GET: /Articles/

        public ActionResult Index()
        {
            using (var context = new CatalogueContainer())
            {
                var model = new ArticlesViewModel(context);
                ViewBag.Categories = model.Categories;
                ViewBag.Projects = model.Projects;
                this.SetSeoContent(model);
                ViewBag.MainMenu = model.Menu;
                ViewBag.IsArticles = true;
                return View(model);
            }
        }
Exemplo n.º 17
0
        public ActionResult Edit(int id, string filter)
        {
            using (var context = new CatalogueContainer())
            {
                ViewBag.Filter = filter;
                var brand = context.Brand.Include("Category").Include("CategoryAttributes").First(l => l.Id == id);
                var category = context.Category.Include("CategoryAttributes").First(c => c.Id == brand.CategoryId);
                ViewBag.CategoryAttributes = category.CategoryAttributes.ToList();
                ViewBag.SelectedAttributes = brand.CategoryAttributes.ToList();

                return View(brand);
            }
        }
Exemplo n.º 18
0
        //
        // GET: /Projects/

        public ActionResult Index(string project)
        {
            using (var context = new CatalogueContainer())
            {
                var model = new ProjectViewModel(context, project);
                ViewBag.Categories = model.Categories;
                ViewBag.Projects = model.Projects;
                this.SetSeoContent(model);
                ViewBag.MainMenu = model.Menu;
                ViewBag.ProjectsPage = true;
                return View(model);
            }
        }
Exemplo n.º 19
0
        public ActionResult Create(FormCollection form)
        {
            try
            {
                using (var context = new CatalogueContainer())
                {
                    var category = new Category();


                    var attributes = context.CategoryAttribute.ToList();
                    PostCheckboxesData postData = form.ProcessPostCheckboxesData("attr");
                    foreach (var kvp in postData)
                    {
                        var attribute = attributes.First(a => a.Id == kvp.Key);
                        if (kvp.Value)
                        {
                            if (!category.CategoryAttributes.Contains(attribute))
                                category.CategoryAttributes.Add(attribute);
                        }
                        else
                        {
                            if (category.CategoryAttributes.Contains(attribute))
                                category.CategoryAttributes.Remove(attribute);
                        }
                    }

                    TryUpdateModel(category, new[] { 
                    "Name", 
                    "Title", 
                    "SortOrder",
                    "SeoDescription",
                    "SeoKeywords",
                    "DescriptionTitle"
                    });
                    category.Description = HttpUtility.HtmlDecode(form["Description"]);
                    category.Name = category.Name.ToLower().Replace(" ", "");

                    context.AddToCategory(category);
                    context.SaveChanges();
                    return RedirectToAction("Index", "Category", new { area = "Admin" });
                }


            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 20
0
        public ActionResult Edit(int id, FormCollection form)
        {
            try
            {
                using (var context = new CatalogueContainer())
                {
                    var attribute = context.CategoryAttribute.First(a => a.Id == id);
                    TryUpdateModel(attribute, new[] { "Title", "Name" });
                    context.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 21
0
        public ActionResult Index(string id)
        {
            using (var context = new CatalogueContainer())
            {
                var model = new SiteViewModel(context, id);
                this.SetSeoContent(model);
                //if (model.Content != null && model.Layouts != null)
                //    ViewBag.Layouts = model.Layouts;
                ViewBag.Categories = model.Categories;
                ViewBag.Projects = model.Projects;

                ViewBag.isHomePage = model.IsHomePage;
                ViewBag.MainMenu = model.Menu;
                if (model.IsHomePage)
                    ViewBag.MainPage = true;
                return View(model);
            }
        }
Exemplo n.º 22
0
 public ActionResult Edit(int id, FormCollection form)
 {
     try
     {
         using (var context = new CatalogueContainer())
         {
             var article = context.Article.First(a => a.Id == id);
             TryUpdateModel(article, new[] { "Title", "Date" });
             article.Text = HttpUtility.HtmlDecode(form["Text"]);
             context.SaveChanges();
             return RedirectToAction("Index", "Articles", new { area = "" });
         }
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 23
0
 public ActionResult Index(string category, string filter, string brand)
 {
     using (var context = new CatalogueContainer())
     {
         var model = new CatalogueViewModel(context, category, filter, brand);
         //if (!model.Category.MainPage)
         //    ViewBag.CategoryName = model.Category.Name;
         //model.SetFilters();
         //model.ApplyFilers();
         //model.ApplyPaging();
         //ViewBag.Page = page ?? 0;
         ViewBag.MainMenu = model.Menu;
         ViewBag.Categories = model.Categories;
         ViewBag.Projects = model.Projects;
         ViewBag.CataloguePage = true;
         this.SetSeoContent(model);
         return View(model);
     }
 }
Exemplo n.º 24
0
        public ActionResult Create(FormCollection form)
        {
            try
            {
                using (var context = new CatalogueContainer())
                {
                    var attribute = new CategoryAttribute();
                    TryUpdateModel(attribute, new[] { "Title", "Name" });
                    context.AddToCategoryAttribute(attribute);
                    context.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 25
0
 public ActionResult AddImage(IEnumerable<HttpPostedFileBase> fileUpload)
 {
     using (var context = new CatalogueContainer())
     {
         foreach (var file in fileUpload)
         {
             if (file != null)
             {
                 string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                 string filePath = Server.MapPath("~/Content/Images");
                 filePath = Path.Combine(filePath, fileName);
                 file.SaveAs(filePath);
                 var mpi = new MainPageImage() {ImageSource = fileName};
                 context.AddToMainPageImage(mpi);
                 context.SaveChanges();
             }
         }
         return RedirectToAction("Index", "Home", new {area = ""});
     }
 }
Exemplo n.º 26
0
        public ProjectViewModel(CatalogueContainer context, string project)
            : base(context, null)
        {
            Title = "Проекты";

            foreach (var p in Projects.Where(p=>p.Name==project))
            {
                p.Current = true;
            }

            if (!string.IsNullOrEmpty(project))
            {
                Project = context.Project.Include("ProjectImages").First(c => c.Name == project);
                Title += " - " + Project.Title;
                SeoDescription = Project.SeoDescription;
                SeoKeywords = Project.SeoKeywords;
            }


        }
Exemplo n.º 27
0
 public ActionResult Edit(int id, FormCollection form)
 {
     try
     {
         using (var context = new CatalogueContainer())
         {
             var content = context.Content.First(c => c.Id == id);
             TryUpdateModel(content, new[] {"Title","DescriptionTitle","SeoDescription","SeoKeywords","SortOrder"});
             content.Text = HttpUtility.HtmlDecode(form["Text"]);
             content.Description = HttpUtility.HtmlDecode(form["Description"]);
             context.SaveChanges();
             if(content.MainPage)
                 return RedirectToAction("Index", "Home", new { area = "", id = "" });
             return RedirectToAction("Index", "Home", new {area="", id = content.Name});
         }
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 28
0
 public ArticlesViewModel(CatalogueContainer context) : base(context, null)
 {
     Title = "Новости";
     Articles = context.Article.ToList();
 }
Exemplo n.º 29
0
 public ActionResult DeleteImage(int id)
 {
     using (var context = new CatalogueContainer())
     {
         var image = context.MainPageImage.First(i => i.Id == id);
         ImageHelper.DeleteImage(image.ImageSource);
         context.DeleteObject(image);
         context.SaveChanges();
         return RedirectToAction("Index", "Content", new { area = "Admin",id="" });
     }
 }
Exemplo n.º 30
0
 public ActionResult Edit(int id)
 {
     using (var context = new CatalogueContainer())
     {
         var category = context.Category.Include("CategoryAttributes").First(c => c.Id == id);
         var attributes = context.CategoryAttribute.ToList();
         ViewBag.Attributes = attributes;
         return View(category);
     }
 }