public Result Handle(UpdateMeetupCommand command)
        {
            Result result = Result.Successful;

            var meetup = _repository.Load(command.MeetupId);

            if (!meetup.Name.Equals(command.Name, StringComparison.InvariantCulture))
            {
                result = meetup.UpdateName(command.Name);
                if (!result.Success)
                {
                    return(result);
                }
            }
            if (meetup.TotalAvailableSeats != command.SeatsAvailable)
            {
                result = meetup.UpdateAvailableSeats(command.SeatsAvailable);
                if (!result.Success)
                {
                    return(result);
                }
            }

            _repository.Commit();

            return(result);
        }
        public void Handle(CancelSeatReservationCommand command)
        {
            var meetup = _repository.Load(command.MeetupId);

            meetup.CancelSeatReservation(command.ParticipantUserId);

            _repository.Commit();
        }
Exemplo n.º 3
0
        public Result Handle(ReserveSeatCommand command)
        {
            var meetup = _repository.Load(command.MeetupId);

            var result = meetup.ReserveSeat(command.ParticipantUserId, DateTime.UtcNow);

            _repository.Commit();

            return(result);
        }
        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);
        }
Exemplo n.º 5
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);
        }