예제 #1
0
        public ActionResult Edit(int id, FormCollection form)
        {
            using (var context = new ModelContainer())
            {
                var content = context.Content.First(c => c.Id == id);
                TryUpdateModel(content,
                              new[]
                                   {
                                       "Title",
                                       "PageTitle",
                                       "SortOrder",
                                       "MainPage",
                                       "SeoTitle",
                                       "SeoDescription",
                                       "SeoKeywords"
                                   });
                
                if (!content.Static)
                {
                    content.Name = form["Name"];
                }

                content.Text = HttpUtility.HtmlDecode(form["Text"]);
                content.SeoText = HttpUtility.HtmlDecode(form["SeoText"]);
                context.SaveChanges();
                return RedirectToAction("Index", "Home", new { Area = "", id = content.Name });
            }
        }
예제 #2
0
        public ActionResult Create(FormCollection form)
        {
            using (var context = new ModelContainer())
            {
                var content = new Content();
                TryUpdateModel(content,
                               new[]
                                   {
                                       "Name",
                                       "Title",
                                       "PageTitle",
                                       "SortOrder",
                                       "MainPage",
                                       "SeoTitle",
                                       "SeoDescription",
                                       "SeoKeywords"
                                   });

                content.Text = HttpUtility.HtmlDecode(form["Text"]);
                content.SeoText = HttpUtility.HtmlDecode(form["SeoText"]);
                context.AddToContent(content);
                context.SaveChanges();
                return RedirectToAction("Index", "Home", new { Area = "", id = content.Name });
            }
        }
예제 #3
0
        public ActionResult Edit(int id, FormCollection form, HttpPostedFileBase uploadFile)
        {
            using (var context = new ModelContainer())
            {
                var category = context.Category.First(c => c.Id == id);
                TryUpdateModel(category, new[] { "SortOrder" });

                category.Title = HttpUtility.HtmlDecode(form["Title"]);

                /*
                if (uploadFile != null)
                {
                    if (!string.IsNullOrEmpty(category.ImageSource))
                    {
                        IOHelper.DeleteFile("~/Content/Images", category.ImageSource);
                        foreach (var folder in GraphicsHelper.ThumbnailFolders)
                        {
                            IOHelper.DeleteFile("~/ImageCache/" + folder, category.ImageSource);
                        }
                    }

                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", uploadFile.FileName);
                    string filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    uploadFile.SaveAs(filePath);

                    category.ImageSource = fileName;
                }
                */
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Home", new { Area = "", id="" });
        }
예제 #4
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase uploadFile)
        {
            using (var context = new ModelContainer())
            {
                var project = new Project { ImageSource = "" };
                TryUpdateModel(project,
                               new[]
                                   {
                                       "Name",
                                       "Title",
                                       "SortOrder"
                                   });

                string fileName = IOHelper.GetUniqueFileName("~/Content/Images", uploadFile.FileName);
                string filePath = Server.MapPath("~/Content/Images");
                filePath = Path.Combine(filePath, fileName);
                uploadFile.SaveAs(filePath);

                project.ImageSource = fileName;

                project.TextTop = HttpUtility.HtmlDecode(form["TextTop"]);
                project.TextBottom = HttpUtility.HtmlDecode(form["TextBottom"]);

                context.AddToProject(project);
                context.SaveChanges();
                return RedirectToAction("Index", "Home", new { Area = "", id = "projects" });
            }
        }
예제 #5
0
 public ActionResult Edit(int id)
 {
     using (var context = new ModelContainer())
     {
         var element = context.Element.First(e => e.Id == id);
         return View(element);
     }
 }
예제 #6
0
 public ActionResult Edit(int id)
 {
     using (var context = new ModelContainer())
     {
         var article = context.Article.First(n => n.Id == id);
         return View(article);
     }
 }
예제 #7
0
 public ActionResult Edit(int id)
 {
     using (var context = new ModelContainer())
     {
         var project = context.Project.First(p => p.Id == id);
         return View(project);
     }
 }
예제 #8
0
 public ActionResult Edit(int id)
 {
     using (var context = new ModelContainer())
     {
         var newsItem = context.News.First(n => n.Id == id);
         return View(newsItem);
     }
 }
예제 #9
0
        //
        // GET: /Admin/Subscriber/

        public ActionResult Index()
        {
            using (var context = new ModelContainer())
            {
                var subscribers = context.Subscriber.ToList();
                return View(subscribers);
            }
        }
