Ejemplo n.º 1
0
        public EventDTO AddEvent(Guid teamId, UpsertEventDTO dto)
        {
            Team  team = this.teamRepository.GetById(teamId);
            Event evt  = EvtFromUpsertDto(dto, team);

            evt.Participations.Add(new Participation()
            {
                Created = DateTime.Now, Confirmed = false, UserId = team.ManagerId
            });

            team.AddEvent(evt);
            this.teamRepository.Update(team);

            evt = this.eventRepository.GetById(evt.Id);

            var responseDto = new EventDTO()
            {
                Id             = evt.Id,
                Name           = evt.Name,
                Description    = evt.Description,
                Start          = evt.Start,
                End            = evt.End,
                Type           = evt.Type,
                Participations = evt.Participations.Select(e => new ParticipationDTO()
                {
                    Confirmed = e.Confirmed, UserId = e.UserId, Username = e.User.Username
                }).ToList(),
                Discrepancies = new List <DiscrepancyDTO>()
            };

            return(responseDto);
        }