Esempio n. 1
0
        public async Task <bool> PostPlayer([FromBody] PlayerSelections selections)

        {
            var PlayerCount = _context.PlayerSelection.Where(p => p.TeamName == selections.TeamName).CountAsync().Result;

            if (PlayerCount < 15)
            {
                try
                {
                    foreach (int i in selections.PlayerKeys)
                    {
                        var selection = new PlayerSelection(selections.TeamName, i);
                        _context.PlayerSelection.Add(selection);

                        await _context.SaveChangesAsync();
                    }
                }
                catch (DbUpdateException)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public async Task <bool> PostTeam([FromBody] Team team)
        {
            try
            {
                _context.Team.Add(team);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                return(false);
            }

            return(true);
        }