public void Delete(int id) { ShippingZone shippingZone = Find(id); var shippingMethods = shippingMethodService.FindAll().Where(m => m.ShippingZoneId == id).ToList(); foreach (var shippingMethod in shippingMethods) { shippingMethodService.Delete(shippingMethod.Id); } db.ShippingZones.Remove(shippingZone); db.SaveChanges(); }
public ActionResult DeleteConfirmed(int[] ids) { if (ids == null || !ids.Any()) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } foreach (int id in ids) { shippingMethodService.Delete(id); } return(RedirectToAction("Index") .WithWarning(string.Format("The shipping method has been deleted".TA()))); }