// // 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 = "" }); } }
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"); }
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="" }); } }
public ActionResult Delete(int id) { try { using (var context = new CatalogueContainer()) { var category = context.Category.Include("Brands").Include("CategoryAttributes").First(c => c.Id == id); if (!category.Brands.Any()) { category.CategoryAttributes.Clear(); context.DeleteObject(category); context.SaveChanges(); } } } catch { } return RedirectToAction("Index"); }
//public ActionResult Edit(int id) //{ // using (var context = new CatalogueContainer()) // { // var product = context.Product.Include("Brand").First(p => p.Id == id); // return View(product); // } //} //[HttpPost] //public ActionResult Edit(int id, FormCollection form, int brandId, int makerId, HttpPostedFileBase fileUpload) //{ // try // { // using (var context = new CatalogueContainer()) // { // var product = context.Product.Include("Brand").First(p => p.Id == id); // if (fileUpload != null) // { // if (!string.IsNullOrEmpty(product.ImageSource)) // { // IOHelper.DeleteFile("~/Content/Images", product.ImageSource); // foreach (var thumbnail in SiteSettings.Thumbnails) // { // IOHelper.DeleteFile("~/ImageCache/" + thumbnail.Key, product.ImageSource); // } // } // string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName); // string filePath = Server.MapPath("~/Content/Images"); // filePath = Path.Combine(filePath, fileName); // fileUpload.SaveAs(filePath); // product.ImageSource = fileName; // } // context.SaveChanges(); // return RedirectToAction("Index", "Catalogue", new { Area = "", brand = product.Brand.Name }); // } // } // catch // { // return View(); // } //} public ActionResult Delete(int id, int? page, string filter) { using (var context = new CatalogueContainer()) { var product = context.Product.Include("Brand").First(p => p.Id == id); var brandId = product.Brand.Id; var brand = context.Brand.Include("Category").First(b => b.Id == brandId); var brandName = brand.Name; var categoryName = brand.Category.Name; ImageHelper.DeleteImage(product.ImageSource); context.DeleteObject(product); context.SaveChanges(); return RedirectToAction("Index", "Catalogue", new { Area = "", brand = brandName, category = categoryName, page = page, filter = filter }); } }
public ActionResult Delete(int id, string filter) { using (var context = new CatalogueContainer()) { var brand = context.Brand.Include("Category").First(b => b.Id == id); string categoryName = brand.Category.Name; brand.CategoryAttributes.Clear(); while (brand.Products.Any()) { var product = brand.Products.First(); ImageHelper.DeleteImage(product.ImageSource); context.DeleteObject(product); } context.DeleteObject(brand); context.SaveChanges(); return RedirectToAction("Index", "Catalogue", new { area = "", category = categoryName,filter=filter }); } }
public ActionResult DeleteImage(int id) { using (var context = new CatalogueContainer()) { var image = context.ProjectImage.Include("Project").First(pi => pi.Id == id); var projectName = image.Project.Name; ImageHelper.DeleteImage(image.ImageSource); context.DeleteObject(image); context.SaveChanges(); return RedirectToAction("Index", "Projects", new { area = "", project = projectName }); } }
// // GET: /Admin/Project/Delete/5 public ActionResult Delete(int id) { using (var context = new CatalogueContainer()) { var project = context.Project.Include("ProjectImages").First(p => p.Id == id); while (project.ProjectImages.Any()) { var image = project.ProjectImages.First(); ImageHelper.DeleteImage(image.ImageSource); context.DeleteObject(image); } context.DeleteObject(project); context.SaveChanges(); } return RedirectToAction("Index", "Projects", new { Area = "" }); }