public CompetitionEditModel(CompetitionModel model, ClimbingContext db) { this.Iid = model.Iid; this.ShortName = model.ShortName; this.FullName = model.Name; this.StartDate = model.Start; this.StopDate = model.End; this.ApplicationsEndDate = model.ApplicationsEnd; this.Region = model.Region; this.RegionId = model.RegionId; this.Lead = model.Lead; this.Speed = model.Speed; this.Boulder = model.Boulder; this.ageGroups = new List <Comp_AgeGroupEdit>(); this.AllowLateApps = model.AllowLateAppl; this.ApplicationsEditEndDate = model.ApplicationsEditEnd; this.RequireSignature = model.SignApplications; this.AllowMultipleTeams = model.AllowMultipleTeams; var grpList = db.AgeGroups.ToList(); grpList.Sort(); foreach (var agr in grpList) { ageGroups.Add(new Comp_AgeGroupEdit(agr, (agr.CompetitionGroups.Count(cg => cg.CompetitionId == model.Iid) > 0))); } }
/// <summary> /// Renvoie la liste des evenements(competition ,stage) auquel un membre participe /// </summary> public static List <EvenementsModel> EvenementsAuquelIlParticipe(ClubModel club, MembreModel m) { BindingList <EvenementsModel> evenements = club.Evenements; List <EvenementsModel> participe = new List <EvenementsModel> { }; foreach (EvenementsModel e in evenements) { if (e is StageModel) { StageModel s = e as StageModel; if (StageService.ParticipeAuStage(m, s)) { participe.Add(e); } } if (e is CompetitionModel) { CompetitionModel c = e as CompetitionModel; if (c.EquipeDuClub.ListeDeJoueur.Contains(m)) { participe.Add(c); } } } return(participe); }
public ActionResult Insert(CompetitionModel model) { if (ModelState.IsValid) { // Attempt to register the contact try { S_Competition competition = new S_Competition(); competition.challengeid = model.challengeId; competition.description = model.description; competition.enddate = model.EndDate; competition.price = model.price; competition.startdate = model.StartDate; CompetitionManager.Insert(competition); return(RedirectToAction("Competition", "Competition", new { id = competition.challengeid })); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", "Fout"); } } // If we got this far, something failed, redisplay form return(View(model)); }
public String[] Validate(UserProfileModel user, ClimbingContext db, CompetitionModel comp) { PersonModel p; Comp_ClimberTeam e; return(Validate(user, db, comp, out p, out e)); }
public void AddCompetition() { CompetitionModel cm = new CompetitionModel(CompetitionName, FixedTeams, RandomisedTeams); CompetitionServices.GetOrCreateCompetition(cm); Competitions.Add(cm); }
/// <summary> /// Get Competition by Competition name. /// </summary> /// <param name="competitionName"></param> /// <returns></returns> public static CompetitionModel GetCompetitionByName(string competitionName) { CompetitionModel rValue = null; _conn = new SQLiteConnection(CONNECTION_STRING); _conn.Open(); using (SQLiteCommand command = _conn.CreateCommand()) { command.CommandText = "SELECT CompetitionID, CompetitionName, CompetitionImage, FixedTeams, RandomiseTeams, LogicallyDeleted" + " FROM Competitions" + " WHERE CompetitionName = @competitionName"; command.Parameters.AddWithValue("@competitionName", competitionName); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { rValue = new CompetitionModel(); rValue.CompetitionID = reader.GetInt64(0); rValue.CompetitionName = reader.GetString(1); rValue.CompetitionImage = reader.GetString(2); rValue.TeamsAreFixed = reader.GetBoolean(3); rValue.TeamsAreRandomised = reader.GetBoolean(4); rValue.LogicallyDeleted = reader.GetBoolean(5); } } _conn.Dispose(); return(rValue); }
public static CompetitionModel GetCompetition(int CompID) { CompetitionModel comp = new CompetitionModel(); using (MySqlConnection conn = new MySqlConnection(Configuration["DBConn:ConnectionString"])) { MySqlCommand cmd = new MySqlCommand("get_CompInfo", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CompID", CompID); conn.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { comp.CompID = Convert.ToInt32(rdr["CompID"]); comp.Date = Convert.ToDateTime(rdr["CompDate"]); comp.Description = rdr["CompDesc"].ToString(); comp.GameID = Convert.ToInt32(rdr["CompGameID"]); comp.GameTitle = rdr["GameTitle"].ToString(); comp.Title = rdr["CompName"].ToString(); } conn.Close(); } return(comp); }
public static List <CompetitionModel> GetCompetitions() { List <CompetitionModel> competitions = new List <CompetitionModel>(); using (MySqlConnection conn = new MySqlConnection(Configuration["DBConn:ConnectionString"])) { MySqlCommand cmd = new MySqlCommand("get_Competitions", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { CompetitionModel competition = new CompetitionModel(); competition.CompID = Convert.ToInt32(rdr["CompID"]); competition.Date = Convert.ToDateTime(rdr["CompDate"]); competition.Title = rdr["CompName"].ToString(); competition.GameID = Convert.ToInt32(rdr["GameID"]); competition.GameTitle = rdr["GameTitle"].ToString(); competitions.Add(competition); } conn.Close(); } return(competitions); }
public string GetCompetition() { CompetitionBL CBL = new CompetitionBL(); CompetitionModel CModel = new CompetitionModel(); return(CBL.GetCompetition(CModel)); }
public ActionResult AddCompetition(CompetitionModel competition) { UserModel owner = UserHandler.GetUserDataByToken(Request.Headers["authorization"]); owner = UserHandler.GetUserDataFromDbByLogin(owner.UserLogin); competition.ownerId = owner.Id; competition.ownerName = owner.UserName; #region dbAccess string sqlProc = "exec dbo.AddCompetition"; Dictionary <string, object> queryParams = new Dictionary <string, object> { { "@description", competition.description }, { "@startTime", competition.startTime.ToString("yyyy-MM-dd HH:mm") }, { "@endTime", competition.endTime.ToString("yyyy-MM-dd HH:mm") }, { "@placeOf", competition.placeOf }, { "@ownerId", competition.ownerId } }; DbHandler dbHandler = new DbHandler(); sqlProc = dbHandler.AddParamsToQuery(sqlProc, queryParams); try { UserModel userModel = new UserModel(); DataSet dataSet = dbHandler.GetSetFromDb(sqlProc, queryParams); return(Ok(competition)); } catch (Exception e) { return(Conflict(e.Message)); } #endregion return(Ok()); }
public GestionMatchModelView(ClubModel club, CompetitionModel competition) { this.club = club; this.matches = competition.Matches; MatchGagneCommand = new SimpleCommand(MatchGagne); MatchPerduCommand = new SimpleCommand(MatchPerdu); }
private void Initialisation() { Competition = new CompetitionModel(); ListeDesEquipes = club.Equipes; AjouterCompetitionCommand = new SimpleCommand(AjouterCompetition); }
/// <summary> /// Get a list of the players for a specific Competition. /// </summary> /// <param name="competition"></param> /// <returns></returns> public static List <GamePlayerModel> GetPlayerRoster(CompetitionModel competition) { List <GamePlayerModel> returnList = null; if (competition.TeamsAreFixed) { // If teams are fixed, then look for a regular team first. returnList = CompetitionDataAccess.GetRegularTeams(competition.CompetitionID); } // If a regular team is not found, then get all the players. if ((competition.TeamsAreRandomised) || (returnList == null)) { List <PlayerModel> players = CompetitionDataAccess.GetRegisteredPlayers(competition.CompetitionID); returnList = new List <GamePlayerModel>(players.Count); foreach (PlayerModel p in players) { GamePlayerModel tfm = new GamePlayerModel { CompetitionID = competition.CompetitionID, PlayerID = p.PlayerID, PlayerName = p.PlayerName }; returnList.Add(tfm); } } return(returnList); }
public CompetitionDeleteModel(CompetitionModel model) { this.Iid = model.Iid; this.Name = model.Name; this.From = model.Start; this.To = model.End; this.Region = model.Region.Name; }
/// <summary> /// Change les attributs de la competition en mettant à jour le match /// </summary> public CompetitionModel MiseAJourCompetition(CompetitionModel c, MatchModel m, bool clubestvainqueur) // Prend en parametre le match qui a été joué { MatchModel resultatmatch = JouerMatch(m, clubestvainqueur); c.Matches.Remove(m); c.Matches.Add(resultatmatch); return(c); }
public void Register(CompetitionModel competition) { if (competition == null) { throw new ArgumentNullException(nameof(competition)); } _context.Competition.Add(competition); }
/// <summary> /// Deprogrammer competition /// </summary> public static void SupprimerCompetition(ClubModel club, CompetitionModel c) { if (club.Evenements.Contains(c)) { club.Evenements.Remove(c); c.EquipeDuClub.NombreDePoint = c.EquipeDuClub.NombreDePoint - c.NombreDeJoueurParEquipe; // les points de malus pour une competition annulé EquipeService.ModifierEquipe(club, c.EquipeDuClub); } }
public ShowCompetitionsViewModel(NavigationService navigation) { this.navigation = navigation; model = new CompetitionModel(); Competitions = model.GetAllCompetitions().Convert(); SwitchViewCommand = new RelayCommand(x => OnSwitchView(), x => true); }
public string GetCompetition(CompetitionModel CModel) { BaseDL bdl = new BaseDL(); Function fun = new Function(); SqlParameter[] prms = new SqlParameter[0]; DataTable DtCompetition = bdl.SelectData("M_Competition_Select", prms); return(fun.DataTableToJSONWithJSONNet(DtCompetition)); }
public ActionResult Insert(long id) { S_Challenge s = ChallengeManager.GetChallenge(id); CompetitionModel m = new CompetitionModel(); m.challengeId = id; m.challenge = s.name; return(View(m)); }
/// <summary> /// Retourne true si l'ensemble des matches de la competitions on été joué /// </summary> public static bool CompetitionTerminer(ClubModel club, CompetitionModel competition) { foreach (MatchModel match in competition.Matches) { if (match.EstAJouer == true) // Si le matche n'est pas encore joué { return(false); } } return(false); }
public EditScoreViewModel() { targetModel = new TargetModel(); runModel = new RunModel(); stageModel = new StageModel(); competitionModel = new CompetitionModel(); shooterModel = new ShooterModel(); Competitions = competitionModel.GetAllCompetitions().Convert(); Shooters = shooterModel.GetAllShooters().Convert(); }
/// <summary> /// Create a new Competition. /// Before insertion, checks to see if it exists. /// </summary> /// <param name="competition"></param> /// <returns>Returns the CompetitionModel (with CompetitionID populated) or null if not created.</returns> public static CompetitionModel GetOrCreateCompetition(CompetitionModel competition) { CompetitionModel rValue = CompetitionDataAccess.GetCompetitionByName(competition.CompetitionName); if (rValue == null) { rValue = CompetitionDataAccess.InsertCompetition(competition); } return(rValue); }
public static CompetitionApiModel ToApi(this CompetitionModel model) { CompetitionApiModel res = new CompetitionApiModel(); res.Iid = model.Iid; res.FullName = model.Name; res.ShortName = model.ShortName; res.DateStart = model.Start; res.DateEnd = model.End; res.Rules = CompetitionRules.International; return(res); }
public int Put([FromBody] CompetitionModel model) { string message = competitionBusiness.Update(model); int resultCode = 0; if (message == CommonResource.ResourceManager.GetString("SuccessMessage")) { return(resultCode = 1); } return(resultCode); }
public ActionResult Edit(CompetitionModel model) { if (ModelState.IsValid) { // Attempt to save the competition try { S_Competition competition = CompetitionManager.GetCompetition(model.Id); competition.challengeid = model.challengeId; competition.description = model.description; competition.enddate = model.EndDate; competition.startdate = model.StartDate; competition.price = model.price; competition.id = model.Id; CompetitionManager.Update(competition); CompetitionManager.DeleteAllBowlingCentersByCompetition(competition.id); // setup properties var selectedBowlingCenters = new List <C_Checkbox>(); var postedBowlingCenterIds = new string[0]; if (model.PostedBowlingCenters == null) { model.PostedBowlingCenters = new C_PostedCheckbox(); } // if a view model array of posted ids exists // and is not empty, save selected ids if (model.PostedBowlingCenters.CheckboxIds != null && model.PostedBowlingCenters.CheckboxIds.Any()) { postedBowlingCenterIds = model.PostedBowlingCenters.CheckboxIds; foreach (var id in postedBowlingCenterIds) { CompetitionManager.InsertBowlingcenterForCompetition(competition.id, long.Parse(id)); } } TempData["message"] = "De competitie met nummer " + competition.id + " is aangepast."; return(RedirectToAction("competition", "Competition", new { id = model.challengeId })); } catch (Exception e) { TempData["error"] = "Er is een fout opgetreden"; } } // If we got this far, something failed, redisplay form return(View(model)); }
private Comp_AgeGroupModel SaveOneAgeGroup(CompetitionModel comp, Comp_AgeGroupApiModel group) { var compYear = comp.Start.Year; var minAge = compYear - group.YearYoung; var maxAge = compYear - group.YearOld; bool noMaxLimit = (maxAge > 80); bool noMinLimit = (minAge < 3); Gender gender = group.Female ? Gender.Female : Gender.Male; IEnumerable <AgeGroupModel> exGroupList = db.AgeGroups.Where(g => g.GenderCode == (int)gender); if (noMaxLimit) { exGroupList = exGroupList.Where(g => (g.MaxAge ?? 100) > 80); } else if (noMinLimit) { exGroupList = exGroupList.Where(g => (g.MinAge ?? 0) < 4); } else { exGroupList = exGroupList.Where(g => g.MaxAge == maxAge && g.MinAge == minAge); } AgeGroupModel exGroup = exGroupList.FirstOrDefault(); if (exGroup == null) { exGroup = new AgeGroupModel { FullName = group.Name, SecretaryName = group.Name, MaxAge = noMaxLimit ? null : new int?(maxAge), MinAge = (noMaxLimit || noMinLimit) ? null : new int?(minAge), GenderProperty = gender, CompetitionGroups = new List <Comp_AgeGroupModel>() }; db.AgeGroups.Add(exGroup); } Comp_AgeGroupModel groupComp = exGroup.CompetitionGroups.FirstOrDefault(cg => cg.CompetitionId == comp.Iid); if (groupComp == null) { groupComp = new Comp_AgeGroupModel { CompetitionId = comp.Iid }; exGroup.CompetitionGroups.Add(groupComp); } return(groupComp); }
public HttpResponseMessage Get(int id) { if (CompetitionDB.TblCompetitions.FirstOrDefault(x => x.Id == id) != null) { CompetitionModel comp = new CompetitionModel(CompetitionDB.TblCompetitions.FirstOrDefault(x => x.Id == id)); comp.MainJudgeName = CompetitionDB.TblUsers.Find(comp.MainJudgeId).Name + " " + CompetitionDB.TblUsers.Find(comp.MainJudgeId).LastName; comp.MainRouteCreatorName = CompetitionDB.TblUsers.Find(comp.MainRouteCreatorId).Name + " " + CompetitionDB.TblUsers.Find(comp.MainRouteCreatorId).LastName; comp.Club = CompetitionDB.TblClubs.Find(CompetitionDB.TblUsers.Find(comp.OrgId).ClubId).Name; return(ToJsonOK(comp)); } return(ToJsonNotFound("Objektas nerastas.")); }
/// <summary> /// Ajoute une competition à la liste des competitions du club /// </summary> public static void AjouterCompetition(ClubModel club, CompetitionModel c) { c.Matches = InitialisationMatch(c); // On remplis la liste des matches de la competitions if (!club.Evenements.Contains(c)) { club.Evenements.Add(c); } foreach (CompetiteurModel competiteur in c.EquipeDuClub.ListeDeJoueur) // On ajoute le paiement de l'inscription à la competitionaux paiements en attente de ces joueurs { PaiementModel p = new PaiementModel(c.Cout, competiteur, c); PaiementService.AjouterPaiement(club, p); } }
public IActionResult EditCompetition(int CompID) { CompetitionModel comp = new CompetitionModel(); DataLibrary.Models.CompetitionModel compData = DataLibrary.DataAccess.SQLDataAccess.GetCompetition(CompID); comp.Date = compData.Date; comp.Description = compData.Description; comp.GameID = compData.GameID; comp.CompID = compData.CompID; comp.GameTitle = compData.GameTitle; comp.Title = compData.Title; return(View(comp)); }
public HttpResponseMessage SaveCompetition(CompetitionModel competition) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); UserPrincipal loggedInUser = (UserPrincipal)HttpContext.Current.User; Gradera.Competition.DAL.Competition comp = CompetitionModel.MapCompetitionToDAL(competition); comp.ClubId = loggedInUser.AccountSession.ClubId; if (comp.Id <= 0) comp.CreatedBy = loggedInUser.AccountSession.AccountId; CompetitionBLL.SaveCompetition(comp); return response; }