public async Task <IActionResult> Edit(TournamentViewModel model) { if (ModelState.IsValid) { if (ModelState.IsValid) { string path = model.LogoPath; if (model.LogoFile != null) { path = await _imageHelper.UploadImageAsync(model.LogoFile, "Tournaments"); } if (model.EndDate.Date <= model.StartDate.Date) { ModelState.AddModelError(string.Empty, "The end date cannot be less than the start date"); } TournamentEntity tournamentEntity = _converterHelper.ToTournamentEntity(model, path, false); _context.Update(tournamentEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(model)); }
/// <summary> /// Copies the tournament basic data and the tournament leg data /// from the source to a new target tournament. The new tournament id must /// not exist. For start and end date of leg data 1 year is added. /// </summary> /// <param name="fromTournamentId">Existing source tournament id.</param> /// <returns>True, if creation was successful, false otherwise.</returns> public async Task <bool> CopyTournament(long fromTournamentId) { var now = DateTime.Now; var tournament = await _appDb.TournamentRepository.GetTournamentAsync(new PredicateExpression(TournamentFields.Id == fromTournamentId), CancellationToken.None); if (tournament is null) { throw new NullReferenceException($"'{fromTournamentId}' not found."); } var newTournament = new TournamentEntity { IsPlanningMode = true, Name = tournament.Name, Description = tournament.Description.Length == 0 ? null : tournament.Description, TypeId = tournament.TypeId, IsComplete = false, CreatedOn = now, ModifiedOn = now, }; _appDb.GenericRepository.SaveEntity(newTournament, true, false); tournament.NextTournamentId = newTournament.Id; tournament.ModifiedOn = now; // save last tournament return(_appDb.GenericRepository.SaveEntity(tournament, true, false)); }
/// <summary> /// Gets all rounds and their teams for a tournament prefetched. /// </summary> /// <param name="tournament">Tournament entity to use.</param> /// <example><![CDATA[ /// RoundEntity round = tir.Where(t => t.Round.Name == "A").First().Round; /// TeamEntity team = tir.Where(t => t.Team.Name == "Die Unglaublichen").First().Team; /// RoundEntity[] rounds = tir.Select(x => x.Round).Distinct().ToArray(); /// TeamEntity[] teamsOfRound = tir.Where(x => x.Round.Name == "F").Select(y => y.Team).ToArray(); /// ]]></example> /// <returns>Returns the TeamInRoundEntity for the tournament id.</returns> public virtual EntityCollection <TeamInRoundEntity> GetTeamsAndRounds(TournamentEntity tournament) { IPrefetchPath2 prefetchPathTeamInRound = new PrefetchPath2(EntityType.TeamInRoundEntity) { TeamInRoundEntity.PrefetchPathRound, TeamInRoundEntity.PrefetchPathTeam }; var filter = new RelationPredicateBucket(); filter.Relations.Add(TeamInRoundEntity.Relations.RoundEntityUsingRoundId); filter.PredicateExpression.Add(RoundFields.TournamentId == tournament.Id); IPrefetchPath2 prefetchPathTeam = new PrefetchPath2(EntityType.TeamEntity) { TeamEntity.PrefetchPathTeamInRounds }; var tir = new EntityCollection <TeamInRoundEntity>(); using var da = _dbContext.GetNewAdapter(); da.FetchEntityCollection(tir, filter, prefetchPathTeamInRound); da.CloseConnection(); return(tir); }
private async Task LoadEntitiesAsync(CancellationToken cancellationToken) { _tournament = await _appDb.TournamentRepository.GetTournamentEntityForMatchPlannerAsync( _tenantContext.TournamentContext.MatchPlanTournamentId, cancellationToken); AreEntitiesLoaded = true; }
public async Task <IActionResult> Create(TournamentViewModel tournamentViewModel) { if (ModelState.IsValid) { string path = string.Empty; if (tournamentViewModel.LogoFile != null) { path = await _imageHelper.UploadImageAsync(tournamentViewModel.LogoFile, "Tournaments"); } TournamentEntity tournamentEntity = _converterHelper.ToTournamentEntity(tournamentViewModel, path, true); _context.Add(tournamentEntity); try { await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { if (ex.InnerException.Message.Contains("duplicate")) { ModelState.AddModelError(string.Empty, $"Already exists the team {tournamentEntity.Name}."); } else { ModelState.AddModelError(string.Empty, ex.InnerException.Message); } } } return(View(tournamentViewModel)); }
public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } TournamentEntity tournamentEntity = await _context.Tournaments .Include(t => t.Groups) .ThenInclude(t => t.Matches) .ThenInclude(t => t.Local) .Include(t => t.Groups) .ThenInclude(t => t.Matches) .ThenInclude(t => t.Visitor) .Include(t => t.Groups) .ThenInclude(t => t.GroupDetails) .FirstOrDefaultAsync(m => m.Id == id); if (tournamentEntity == null) { return(NotFound()); } return(View(tournamentEntity)); }
public static ParticipationAggregate Restore(ParticipationId id, TeamEntity team, TournamentEntity tournamentEntity, StepEntity stepEntity, DateTime startDate, DateTime?endDate, decimal calculatedScore, IList <FunctionEntity> functions) { return(new(id, team, tournamentEntity, stepEntity, startDate, endDate, calculatedScore, functions)); }
public MatchPlanner(AppDb appDb, OrganizationContext organizationContext, long tournamentId) { _organizationContext = organizationContext; _appDb = appDb; _tournament = new TournamentEntity(tournamentId); _venue = new EntityCollection <VenueEntity>(new VenueEntityFactory()); _availableMatchDates = new AvailableMatchDates(_appDb, this); }
public async Task <IActionResult> GetPositionsByTournament([FromRoute] int id) //id del torneo { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TournamentEntity tournament = await _context.Tournaments.Include(t => t.Groups).Include(t => t.Groups) .ThenInclude(g => g.Matches) .ThenInclude(m => m.Predictions) .ThenInclude(p => p.User) .ThenInclude(u => u.Team) .FirstOrDefaultAsync(t => t.Id == id); if (tournament == null) { return(BadRequest("Tournament doesn't exists.")); } //creamos la lista de predicciones List <PositionResponse> positionsResponses = new List <PositionResponse>(); foreach (GroupEntity group in tournament.Groups) //por cada grupo en el torneo { foreach (MatchEntity match in group.Matches) //por cda partido del grupo { foreach (PredictionEntity prediction in match.Predictions) //por cada predicciòn del partido { //buscamos si el user realizò una predicciòn del partido PositionResponse positionResponse = positionsResponses.FirstOrDefault(p => p.UserResponse.Id == prediction.User.Id); if (positionResponse == null) { positionsResponses.Add(new PositionResponse //adicionamos a la lista { Points = prediction.Points, //suma los puntos obtenidos UserResponse = _coverter.ToUserResponse(prediction.User) }); } else { positionResponse.Points += prediction.Points; //suma los puntos si el user no es nuevo } } } } //ordenamos descendentemente por los puntos List <PositionResponse> list = positionsResponses.OrderByDescending(p => p.Points).ToList(); int i = 1; foreach (PositionResponse item in list) //a cada item { item.Ranking = i; //le asignamos el puesto i++; } return(Ok(list)); }
public ServiceMessage Update(EventEditDTO eventEditDTO) { string message = ""; bool success = true; string sportName = eventEditDTO.SportName; string tournamentName = eventEditDTO.TournamentName; DateTime dateOfTournamentStart = eventEditDTO.DateOfTournamentStart; string notes = eventEditDTO.Notes; DateTime dateOfEvent = eventEditDTO.DateOfEvent; List <ParticipantBaseDTO> participants = eventEditDTO.Participants; if (success = Validate(eventEditDTO, ref message)) { try { TournamentEntity tournamentEntity = unitOfWork.Tournaments.Get(tournamentName, sportName, dateOfTournamentStart); if (tournamentEntity != null) { IEnumerable <ParticipantEntity> participantEntities = participants .Select(p => unitOfWork.Participants.Get(p.Name, p.SportName, p.CountryName)) .ToList(); EventEntity eventEntity = unitOfWork .Events .Get(sportName, tournamentName, dateOfEvent, participantEntities); if (eventEntity != null) { eventEntity.DateOfEvent = eventEditDTO.NewDateOfEvent; eventEntity.Notes = eventEditDTO.Notes; unitOfWork.Commit(); message = "Edited event"; } else { message = "Such event was not found"; success = false; } } else { message = "Such tournament was not found"; success = false; } } catch (Exception ex) { message = ExceptionMessageBuilder.BuildMessage(ex); success = false; } } return(new ServiceMessage(message, success)); }
public async Task <IActionResult> GetPositionsByTournament([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TournamentEntity tournament = await _context.Tournaments .Include(t => t.Groups) .ThenInclude(g => g.Matches) .ThenInclude(m => m.Predictions) .ThenInclude(p => p.User) .ThenInclude(u => u.Team) .FirstOrDefaultAsync(t => t.Id == id); if (tournament == null) { return(BadRequest("Tournament doesn't exists.")); } List <PositionResponse> positionResponses = new List <PositionResponse>(); foreach (GroupEntity groupEntity in tournament.Groups) { foreach (MatchEntity matchEntity in groupEntity.Matches) { foreach (PredictionEntity predictionEntity in matchEntity.Predictions) { PositionResponse positionResponse = positionResponses.FirstOrDefault(pr => pr.UserResponse.Id == predictionEntity.User.Id); if (positionResponse == null) { positionResponses.Add(new PositionResponse { Points = predictionEntity.Points, UserResponse = _converterHelper.ToUserResponse(predictionEntity.User), }); } else { positionResponse.Points += predictionEntity.Points; } } } } List <PositionResponse> list = positionResponses.OrderByDescending(pr => pr.Points).ToList(); int i = 1; foreach (PositionResponse item in list) { item.Ranking = i; i++; } return(Ok(list)); }
public virtual IQueryable <TeamEntity> GetTeamAsQuery(TournamentEntity t) { using var da = _dbContext.GetNewAdapter(); var metaData = new LinqMetaData(da); var result = (metaData.TeamInRound.Where(tir => tir.Round.TournamentId == t.Id) .Select(tir => tir.Team)); da.CloseConnection(); return(result); }
protected ParticipationAggregate(ParticipationId id, TeamEntity team, TournamentEntity tournamentEntity, StepEntity stepEntity, DateTime startDate, DateTime?endDate, decimal calculatedScore, IList <FunctionEntity> functions) : base(id) { Team = team; TournamentEntity = tournamentEntity; StepEntity = stepEntity; _functions = new List <FunctionEntity>(functions); StartDate = startDate; EndDate = endDate; CalculatedScore = calculatedScore; }
public ServiceMessage Create(TournamentBaseDTO tournamentCreateDTO) { string message = ""; bool success = true; if (success = Validate(tournamentCreateDTO, ref message)) { string name = tournamentCreateDTO.Name; string sportName = tournamentCreateDTO.SportName; DateTime dateOfStart = tournamentCreateDTO.DateOfStart; try { SportEntity sportEntity = unitOfWork.Sports.Get(sportName); if (sportEntity != null) { bool exists = unitOfWork.Tournaments.Exists(name, sportEntity.Id, dateOfStart); if (!exists) { TournamentEntity tournamentEntity = new TournamentEntity { Name = name, DateOfStart = dateOfStart, SportId = sportEntity.Id }; unitOfWork.Tournaments.Add(tournamentEntity); unitOfWork.Commit(); message = "Created new tournament"; } else { message = "Such tournament already exists"; success = false; } } else { message = "No such sport found"; success = false; } } catch (Exception ex) { message = ExceptionMessageBuilder.BuildMessage(ex); success = false; } } return(new ServiceMessage(message, success)); }
public TournamentViewModel ToTournamentViewModel(TournamentEntity tournamentEntity) { return(new TournamentViewModel { EndDate = tournamentEntity.EndDate, Groups = tournamentEntity.Groups, Id = tournamentEntity.Id, IsActive = tournamentEntity.IsActive, LogoPath = tournamentEntity.LogoPath, Name = tournamentEntity.Name, StartDate = tournamentEntity.StartDate }); }
public ServiceMessage Update(TournamentEditDTO tournamentEditDTO) { string message = ""; bool success = true; if (success = Validate(tournamentEditDTO, ref message)) { string sportName = tournamentEditDTO.SportName; string oldName = tournamentEditDTO.Name; DateTime oldDateOfStart = tournamentEditDTO.DateOfStart; string newName = tournamentEditDTO.NewName; DateTime newDateOfStart = tournamentEditDTO.NewDateOfStart; try { TournamentEntity tournamentEntity = unitOfWork.Tournaments.Get(oldName, sportName, oldDateOfStart); if (tournamentEntity != null) { bool anyDateEarlier = tournamentEntity.Events.Any(_event => _event.DateOfEvent < tournamentEntity.DateOfStart); if (!anyDateEarlier) { tournamentEntity.Name = newName; tournamentEntity.DateOfStart = newDateOfStart; unitOfWork.Commit(); message = "Edited tournament"; } else { message = "Tournament cannot start later then event"; success = false; } } else { message = "Such tournament was not found"; success = false; } } catch (Exception ex) { message = ExceptionMessageBuilder.BuildMessage(ex); success = false; } } return(new ServiceMessage(message, success)); }
public async Task <IActionResult> GetPredictionsForUserInOneTournament([FromRoute] int id, [FromRoute] int id2) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TournamentEntity tournament = await _context.Tournaments.FindAsync(id); if (tournament == null) { return(BadRequest("Este Torneo no existe.")); } Player player = await _context.Players .Include(u => u.User.FavoriteTeam) .ThenInclude(l => l.League) .Include(pr => pr.Predictions) .ThenInclude(p => p.Match) .ThenInclude(m => m.Local) .ThenInclude(l => l.League) .Include(pr => pr.Predictions) .ThenInclude(p => p.Match) .ThenInclude(m => m.Visitor) .ThenInclude(l => l.League) .Include(pr => pr.Predictions) .ThenInclude(p => p.Match) .ThenInclude(p => p.Group) .ThenInclude(p => p.Tournament) .FirstOrDefaultAsync(u => u.Id == id2); if (player == null) { return(BadRequest("Este Usuario no existe.")); } // Add precitions already done List <PredictionResponse3> predictionResponses = new List <PredictionResponse3>(); foreach (PredictionEntity predictionEntity in player.Predictions) { if (predictionEntity.Match.Group.Tournament.Id == id && predictionEntity.Match.IsClosed) { predictionResponses.Add(_converterHelper.ToPredictionResponse3(predictionEntity)); } } return(Ok(predictionResponses.OrderBy(pr => pr.Id).ThenBy(pr => pr.MatchDate))); }
/// <summary> /// Adds new tournament. /// </summary> /// <param name="newEntity">The tournament for adding.</param> public void Add(Tournament newEntity) { var tournament = new TournamentEntity(); DomainToDal.Map(tournament, newEntity); if (!_dbStorageSpecification.IsSatisfiedBy(tournament)) { throw new InvalidEntityException(); } _dalTournaments.Add(tournament); _unitOfWork.Commit(); MapIdentifiers(newEntity, tournament); }
public TournamentViewModel ToTournamentViewModel(TournamentEntity tournamentEntity) { return(new TournamentViewModel { EndDate = tournamentEntity.EndDate.ToLocalTime(), Groups = tournamentEntity.Groups, Id = tournamentEntity.Id, IsActive = tournamentEntity.IsActive, LogoPath = tournamentEntity.LogoPath, Name = tournamentEntity.Name, StartDate = tournamentEntity.StartDate.ToLocalTime(), SportId = tournamentEntity.Sport.Id, Sports = _combosHelper.GetComboSports() }); }
public void SetTournamentID(TournamentEntity tournamententity, MatchEntity matchentity) { try { using (conn) { conn.Open(); SqlCommand myCommand = new SqlCommand("UPDATE Wedstrijd SET Toernooi_ID = '" + tournamententity.ID + "' WHERE ID = '" + matchentity.MatchID + "')", conn); myCommand.ExecuteNonQuery(); conn.Close(); } } catch (SqlException) { } }
public async Task<IActionResult> Edit(int? id) { if (id == null) { return NotFound(); } TournamentEntity tournamentEntity = await _context.Tournaments.FindAsync(id); if (tournamentEntity == null) { return NotFound(); } TournamentViewModel model = _converterHelper.ToTournamentViewModel(tournamentEntity); return View(model); }
public void RemoveTournament(TeamEntity teamentity, TournamentEntity tournamententity) { try { using (conn) { conn.Open(); SqlCommand mycommand = new SqlCommand("RemoveTournament(" + teamentity.ID + "," + tournamententity.ID + "; ", conn); mycommand.ExecuteNonQuery(); conn.Close(); } } catch (SqlException) { } }
public async Task <string> Handle(CreateParticipationCommand request, CancellationToken cancellationToken) { var tournamentNavigation = await _readTournamentRepository.GetOneTournamentNavigationById(request.TournamentId); if (tournamentNavigation is null) { throw new NotFoundException(request.TournamentId.ToString(), "Tournament"); } var stepNavigation = await _readStepRepository.GetOneStepNavigationById(request.StepId); if (stepNavigation is null) { throw new NotFoundException(request.StepId.ToString(), "Step"); } var teamNavigation = await _readTeamRepository .GetOneTeamNavigationByIdAsync(request.TeamId); if (teamNavigation is null) { throw new NotFoundException(request.TeamId.ToString(), "Team"); } if (await _readParticipationRepository.ParticipationExistsByTournamentStepTeamIds(request.TournamentId, request.StepId, request.TeamId)) { throw new ApplicationException( $"Participation for team : {request.TeamId} on tournament : {request.TournamentId} on step : {request.StepId} already exists"); } if (!await CanAddParticipation(request.TeamId, request.TournamentId, request.StepId)) { throw new ApplicationException("Participation cannot be created, finish previous first"); } var team = new TeamEntity(new TeamId(request.TeamId), teamNavigation.MembersIds.Select(memberId => new UserId(memberId)).ToList()); var step = new StepEntity(new StepId(request.StepId), stepNavigation.TournamentsIds.Select(tournamentId => new TournamentId(tournamentId)).ToList()); var tournament = new TournamentEntity(new TournamentId(request.TournamentId), tournamentNavigation.IsPublished); var participation = ParticipationAggregate.CreateNew(await _participationRepository.NextIdAsync(), team, tournament, step, _timeService.Now()); await _participationRepository.SetAsync(participation); return(participation.Id.ToString()); }
public EnterResultViewModel(TournamentEntity tournament, RoundEntity round, MatchEntity match, MatchRuleEntity matchRule, IList <TeamInRoundEntity> teamInRound, Axuno.Tools.DateAndTime.TimeZoneConverter timeZoneConverter) { Tournament = tournament ?? throw new ArgumentNullException(nameof(tournament)); Round = round ?? throw new ArgumentNullException(nameof(round)); Match = match ?? throw new ArgumentNullException(nameof(match)); Opponent = new Opponent( teamInRound.FirstOrDefault(o => o.TeamId == match.HomeTeamId)?.TeamNameForRound ?? throw new ArgumentNullException(nameof(teamInRound)), teamInRound.FirstOrDefault(o => o.TeamId == match.GuestTeamId)?.TeamNameForRound ?? throw new ArgumentNullException(nameof(teamInRound)));; TimeZoneConverter = timeZoneConverter ?? throw new ArgumentNullException(nameof(timeZoneConverter)); _localizer = CreateModelStringLocalizer(); _maxNumberOfSets = matchRule.MaxNumOfSets(); MapEntityToFormFields(); }
public TournamentResponse ToTournamentResponse(TournamentEntity tournamentEntity) { return(new TournamentResponse { EndDate = tournamentEntity.EndDate, Id = tournamentEntity.Id, IsActive = tournamentEntity.IsActive, LogoPath = tournamentEntity.LogoPath, Name = tournamentEntity.Name, StartDate = tournamentEntity.StartDate, Groups = tournamentEntity.Groups?.Select(g => new GroupResponse { Id = g.Id, Name = g.Name, GroupDetails = g.GroupDetails?.Select(gd => new GroupDetailResponse { GoalsAgainst = gd.GoalsAgainst, GoalsFor = gd.GoalsFor, Id = gd.Id, MatchesLost = gd.MatchesLost, MatchesPlayed = gd.MatchesPlayed, MatchesTied = gd.MatchesTied, MatchesWon = gd.MatchesWon, Team = ToTeamResponse(gd.Team) }).ToList(), Matches = g.Matches?.Select(m => new MatchResponse { Date = m.Date, GoalsLocal = m.GoalsLocal, GoalsVisitor = m.GoalsVisitor, Id = m.Id, IsClosed = m.IsClosed, Local = ToTeamResponse(m.Local), Visitor = ToTeamResponse(m.Visitor), Predictions = m.Predictions?.Select(p => new PredictionResponse { GoalsLocal = p.GoalsLocal, GoalsVisitor = p.GoalsVisitor, Id = p.Id, Points = p.Points, User = ToUserResponse(p.User) }).ToList() }).ToList() }).ToList() }); }
public DataServiceMessage <IEnumerable <ParticipantBaseDTO> > GetByTournament(TournamentBaseDTO tournamentBaseDTO) { string message; bool success = true; IEnumerable <ParticipantBaseDTO> partipantDisplayDTOs = null; string name = tournamentBaseDTO.Name; string sportName = tournamentBaseDTO.SportName; DateTime dateOfStart = tournamentBaseDTO.DateOfStart; try { TournamentEntity tournamentEntity = unitOfWork.Tournaments.Get(name, sportName, dateOfStart); if (tournamentEntity != null) { IEnumerable <ParticipantEntity> participantEntities = tournamentEntity.Participants; partipantDisplayDTOs = participantEntities .Select(participant => { return(new ParticipantBaseDTO { Name = participant.Name, CountryName = participant.Country.Name, SportName = participant.Sport.Type }); }) .OrderBy(p => p.Name) .ToList(); message = "Got all participants"; } else { message = "No such tournament found"; success = false; } } catch (Exception ex) { message = ExceptionMessageBuilder.BuildMessage(ex); success = false; } return(new DataServiceMessage <IEnumerable <ParticipantBaseDTO> >(partipantDisplayDTOs, message, success)); }
public void RemoveTeam(TeamEntity teamentity, TournamentEntity tournamententity) { SqlConnection conn = new SqlConnection("Server = mssql.fhict.local; Database = dbi346272; User Id = dbi346272; Password = Test123"); try { using (conn) { conn.Open(); SqlCommand myCommand = new SqlCommand("REMOVE Team_Toernooi WHERE Team_ID = '" + teamentity.ID + "' and Toernooi_ID = '" + tournamententity.ID + "'", conn); myCommand.ExecuteNonQuery(); conn.Close(); } } catch (SqlException) { } }
private void MapIdentifiers(Tournament to, TournamentEntity from) { to.Id = from.Id; foreach (DivisionEntity divisionEntity in from.Divisions) { Division divisionDomain = to.Divisions.Where(d => d.Name == divisionEntity.Name).First(); divisionDomain.Id = divisionEntity.Id; divisionDomain.TournamentId = divisionEntity.TournamentId; foreach (GroupEntity groupEntity in divisionEntity.Groups) { Group groupDomain = divisionDomain.Groups.Where(g => g.Name == groupEntity.Name).First(); groupDomain.Id = groupEntity.Id; groupDomain.DivisionId = divisionEntity.Id; } } }
public void AddMatch(TeamEntity Team1entity, TeamEntity Team2entity, TournamentEntity tournamententity) { SqlConnection conn = new SqlConnection("Server = mssql.fhict.local; Database = dbi346272; User Id = dbi346272; Password = Test123"); try { using (conn) { conn.Open(); SqlCommand myCommand = new SqlCommand("INSERT INTO Wedstrijd (Toernooi_ID, Team1_ID, Team2_ID) Values('" + tournamententity.ID + "', '" + Team1entity.ID + "', '" + Team2entity.ID + "')", conn); myCommand.ExecuteNonQuery(); conn.Close(); } } catch (SqlException) { } }
public void SetDescription(TournamentEntity entity) { SqlConnection conn = new SqlConnection("Server = mssql.fhict.local; Database = dbi346272; User Id = dbi346272; Password = Test123"); try { using (conn) { conn.Open(); SqlCommand myCommand = new SqlCommand("UPDATE toernooi SET Beschrijving = '" + entity.Description + "' WHERE ID = '" + entity.ID + "')", conn); myCommand.ExecuteNonQuery(); conn.Close(); } } catch (SqlException) { } }