public bool DeleteProject(int id) { var pr = _dbContext.Projects.FirstOrDefault(x => x.ProjectId == id); if (pr != null) { // Remove all contacts for the project first... _dbContext.ProjectContacts.Where(x => x.ProjectId == id).ToList().ForEach(pc => _dbContext.Remove(pc)); _dbContext.Remove(pr); _dbContext.SaveChanges(); return(true); } return(false); }
public bool DeleteContact(int id) { var c = _dbContext.Contacts.FirstOrDefault(x => x.ContactId == id); if (c != null) { // Remove all links to projects first... _dbContext.ProjectContacts.Where(x => x.ContactId == id).ToList().ForEach(t => _dbContext.Remove(t)); _dbContext.Remove(c); _dbContext.SaveChanges(); return(true); } return(false); }