public Barbecue Run(string barbecueId, Participant[] participants)
        {
            var barbecue = _barbecueRepository.FindOne(barbecueId);

            if (barbecue == null)
            {
                throw new ArgumentException("Churrasco não encontrado");
            }

            var update = Builders <Barbecue> .Update.Set(x => x.Participants, participants);

            _barbecueRepository.Update(barbecueId, update);

            return(barbecue);
        }
Exemplo n.º 2
0
        public Barbecue Run(string barbecueId, Participant participant)
        {
            var barbecue = _barbecueRepository.FindOne(barbecueId);

            if (barbecue == null)
            {
                throw new ArgumentException("Churrasco não encontrado");
            }

            if (barbecue.Participants.Any(x => x.Name.Equals(participant.Name, StringComparison.InvariantCultureIgnoreCase)))
            {
                throw new Exception("Participante já cadastrado");
            }

            var participants = barbecue.Participants.ToList();

            participants.Add(participant);

            var update = Builders <Barbecue> .Update.Set(x => x.Participants, participants);

            _barbecueRepository.Update(barbecueId, update);

            return(barbecue);
        }