示例#1
0
        public Barbecue AddParticipant(int idBarbecue, BarbecueParticipant barbecueParticipant)
        {
            if (!barbecueParticipant.IsValid())
            {
                throw new ArgumentException("Barbecue participant entity is not valid");
            }
            if (idBarbecue < 1)
            {
                throw new ArgumentException("Barbecue Id is not valid");
            }

            var bbq = _barbecueRepository.GetById(idBarbecue); if (bbq == null)

            {
                throw new ArgumentException("Barbecue not found");
            }
            bbq.BarbecueParticipants.Add(barbecueParticipant);

            _barbecueRepository.Update(bbq);
            _barbecueRepository.Commit();

            return(bbq);
        }
示例#2
0
 public ActionResult <Barbecue> AddParticipant([FromRoute] int id, [FromBody] BarbecueParticipant barbecueParticipant)
 {
     return(_barbecueServices.AddParticipant(id, barbecueParticipant));
 }