public void DeletePractice(Practice practice) { if (PracticeExists(practice.PracticeID) && !HasParticipants(practice)) { _dbContext.Practices.Remove(practice); _dbContext.SaveChanges(); } }
public Practice UpdatePractice(Practice practice) { _dbContext.Attach(practice).State = EntityState.Modified; try { _dbContext.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PracticeExists(practice.PracticeID)) { return(null); } else { throw; } } return(practice); }
public bool HasParticipants(Practice practice) => practice.Attendances.Count() > 0;
public Practice AddPractice(Practice practice) { _dbContext.Practices.Add(practice); _dbContext.SaveChanges(); return(practice); }