예제 #10
0
 public ActionResult Edit(int id)
 {
     using (var context = new ModelContainer())
     {
         var subscriber = context.Subscriber.First(s => s.Id == id);
         return View(subscriber);
     }
 }
예제 #11
0
 public ActionResult Edit(int id)
 {
     using (var context = new ModelContainer())
     {
         var content = context.Content.First(c => c.Id == id);
         return View(content);
     }
 }
예제 #12
0
 public ActionResult Edit(int id)
 {
     using (var context = new ModelContainer())
     {
         var category = context.Category.First(c => c.Id == id);
         category.Title = HttpUtility.HtmlEncode(category.Title);
         return View(category);
     }
 }
예제 #13
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase uploadFile)
        {
            using (var context = new ModelContainer())
            {
                int albumId = Convert.ToInt32(form["AlbumId"]);
                var album = context.Album.First(a => a.Id == albumId);

                PostCheckboxesData cbDataCategories = form.ProcessPostCheckboxesData("category");
                PostCheckboxesData cbDataElements = form.ProcessPostCheckboxesData("element");



                var product = new Product();
                TryUpdateModel(product,
                               new[]
                                   {
                                       "Title",
                                       "SortOrder"
                                   });

                string fileName = IOHelper.GetUniqueFileName("~/Content/Images", uploadFile.FileName);
                string filePath = Server.MapPath("~/Content/Images");
                filePath = Path.Combine(filePath, fileName);
                uploadFile.SaveAs(filePath);

                product.ImageSource = fileName;

                foreach (var kvp in cbDataCategories)
                {
                    var categoryId = kvp.Key;
                    bool productValue = kvp.Value;
                    if (productValue)
                    {
                        var category = context.Category.First(c => c.Id == categoryId);
                        product.Categories.Add(category);
                    }
                }

                foreach (var kvp in cbDataElements)
                {
                    var elementId = kvp.Key;
                    var elemrntValue = kvp.Value;
                    if (elemrntValue)
                    {
                        var element = context.Element.First(e => e.Id == elementId);
                        product.Elements.Add(element);
                    }
                }


                album.Products.Add(product);

                context.SaveChanges();
                return RedirectToAction("Index", "Albums", new { Area = "", id = album.Name });
            }
        }
예제 #14
0
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new ModelContainer())
     {
         var subscriber = context.Subscriber.First(s => s.Id == id);
         TryUpdateModel(subscriber, new[] {"Name", "Email"});
         context.SaveChanges();
     }
     return RedirectToAction("Index");
 }
예제 #15
0
 public ActionResult Delete(int id)
 {
     using (var context = new ModelContainer())
     {
         var newsItem = context.News.First(n => n.Id == id);
         context.DeleteObject(newsItem);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "News", new { Area = "" });
 }
