Ejemplo n.º 1
0
        public IHttpActionResult CreateTeam(Int32 eventID, Int32 tournamentID, CreateTeamRequest request)
        {
            BaseViewModel                           viewmodel               = new BaseViewModel();
            TournamentDataController                dataCtrl                = new TournamentDataController();
            SeatDataController                      seatDataCtrl            = new SeatDataController();
            TournamentTeamDataController            teamDataCtrl            = new TournamentTeamDataController();
            TournamentTeamParticipantDataController teamParticipantDataCtrl = new TournamentTeamParticipantDataController();

            try
            {
                if (seatDataCtrl.GetCurrentUserSeats(eventID).FindAll(x => x.State >= 2).Count == 0)
                {
                    return(Error(viewmodel, "Du bist kein Teilnehmer dieser Veranstaltung. Bitte reserviere einen Platz."));
                }

                var team = teamDataCtrl.Insert(request.ToModel(tournamentID));
                JoinTournamentRequest _tmp = new JoinTournamentRequest()
                {
                    TeamID = team.ID
                };
                teamParticipantDataCtrl.Insert(_tmp.ToTeamModel());
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel, "Team wurde erstellt."));
        }
Ejemplo n.º 2
0
        public IHttpActionResult Join(Int32 eventID, Int32 tournamentID, JoinTournamentRequest request)
        {
            BaseViewModel      viewmodel    = new BaseViewModel();
            SeatDataController seatDataCtrl = new SeatDataController();
            TournamentParticipantDataController     participantDataCtrl     = new TournamentParticipantDataController();
            TournamentTeamParticipantDataController teamParticipantDataCtrl = new TournamentTeamParticipantDataController();

            try
            {
                if (seatDataCtrl.GetCurrentUserSeats(eventID).FindAll(x => x.State >= 2).Count == 0)
                {
                    return(Error(viewmodel, "Du bist kein Teilnehmer dieser Veranstaltung. Bitte reserviere einen Platz."));
                }

                if (request.TeamID == null)
                {
                    participantDataCtrl.Insert(request.ToModel(tournamentID));
                }
                else
                {
                    teamParticipantDataCtrl.Insert(request.ToTeamModel());
                }
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel, "Anmeldung erfolgreich."));
        }