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, 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 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()) { 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(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 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 newsItem = context.News.First(n => n.Id == id); context.DeleteObject(newsItem); context.SaveChanges(); } return RedirectToAction("Index", "News", new { Area = "" }); }
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 subscriber = context.Subscriber.First(s => s.Id == id); context.DeleteObject(subscriber); context.SaveChanges(); } return RedirectToAction("Index"); }
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 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 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 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 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 ActionResult Edit(int id, FormCollection form) { using (var context = new ModelContainer()) { var project = context.Project.First(p => p.Id == id); TryUpdateModel(project, new[] { "Name", "Title", "SortOrder" }); project.TextTop = HttpUtility.HtmlDecode(form["TextTop"]); project.TextBottom = HttpUtility.HtmlDecode(form["TextBottom"]); context.SaveChanges(); } return RedirectToAction("Index", "Home", new { Area = "", id = "projects" }); }
public ActionResult Create(FormCollection form, HttpPostedFileBase uploadFile) { using (var context = new ModelContainer()) { var category = new Category(); TryUpdateModel(category, 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); category.ImageSource = fileName; */ context.AddToCategory(category); context.SaveChanges(); } return RedirectToAction("Index", "Home", new { Area = "" }); }
public ActionResult Create(FormCollection form) { using (var context = new ModelContainer()) { var newsItem = new News(); TryUpdateModel(newsItem, new[] { "Title", "Date" }); newsItem.Text = HttpUtility.HtmlDecode(form["Text"]); context.AddToNews(newsItem); // TODO: change absolute url!!!!! var mailText = HttpUtility.HtmlDecode(form["Text"]).Replace("src=\"", "src=\"http://posh-net-ua.1gb.ua/"); var mailSubject = "Posh. Рассылка новостей."; var subscribers = context.Subscriber.ToList(); foreach (var subscriber in subscribers) { new MailHelper("*****@*****.**", "POSH").SendMessage(new MailAddress(subscriber.Email), mailText, mailSubject, true); } context.SaveChanges(); } return RedirectToAction("Index", "News", new { Area = "" }); }
public ActionResult Delete(int id) { using (var context = new ModelContainer()) { var product = context.Product.Include("Album").First(p => p.Id == id); var album = product.Album; if (!string.IsNullOrEmpty(product.ImageSource)) { IOHelper.DeleteFile("~/Content/Images", product.ImageSource); foreach (var folder in GraphicsHelper.ThumbnailFolders) { IOHelper.DeleteFile("~/ImageCache/" + folder, product.ImageSource); } } product.Categories.Clear(); product.Elements.Clear(); context.DeleteObject(product); context.SaveChanges(); return RedirectToAction("Index", "Albums", new {Area = "", id = album.Name}); } }
public ActionResult Delete(int id) { using (var context = new ModelContainer()) { var category = context.Category.First(e => e.Id == id); category.Products.Clear(); IOHelper.DeleteFile("~/Content/Images", category.ImageSource); foreach (var folder in GraphicsHelper.ThumbnailFolders) { IOHelper.DeleteFile("~/ImageCache/" + folder, category.ImageSource); } context.DeleteObject(category); context.SaveChanges(); } return RedirectToAction("Index", "Home", new { Area = "", id = "" }); }
public ActionResult CreateProjectItem(FormCollection form, HttpPostedFileBase uploadFile) { using (var context = new ModelContainer()) { int projectId = Convert.ToInt32(form["ProjectId"]); var project = context.Project.First(p => p.Id == projectId); var projectItem = new ProjectItem(); TryUpdateModel(projectItem, 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); GraphicsHelper.SaveCachedImage("~/Content/Images", fileName, "mainView",ScaleMode.Corp); GraphicsHelper.SaveCachedImage("~/Content/Images", fileName, "galleryThumbnail", ScaleMode.Corp); projectItem.ImageSource = fileName; project.ProjectItems.Add(projectItem); context.SaveChanges(); return RedirectToAction("Index", "Projects", new { Area = "", id = project.Name }); } }
public ActionResult DeleteProjectItem(int id) { using (var context = new ModelContainer()) { var projectItem = context.ProjectItem.Include("Project").First(pi => pi.Id == id); var projectName = projectItem.Project.Name; if (!string.IsNullOrEmpty(projectItem.ImageSource)) { IOHelper.DeleteFile("~/Content/Images", projectItem.ImageSource); foreach (var folder in GraphicsHelper.ThumbnailFolders) { IOHelper.DeleteFile("~/ImageCache/" + folder, projectItem.ImageSource); } } context.DeleteObject(projectItem); context.SaveChanges(); return RedirectToAction("Index", "Projects", new {Area = "", id = projectName}); } }
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" }); }
public ActionResult SetDefault(int id) { using (var context = new ModelContainer()) { var product = context.Product.Include("Album").First(p => p.Id == id); product.Album.ImageSource = product.ImageSource; context.SaveChanges(); return RedirectToAction("Index", "Albums", new { Area = "", id = "" }); } }