public void It_persists_and_retrieves_meetups()
        {
            var originalMeetup = MeetupFactory.SomeMeetup();

            meetupRepository.Add(originalMeetup);

            originalMeetup.Id.Should().BeGreaterThan(0);

            var restoredMeetup = meetupRepository.GetById(originalMeetup.Id);

            restoredMeetup.ShouldBeEquivalentTo(originalMeetup);
        }
Example #2
0
 public void Handle(string name, string description, string scheduledFor)
 {
     meetupRepository.Add(Meetup.Schedule(
                              Name.FromString(name),
                              Description.FromString(description),
                              DateTimeOffset.Parse(scheduledFor)));
 }
        public Domain.Meetup Handle(CreateMeetupCommand command)
        {
            var meetup = new Domain.Meetup(0,
                                           command.HostUserId,
                                           command.Name,
                                           command.SeatsAvailable);

            _repository.Add(meetup);

            _repository.Commit();

            return(meetup);
        }
Example #4
0
        public Domain.Meetup Handle(CreateMeetupCommand command)
        {
            var meetupId = _repository.GetNextId();

            var meetup = new Domain.Meetup(
                meetupId,
                command.HostUserId,
                command.Name,
                command.SeatsAvailable);

            _repository.Add(meetup);

            _readModelUpdater.OnCreate(meetup);

            _repository.Commit();

            return(meetup);
        }
        public IActionResult Schedule(ScheduleMeetup meetup)
        {
            if (string.IsNullOrEmpty(meetup.Name))
            {
                ModelState.AddModelError("Name", "Name cannot be empty");
            }

            if (string.IsNullOrEmpty(meetup.Description))
            {
                ModelState.AddModelError("Description", "Description cannot be empty");
            }

            if (!ModelState.IsValid)
            {
                return(View(meetup));
            }

            meetupRepository.Add(Meetup.Schedule(
                                     Name.FromString(meetup.Name),
                                     Description.FromString(meetup.Description),
                                     meetup.ScheduledFor));

            return(RedirectToAction("Index"));
        }