void EnsureBedIsNotAssigned(Bed bed) { if (bed != null && Registrations.Any(r => r.Bed == bed)) { throw new InvalidOperationException("Cannot assign the same bed twice for the same retreat."); } }
static string[] GetAvailableBedCodes(Bed bed, Retreat retreat, IEnumerable<Bed> beds) { var bedcodes = retreat.GetUnassignedBeds(beds).Select(x => x.Code).ToArray(); if (bed != null) bedcodes = new[] { bed.Code }.Concat(bedcodes).ToArray(); return bedcodes; }
public virtual void AddParticipant(Participant participant, Bed bed) { EnsureRetreatIsNotFull(); EnsureBedIsNotAssigned(bed); var registration = new Registration {Participant = participant, Retreat = this, Bed = bed}; _registrations.Add(registration); }
static void FillRetreat(Retreat retreat) { for (int x = 0; x < 29; x++) { var bed = new Bed { Code = "bedcode" + x }; var participant = new Participant(); retreat.AddParticipant(participant, bed); } }
public virtual void AddParticipant(Participant participant, Bed bed) { EnsureRetreatIsNotFull(); EnsureBedIsNotAssigned(bed); var registration = new Registration { Participant = participant, Retreat = this, Bed = bed }; _registrations.Add(registration); }