Example #1
0
        public HttpResponseMessage ListAll()
        {
            try
            {
                List <TournamentModelGet> list = new List <TournamentModelGet>();

                TournamentRepository rep = new TournamentRepository();
                foreach (Tournament t in rep.ListAll())
                {
                    TournamentModelGet model = new TournamentModelGet();
                    model.Tournament_ID = t.Tournament_ID;
                    model.Name          = t.Name;
                    model.NumberOfTeams = t.NumberOfTeams;
                    model.Start         = t.Start;

                    list.Add(model);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, list));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message));
            }
        }
Example #2
0
        public HttpResponseMessage Get(int id)
        {
            try
            {
                TournamentRepository rep = new TournamentRepository();
                Tournament           t   = rep.GetByID(id);

                TournamentModelGet model = new TournamentModelGet();
                model.Tournament_ID = t.Tournament_ID;
                model.Name          = t.Name;
                model.NumberOfTeams = t.NumberOfTeams;
                model.Start         = t.Start;

                return(Request.CreateResponse(HttpStatusCode.OK, model));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message));
            }
        }