예제 #16
0
 public ActionResult Edit(Element model)
 {
     using (var context = new ModelContainer())
     {
         var element = context.Element.First(e => e.Id == model.Id);
         TryUpdateModel(element, new[] { "Title", "SortOrder" });
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Home", new { Area = "", id="" });
 }
예제 #17
0
 public ActionResult ShowFilter()
 {
     using (var context = new ModelContainer())
     {
         SiteViewModel model = new SiteViewModel(context, null, null);
         ViewBag.Categories = model.Categories;
         ViewBag.Elements = model.Elements;
         return PartialView("_SearchCriteriaSelector");
     }
 }
예제 #18
0
        public ArticlesModel(ModelContainer context, string contentId, string articleId, bool loadContent=true) : base(context, contentId, articleId, loadContent)
        {
            Articles = _context.Article.ToList();

            if(!string.IsNullOrEmpty(articleId))
            {
                Article = _context.Article.First(a => a.Name == articleId);
                Title += " - " + Article.Title;
            }
        }
예제 #19
0
 public ActionResult Delete(int id)
 {
     using (var context = new ModelContainer())
     {
         var article = context.Article.First(n => n.Id == id);
         context.DeleteObject(article);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Articles", new { Area = "" });
 }
예제 #20
0
 public ActionResult Delete(int id)
 {
     using (var context = new ModelContainer())
     {
         var subscriber = context.Subscriber.First(s => s.Id == id);
         context.DeleteObject(subscriber);
         context.SaveChanges();
     }
     return RedirectToAction("Index");
 }
예제 #21
0
 public ActionResult Delete(int id)
 {
     using (var context = new ModelContainer())
     {
         var element = context.Element.First(e => e.Id == id);
         element.Products.Clear();
         context.DeleteObject(element);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Home", new { Area = "", id = "" });
 }
예제 #22
0
 public CatalogueModel(ModelContainer dataContext, string contentId, string albumId, bool loadContent = true)
     : base(dataContext, contentId, albumId, loadContent)
 {
      Albums  = _context.Album.Include("Products").ToList();
     
     if (!string.IsNullOrEmpty(albumId))
     {
         Album = _context.Album.Include("Products").First(a => a.Name == albumId);
         Title += " - " + Album.Title;
     }
 }
예제 #23
0
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new ModelContainer())
     {
         var newsItem = context.News.First(n => n.Id == id);
         TryUpdateModel(newsItem, new[] { "Title", "Date" });
         newsItem.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "News", new { Area = "" });
 }
예제 #24
0
        public SiteViewModel(ModelContainer context, string contentId, string currentId, bool loadContent = true)
        {
            Title = "Posh. Обустройство вашего заведения";
            _context = context;

            Categories = _context.Category.ToList();
            Elements = _context.Element.ToList();

            MainMenu = new List<MenuItem>();

            var contents = _context.Content.ToList();
            foreach (var c in contents)
            {
                MainMenu.Add(new MenuItem
                                 {
                                     Id = c.Id, 
                                     Name = c.Name, 
                                     Title = c.Title,
                                     Current = c.Name == contentId && (string.IsNullOrEmpty(currentId) || contentId==currentId),
                                     Selected = !string.IsNullOrEmpty(currentId) && c.Name == contentId, 
                                     SortOrder = c.SortOrder, 
                                     Static = c.Static, 
                                     MainPage = c.MainPage
                                 });
            }


            if (loadContent)
            {
                Content content = null;
                if (!string.IsNullOrEmpty(contentId))
                {
                    content = _context.Content.FirstOrDefault(c => c.Name == contentId);
                    if (content == null)
                    {
                        throw new HttpNotFoundException();
                    }
                }
                else
                {
                    content = _context.Content.FirstOrDefault(c => c.MainPage);
                    IsHomePage = true;
                }

                Content = content;
                if (content != null)
                {
                    Title += " - " + content.Title;
                    SeoDescription = content.SeoDescription;
                    SeoKeywords = content.SeoKeywords;
                }
            }

        }
예제 #25
0
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new ModelContainer())
     {
         var article = context.Article.First(n => n.Id == id);
         TryUpdateModel(article, new[] { "Title", "Name", "SortOrder" });
         article.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Articles", new { Area = "" });
 }
예제 #26
0
 public ActionResult ThankYou()
 {
     using (var context = new ModelContainer())
     {
         var model = new NewsModel(context, null, false);
         this.SetSeoContent(model);
         ViewBag.MainMenu = model.MainMenu;
         ViewBag.isHomePage = model.IsHomePage;
         return View(model);
     }
 }
예제 #27
0
 public ActionResult Create(FormCollection form)
 {
     using (var context = new ModelContainer())
     {
         var element = new Element();
         TryUpdateModel(element, new[] { "Title", "SortOrder" });
         context.AddToElement(element);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Home", new { Area = "", id = "" });
 }
예제 #28
0
 public ActionResult Subscribe(FormCollection form)
 {
     using (var context = new ModelContainer())
     {
         var subscriber = new Subscriber();
         TryUpdateModel(subscriber, new[] { "Name", "Email" });
         context.AddToSubscriber(subscriber);
         context.SaveChanges();
     }
     return RedirectToAction("ThankYou");
 }
예제 #29
0
        public ProjectsModel(ModelContainer dataContext, string contentId, string projectId, bool loadContent=true) 
            : base(dataContext, contentId, projectId, loadContent)
        {

            Projects = _context.Project.ToList();
            
            if (!string.IsNullOrEmpty(projectId))
            {
                Project = _context.Project.Include("ProjectItems").First(p => p.Name == projectId);
                Title += " - " + Project.Title;
            }
        }
예제 #30
0
 public ActionResult Delete(int id)
 {
     using (var context = new ModelContainer())
     {
         var project = context.Project.Include("ProjectItems").First(a => a.Id == id);
         if (!project.ProjectItems.Any())
         {
             context.DeleteObject(project);
             context.SaveChanges();
         }
     }
     return RedirectToAction("Index", "Home", new { Area = "", id = "projects" });
 }