Inheritance: IAmPersistable
Esempio n. 1
0
        public void Two_Participants_with_the_same_ids_are_equal()
        {
            var p1 = new Participant { Id = 1 };
            var p2 = new Participant { Id = 1 };

            Assert.That(p1.Equals(p2));
            Assert.That(p2.Equals(p1));
        }
Esempio n. 2
0
        public virtual void AddParticipant(Participant participant, Bed bed)
        {
            EnsureRetreatIsNotFull();
            EnsureBedIsNotAssigned(bed);

            var registration = new Registration {Participant = participant, Retreat = this, Bed = bed};
            _registrations.Add(registration);
        }
Esempio n. 3
0
        public void Two_Participants_with_the_different_ids_are_not_equal()
        {
            var p1 = new Participant { Id = 1 };
            var p2 = new Participant { Id = 2 };

            Assert.That(p1.Equals(p2), Is.False);
            Assert.That(p2.Equals(p1), Is.False);
        }
        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 void Save(Participant participant)
 {
     _session.SaveOrUpdate(participant);
     _session.Flush();
 }
Esempio n. 6
0
 Uri BuildDeleteLink(Retreat retreat, Participant participant)
 {
     // TODO: should have a delete view model here instead?
     return _urlMapper.MapAction<ParticipantController>(
         x => x.DeleteFromRetreat(
             retreat.Id,
             retreat.StartDate,
             participant.Id,
             participant.FirstName,
             participant.LastName));
 }
        public ActionResult AddToRetreat(AddParticipantToRetreatViewModel postBack)
        {
            if (postBack.Cancel != null)
                return this.RedirectToAction<RetreatController>(c => c.Index(postBack.RetreatId));

            if (postBack.Search != null)
            {
                var queryResults = _participantRepository.WithNameLike(postBack.FirstName, postBack.LastName);
                var searchResults = queryResults.Select(x => new ParticipantSearchResultViewModel
                {
                    Name = string.Format("{0} {1}", x.FirstName, x.LastName),
                    DateReceived = x.DateReceived,
                    SelectLink = _urlMapper.MapAction<ParticipantController>(c => c.AssignToRetreatChooseBedCode(postBack.RetreatId, x.Id)),
                });
                TempData["searchResults"] = new AddParticipantToRetreatSearchResultsViewModel
                {
                    SearchResults = searchResults.ToList(),
                };
                return this.RedirectToAction(c => c.AddToRetreat(postBack.RetreatId));
            }

            var retreat = _retreatRepository.Get(postBack.RetreatDate);

            // TODO: what if we already have a participant with this name in the db?
            var newParticipant = new Participant
            {
                FirstName = postBack.FirstName,
                LastName = postBack.LastName,
                DateReceived = postBack.DateReceived,
                Notes = postBack.Notes,
                PhysicalStatus = postBack.PhysicalStatus
            };

            var bed = _bedRepository.GetBy(postBack.BedCode);

            retreat.AddParticipant(newParticipant, bed);
            _retreatRepository.Save(retreat);

            return this.RedirectToAction<RetreatController>(c => c.Index(postBack.RetreatId));
        }