コード例 #1
0
ファイル: NewsController.cs プロジェクト: fathurxzz/aleqx
 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 = "" });
 }
コード例 #2
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");
 }
コード例 #3
0
ファイル: ArticleController.cs プロジェクト: fathurxzz/aleqx
 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 = "" });
 }
コード例 #4
0
ファイル: ElementController.cs プロジェクト: fathurxzz/aleqx
 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 = "" });
 }
コード例 #5
0
ファイル: CategoryController.cs プロジェクト: fathurxzz/aleqx
 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 = "" });
 }
コード例 #6
0
ファイル: ProductController.cs プロジェクト: fathurxzz/aleqx
        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});
            }
        }
コード例 #7
0
ファイル: ProjectController.cs プロジェクト: fathurxzz/aleqx
 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" });
 }
コード例 #8
0
ファイル: ProjectController.cs プロジェクト: fathurxzz/aleqx
        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});
            }
        }