예제 #1
0
 public async Task <Boolean> AddCourse(Course course)
 {
     try
     {
         _context.Courses.Add(course);
         return(0 < await _context.SaveChangesAsync());
     }
     catch
     {
         throw new Exception("Could not add Course for " + course.Id.ToString());
     }
 }
예제 #2
0
        public async Task <Guid> AddGolfRound(GolfRound golfRound)
        {
            try
            {
                await _context.GolfRounds.AddAsync(golfRound);

                await _context.SaveChangesAsync();

                return(golfRound.Id);
            }
            catch
            {
                throw new Exception("Could not add Golf Round for " + golfRound.Id.ToString());
            }
        }
예제 #3
0
        public async Task <Boolean> AddPartner(Partner player)
        {
            try
            {
                if (!CheckPartner(player))
                {
                    await _context.Partners.AddAsync(player);

                    return(0 < await _context.SaveChangesAsync());
                }
                return(false);
            }
            catch
            {
                throw new Exception("Could not add Partner for " + player.Id.ToString());
            }
        }
예제 #4
0
        public async Task <Guid> AddPlayer(Player player)
        {
            if (_userContext.Users.Where(u => (new Guid(u.Id)).Equals(player.UserId)).Count() > 0)
            {
                try
                {
                    player.Modified = DateTime.Now;
                    _context.Players.Add(player);
                    await _context.SaveChangesAsync();

                    return(player.Id);
                }
                catch
                {
                    throw new Exception("Could not add Player for " + player.Id.ToString());
                }
            }
            else
            {
                throw new Exception("User does not exist " + player.Id.ToString());
            }
        }
        public async Task <Boolean> AddHandicap(Handicap handicap)
        {
            try
            {
                await _context.Handicaps.AddAsync(handicap);

                return(0 < await _context.SaveChangesAsync());
            }
            catch
            {
                throw new Exception("Could not add Handicap");
            }
        }
예제 #6
0
        public async Task <Boolean> AddScore(Score score)
        {
            try
            {
                if (_context.Scores.Where(s => s.GolfRoundId.Equals(score.GolfRoundId)).Count() < 4 &&
                    _context.Scores.Where(s => s.PlayerId.Equals(score.PlayerId) && s.GolfRoundId.Equals(score.GolfRoundId)).Count() < 1)
                {
                    await _context.Scores.AddAsync(score);

                    return(0 < await _context.SaveChangesAsync());
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                throw new Exception("Could not add score for " + score.Id.ToString());
            }
        }