Exemplo n.º 1
0
        public async Task <HttpResponseMessage> CreateCompetitionBoard(CompetitionBoard board)
        {
            var obj = new List <CompetitionBoard>()
            {
                board
            };

            return(await new RestConnector(token).PostObjectAsync(RestConstValues.COMPETITION_BOARD, obj));
        }
Exemplo n.º 2
0
        private Dictionary <string, string> GetCompetitionBoardDisplayOptions(CompetitionBoard competitionBoard)
        {
            var displayOptions = new Dictionary <string, string>();

            if (competitionBoard.clubId != 0)
            {
                var clubName = dataContext.clubs.FirstOrDefault(a => a.id == competitionBoard.clubId).name;
                displayOptions.Add(ConstValues.DO_CLUB_NAME, clubName);
            }

            return(displayOptions);
        }
Exemplo n.º 3
0
        public async Task <CompetitionBoard> UpdateCompetitionBoard(CompetitionBoard board)
        {
            var result   = new CompetitionBoard();
            var response = await new RestConnector(token).PutObjectAsync(RestConstValues.COMPETITION_BOARD, board);

            if (response.IsSuccessStatusCode)
            {
                result = JsonConvert.DeserializeObject <CompetitionBoard>(await response.Content.ReadAsStringAsync());
            }

            return(result);
        }
Exemplo n.º 4
0
        public static CompetitionBoard AddCompetitionBoardToContext(DataContext context)
        {
            var club             = AddClubToContext(context);
            var competition      = AddCompetitionToContext(context);
            var competitionBoard = new CompetitionBoard()
            {
                competitionId = competition.id, clubId = club.id
            };

            context.competitionBoards.Add(competitionBoard);
            context.SaveChanges();

            return(competitionBoard);
        }
Exemplo n.º 5
0
        public IActionResult UpdateCompetitionBoard(CompetitionBoard competitionBoard)
        {
            if (User.GetUser(dataContext).accessLevel >= ConstValues.AL_USER)
            {
                return(Forbid());
            }

            try
            {
                competitionBoard.updated = GenericUtils.GetDateTime();
                dataContext.competitionBoards.Update(competitionBoard);
                dataContext.SaveChanges();
                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }