public bool DeleteTeam(Guid TeamID) { Team Team = context.Teams.Find(TeamID); var entity = context.Users.Where(user => user.teamid == TeamID); if (Team != null) { foreach (var user in entity) { user.teamid = null; user.Team = null; context.Entry(user).State = EntityState.Modified; } context.SaveChanges(); context.Teams.Remove(Team); return(true); } else { return(false); } }
public void Save() { context.SaveChanges(); }