示例#1
0
 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");
     }
 }
示例#2
0
        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");
        }
示例#3
0
 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");
     }
 }
示例#4
0
        //
        // 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");
        }
示例#5
0
        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");
            }

        }
示例#6
0
 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 });
     }
 }
示例#7
0
        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");
            }
        }
示例#8
0
 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");
 }