Ejemplo n.º 1
0
 private void DeleteCurrentTeamRecord(string dreamTeamId)
 {
     try
     {
         using (TBCL3FantasyLeagueEntities context = new TBCL3FantasyLeagueEntities())
         {
             try
             {
                 if (context.Database.Exists())
                 {
                     DreamTeam dreamTeam = new DreamTeam()
                     {
                         DreamTeamId = dreamTeamId
                     };
                     context.DreamTeams.Attach(dreamTeam);
                     context.DreamTeams.Remove(dreamTeam);
                     context.SaveChanges();
                 }
                 else
                 {
                     throw new ApplicationException("Connectivity issues with database.Contact Admin");
                 }
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Connectivity issues with database.Contact Admin. \n Details: " + ex.Message);
     }
 }
Ejemplo n.º 2
0
 private void UpdateDreamTeamPlayers(string dreamTeamId, List <PlayerInfo> players)
 {
     try
     {
         using (TBCL3FantasyLeagueEntities context = new TBCL3FantasyLeagueEntities())
         {
             try
             {
                 if (context.Database.Exists())
                 {
                     foreach (var item in players)
                     {
                         context.DreamTeamPlayers.Add(new DreamTeamPlayer()
                         {
                             Name             = item.Name,
                             Team_id          = item.Team_Id,
                             Points           = item.Points,
                             IsGirlplayer     = item.IsGirlPlayer,
                             runsScored       = 0,
                             noOfFours        = 0,
                             noOfSixes        = 0,
                             noOfwickets      = 0,
                             maidenOver       = 0,
                             noOfCatches      = 0,
                             stumping         = 0,
                             runoutThrow      = 0,
                             runoutCatch      = 0,
                             duck             = 0,
                             bonusOnRunsScore = 0,
                             bonusOnWickets   = 0,
                             totalPoints      = 0,
                             DreamTeamId      = dreamTeamId
                         });
                     }
                     context.SaveChanges();
                 }
                 else
                 {
                     new ApplicationException("Connectivity issues with database.Contact Admin");
                 }
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Connectivity issues with database.Contact Admin. \n Details: " + ex.Message);
     }
 }
Ejemplo n.º 3
0
        private void UpdateDreamTeam(string dreamTeamName, string captainName, string viceCaptainName, string dreamTeamId)
        {
            DreamTeam dreamTeamObj = new DreamTeam()
            {
                TeamName      = dreamTeamName,
                Captain       = captainName,
                ViceCaptain   = viceCaptainName,
                DateSubmitted = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")),
                DreamTeamId   = dreamTeamId,
                MoneyPaid     = false
            };

            try
            {
                using (TBCL3FantasyLeagueEntities context = new TBCL3FantasyLeagueEntities())
                {
                    try
                    {
                        if (context.Database.Exists())
                        {
                            context.DreamTeams.Add(dreamTeamObj);
                            context.SaveChanges();
                        }
                        else
                        {
                            new ApplicationException("Connectivity issues with database.Contact Admin");
                        }
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == 2627)
                        {
                            new ApplicationException("Someone already reserved the team name today.Choose different team name");
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Connectivity issues with database.Contact Admin. \n Details: " + ex.Message);
            }
        }