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 }); } }
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 }); } }
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="" }); }
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" }); } }
public ActionResult Edit(int id) { using (var context = new ModelContainer()) { var element = context.Element.First(e => e.Id == id); return View(element); } }
public ActionResult Edit(int id) { using (var context = new ModelContainer()) { var article = context.Article.First(n => n.Id == id); return View(article); } }
public ActionResult Edit(int id) { using (var context = new ModelContainer()) { var project = context.Project.First(p => p.Id == id); return View(project); } }
public ActionResult Edit(int id) { using (var context = new ModelContainer()) { var newsItem = context.News.First(n => n.Id == id); return View(newsItem); } }
// // GET: /Admin/Subscriber/ public ActionResult Index() { using (var context = new ModelContainer()) { var subscribers = context.Subscriber.ToList(); return View(subscribers); } }
public ActionResult Edit(int id) { using (var context = new ModelContainer()) { var subscriber = context.Subscriber.First(s => s.Id == id); return View(subscriber); } }
public ActionResult Edit(int id) { using (var context = new ModelContainer()) { var content = context.Content.First(c => c.Id == id); return View(content); } }
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); } }
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 }); } }
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"); }
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 = "" }); }
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="" }); }
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"); } }
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; } }
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 = "" }); }
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"); }
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 = "" }); }
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; } }
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 = "" }); }
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; } } }
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 = "" }); }
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); } }
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 = "" }); }
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"); }
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; } }
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" }); }