public ActionResult Delete(int id) { using (var context = new LibraryContainer()) { var comment = context.Comment.First(c => c.Id == id); context.DeleteObject(comment); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Delete(int id) { using (var context = new LibraryContainer()) { var category = context.Category.Include("Products").First(c => c.Id == id); while (category.Products.Any()) { var product = category.Products.First(); ImageHelper.DeleteImage(product.ImageSource); product.Layout = null; context.DeleteObject(product); } ImageHelper.DeleteImage(category.ImageSource); context.DeleteObject(category); context.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult DeleteProductSet(int id) { using (var context = new LibraryContainer()) { var productSet = context.ProductSet.Include("Products").Include("Customer").First(ps => ps.Id == id); var customerName = productSet.Customer.Name; ViewBag.CustomerId = productSet.Customer.Name; productSet.Products.Clear(); context.DeleteObject(productSet); context.SaveChanges(); return RedirectToAction("Index", "Customer"); } }
// // GET: /Presentation/Note/Delete/5 public ActionResult Delete(int id) { using (var context = new LibraryContainer()) { var note = context.Note.First(n => n.Id == id); context.DeleteObject(note); context.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult Delete(int id) { using (var context = new LibraryContainer()) { var customer = context.Customer.Include("ProductSets").First(c => c.Id == id); string userName = customer.Name; while (customer.ProductSets.Any()) { var productContainer = customer.ProductSets.First(); context.DeleteObject(productContainer); context.SaveChanges(); } context.DeleteObject(customer); Membership.DeleteUser(userName); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult DeleteSurveyItem(int id) { using (var context = new LibraryContainer()) { var surveyItem = context.SurveyItem.Include("Survey").First(si => si.Id == id); var surveyId = surveyItem.Survey.Id; var survey = context.Survey.Include("Customer").First(s => s.Id == surveyId); context.DeleteObject(surveyItem); context.SaveChanges(); return RedirectToAction("Details", "Survey", new { id = survey.Customer.Name }); } }
public ActionResult Delete(int id) { using (var context = new LibraryContainer()) { var survey = context.Survey.Include("SurveyItems").First(s => s.Id == id); while (survey.SurveyItems.Any()) { var si = survey.SurveyItems.First(); context.DeleteObject(si); } context.DeleteObject(survey); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Delete(int id, FormCollection collection) { using (var context = new LibraryContainer()) { var layout = context.Layout.First(l => l.Id == id); context.DeleteObject(layout); context.SaveChanges(); } return RedirectToAction("Index"); }