public ActionResult DeleteConfirmed(int MinistryID) { ministry ministry = MinistryRepository.GetMinistryByID(MinistryID); int goalCt = GoalRepository.GetGoalByMinistry(ministry.ministryID).Count(); int meetingCt = MeetingRepository.GetMeetingByMinistry(ministry.ministryID).Count(); int calendarCt = CalendarRepository.GetCalendarByMinistry(ministry.ministryID).Count(); int storyCt = StoryRepository.GetStoryByMinistry(ministry.ministryID).Count(); int pictureCt = PictureRepository.GetPictureByMinistry(ministry.ministryID).Count(); int ListTableCt = ListTableRepository.GetListByMinistry(ministry.ministryID).Count(); if ((goalCt > 0) || (meetingCt > 0) || (calendarCt > 0) || (storyCt > 0) || (pictureCt > 0) || (ListTableCt > 0)) { return(RedirectToAction("Details")); } MinistryRepository.DeleteRecord(ministry); return(RedirectToAction("Details")); }