public DateTime GetNextMatchDate(CompetitionType competitionType, int roundIndex) { if (!_initialized) { throw new Exception("MatchDateManager is not initialized"); } DateTime nextDateTime; switch (competitionType) { case CompetitionType.Friendly: nextDateTime = _friendlyDates[roundIndex]; break; case CompetitionType.League: nextDateTime = _leagueDates[roundIndex]; break; case CompetitionType.NationalCup: nextDateTime = _cupDates[roundIndex]; break; case CompetitionType.NationalSuperCup: nextDateTime = _superCupDate; break; default: throw new ArgumentException("Unknown CompetitionType"); } return(nextDateTime); }
public ActionResult Create(CompetitionType competitionType) { var competitionTypesRepository = ServiceProvider.Get <ICompetitionTypeRepository>(); competitionTypesRepository.Add(competitionType); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit(int cid, string name, string description, string type, int?page) { var comp = db.Competitions.FirstOrDefault(x => x.Id == cid); comp.Name = name; comp.Description = description; CompetitionType t = db.CompetitionTypes.FirstOrDefault(x => x.Name == type); comp.CompetitionType = t; comp.CompetitionTypeId = t.Id; await db.SaveChangesAsync(); List <Competition> comps = db.Competitions.ToList(); var userid = this.User.Identity.GetUserId(); var ermessages = db.Users.FirstOrDefault(x => x.Id == userid).Messages; ermessages.Add(new Message { Subject = Resources.Messages.Success + "!", Body = Resources.Messages.Saved, Type = "alert-success" }); await db.SaveChangesAsync(); return(await Edit(page, cid)); }
public IHttpActionResult PutCompetitionType(int id, CompetitionType competitionType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != competitionType.CompetitionType_ID) { return(BadRequest()); } db.Entry(competitionType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CompetitionTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public DateTime GetNextMatchDate(CompetitionType competitionType, int roundIndex) { if (!_initialized) { throw new Exception("MatchDateManager is not initialized"); } DateTime nextDateTime; switch (competitionType) { case CompetitionType.Friendly: nextDateTime = _friendlyDates[roundIndex]; break; case CompetitionType.League: nextDateTime = _leagueDates[roundIndex]; break; case CompetitionType.NationalCup: nextDateTime = _cupDates[roundIndex]; break; case CompetitionType.NationalSuperCup: nextDateTime = _superCupDate; break; default: throw new ArgumentException("Unknown CompetitionType"); } return nextDateTime; }
public async Task <IActionResult> Edit(int id, [Bind("CompetitionTypeID,Name")] CompetitionType competitionType) { if (id != competitionType.CompetitionTypeID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(competitionType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompetitionTypeExists(competitionType.CompetitionTypeID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(competitionType)); }
public IEnumerable <Competition> GetByType(CompetitionType competitionType) { using (var competitionRepository = new RepositoryFactory().CreateCompetitionRepository()) { var competitions = competitionRepository.GetByCompetitionType(competitionType); return(competitions); } }
/// <summary> /// Object to data transfer object /// </summary> /// <param name="authentication"></param> /// <returns></returns> public static CompetitionTypeDTO ObjectToDTO(CompetitionType obj) { return(new CompetitionTypeDTO { name = obj.name, description = obj.description, timestamp = DataConvert.DateTimeToJsonString(obj.timestamp), updated = DataConvert.DateTimeToJsonString(obj.updated) }); }
}// End of Constructor function /// <summary> /// Add competition type /// </summary> /// <param name="competition_type"></param> /// <param name="user_log"></param> /// <returns></returns> public CompetitionType addCompetitionType(CompetitionType competition_type, UserSystem user_log) { return(http_service.JSONHttpPettitionObject <CompetitionType>( HttpMethod.POST, GetType().Name.ToLower().Replace( TWords.SERVICE, TWords.SLASH), JsonConvert.SerializeObject( CompetitionTypeAdapter.ObjectToDTO( competition_type)))); }// End of addCompetitionType function
public async Task <IActionResult> Create([Bind("CompetitionTypeID,Name")] CompetitionType competitionType) { if (ModelState.IsValid) { _context.Add(competitionType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(competitionType)); }
public HttpResponseMessage UpdateCompetitionType(CompetitionType competitionType) { Result <CompetitionType> res = competitionTypeBusiness.UpdateCompetitionType(competitionType); HttpResponseMessage response = res.Success ? Request.CreateResponse(HttpStatusCode.Created, res.Data) : Request.CreateResponse(HttpStatusCode.InternalServerError, res.Message); return(response); }
public IHttpActionResult GetCompetitionType(int id) { CompetitionType competitionType = db.CompetitionTypes.Find(id); if (competitionType == null) { return(NotFound()); } return(Ok(competitionType)); }
public IMatchProvisioningEngine Create(CompetitionType competitionType) { if (competitionType.Method == CompetitionMethod.Knockout) { return(Build.New <KnockoutMatchProvisioningEngine>()); } else { throw new NotImplementedException(); } }
public static IList <CompetitionType> DTOsToObjects(IList <CompetitionTypeDTO> dtos) { IList <CompetitionType> list = new List <CompetitionType>(); foreach (CompetitionTypeDTO dto in dtos) { CompetitionType obj = DTOToObject(dto); list.Add(obj); } return(list); }
public IHttpActionResult PostCompetitionType(CompetitionType competitionType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CompetitionTypes.Add(competitionType); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = competitionType.CompetitionType_ID }, competitionType)); }
public static CompetitionTypeModel mapToModel(this CompetitionType competiotnType) { CompetitionTypeModel competitionTypeModel = new CompetitionTypeModel { Name = competiotnType.Name, CompetitionTypeId = competiotnType.CompetionId, //MatchModel = (competiotnType.Matches!= null) ? // competiotnType.Matches.Select(m => m.mapToMatchModel()).ToList() : null }; return(competitionTypeModel); }
public static CompetitionType mapToCompetiotionType(this CompetitionTypeModel ct) { CompetitionType competitionType = new CompetitionType() { CompetionId = ct.CompetitionTypeId, Name = ct.Name, //Matches = (ct.MatchModel != null) ? // ct.MatchModel.Select(m => m.mapToMatch()).ToList() : null }; return(competitionType); }
public IHttpActionResult DeleteCompetitionType(int id) { CompetitionType competitionType = db.CompetitionTypes.Find(id); if (competitionType == null) { return(NotFound()); } db.CompetitionTypes.Remove(competitionType); db.SaveChanges(); return(Ok(competitionType)); }
public async Task <ActionResult> Create(string name, string description, string type, string red) { CompetitionType ctype = db.CompetitionTypes.ToList().FindLast(x => x.Name == type); string id = this.User.Identity.GetUserId(); var applicationUser = db.Users.FirstOrDefault(x => x.Id == id); int i = 1 + db.Users.ToList().IndexOf(applicationUser); if (i < 1) { var ermessages = db.Users.FirstOrDefault(x => x.Id == id).Messages; ermessages.Add(new Message { Subject = Resources.Messages.Error + "!", Body = Resources.Messages.CompCreateFailed, Type = "alert-danger" }); await db.SaveChangesAsync(); switch (red) { case "manage": return(RedirectToAction("Manage", "Home")); case "competitions": return(RedirectToAction("Competitions", "Home")); default: return(RedirectToAction("", "Home")); } } db.Competitions.Add(new Competition { Name = name, Description = description, CompetitionType = ctype, CompetitionTypeId = ctype.Id, ApplicationUser = applicationUser, ApplicationUserId = applicationUser.Id }); var messages = db.Users.FirstOrDefault(x => x.Id == id).Messages; messages.Add(new Message { Subject = Resources.Messages.Success + "!", Body = Resources.Messages.CompCreateSuccess, Type = "alert-success" }); await db.SaveChangesAsync(); switch (red) { case "manage": return(RedirectToAction("Manage", "Home", new { alert = "crcomp" })); case "competitions": return(RedirectToAction("Competitions", "Home", new { alert = "crcomp" })); default: return(RedirectToAction("", "Home")); } }
public Response <IEnumerable <CompetitionHacker> > GetHackers(CompetitionType type, int top) { try { var hackers = _repo.GetHackers(type == CompetitionType.Monthly, top); return(hackers == null ? new Response <IEnumerable <CompetitionHacker> >("No Competition Yet!") : new Response <IEnumerable <CompetitionHacker> >(hackers)); } catch (Exception e) { return(new Response <IEnumerable <CompetitionHacker> >($"Error :{e.Message}")); } }
public static int RankPlayer(this CompetitionType competitionType, Player player) { var rank = player.NationalRank; if (competitionType.Ranking == Ranking.YouthInternational) { rank = player.YouthInternationalRank; } else if (competitionType.Ranking == Ranking.EuropeInternational) { rank = player.EuropeInternationalRank; } return(rank.GetValueOrDefault()); }
private void cbxCompetitionType_SelectedIndexChanged(object sender, EventArgs e) { CompetitionType type = cbxCompetitionType.SelectedItem as CompetitionType; if (type != null) { cbxChangesRating.Enabled = type.CanChangeRating; } else { cbxChangesRating.Enabled = false; } btnOk.Enabled = cbxGameType.SelectedIndex != -1 && txtCompetitionName.Text != "" && cbxCompetitionType.SelectedItem != null; }
public void Create(string CreaotrId, int TrackId, CompetitionType type, bool IsPublic, int lapsCount, DateTime startDateTime, DateTime endDateTime) { var competition = new Competition { TrackId = TrackId, Type = type, IsPublic = IsPublic, LapsCount = lapsCount, StartDateTime = startDateTime, EndDateTime = endDateTime }; this.competitions.Add(competition); this.competitions.Save(); }
public async Task <Response <IEnumerable <Competitor> > > GetCurrentResult(CompetitionType type, int repId) { try { var last = await _repo.GetLastCompetition(type != CompetitionType.Daily); var compareDate = _offSetHandler.GetDate(); if (last == null || !compareDate.Equals(last.DateTime)) { return(new Response <IEnumerable <Competitor> >("No Competition!")); } var allCompetitors = await _repo.GetCurrentResult( new DateTime(last.DateTime.Year, last.DateTime.Month, last.DateTime.Day, HourOffset, 0, 0), last.MinUniqueUsers, last.MinUniqueVisits); /** * take the top @ReturnedRowNumber of rows with the rank of a specific User * in the competition .if the passed user is not in the competition ,it will * only return the top @ReturnedRowNumber of rows. **/ var rt = new List <Competitor>(); var found = false; foreach (var competitor in allCompetitors) { if (found && competitor.Ranking > ReturnedRowNumber) { break; } if (competitor.Ranking > ReturnedRowNumber && (found || competitor.Id != repId)) { continue; } rt.Add(competitor); if (!found && competitor.Id == repId) { found = true; } } //end of result filtering return(new Response <IEnumerable <Competitor> >(rt)); } catch (Exception e) { return(new Response <IEnumerable <Competitor> >($"Error :{e.Message}")); } }
public CompetitionType Add(CompetitionType competitionType) { CompetitionType dbCompetition; try { dbCompetition = _context.CompetitionTypes.Add(competitionType); _context.SaveChanges(); } catch (Exception ex) { Console.Write(ex); throw ex; } return(dbCompetition); }
public Result <CompetitionType> GetById(int id) { Result <CompetitionType> retVal = null; try { CompetitionType competitionType = Uow.CompetitionTypes.GetById(id); retVal = ResultHandler <CompetitionType> .Sucess(competitionType); } catch (Exception ex) { log.Error(String.Format("Error retreiving competition type with following id: {0}", id), ex); retVal = ResultHandler <CompetitionType> .Erorr("Error retreiving competition type"); } return(retVal); }
public async Task <Response <Competition> > GetNextCompetition(CompetitionType type) { try { var now = _offSetHandler.GetDate(); var d1 = new DateTime(now.Year, now.Month, now.Day).AddDays(1); var d2 = new DateTime(now.Year, now.Month, 1).AddDays(1); var d = CompetitionType.Monthly == type ? d2 : d1; var c = await _repo.GetCompetition(CompetitionType.Monthly == type, d.Year, d.Month, d.Day); return(c == null ? new Response <Competition>("you have not added the next competition Yet") : new Response <Competition>(c)); } catch (Exception e) { return(new Response <Competition>($"Error:{e.Message}")); } }
public CompetitionType Update(CompetitionType competitionType) { try { if (competitionType != null) { _context.CompetitionTypes.Attach(competitionType); _context.Entry(competitionType).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } catch (Exception ex) { Console.Write(ex); throw ex; } return(competitionType); }
public Result <CompetitionType> UpdateCompetitionType(CompetitionType competitionType) { Result <CompetitionType> retVal = null; try { Uow.CompetitionTypes.Update(competitionType, competitionType.CompetitionTypeID); Uow.Commit(); retVal = ResultHandler <CompetitionType> .Sucess(competitionType); } catch (Exception ex) { log.Error("Error updating competition type", ex); retVal = ResultHandler <CompetitionType> .Erorr("Error updating competition type"); } return(retVal); }
public static ValidationResult ValidateTeamMembers(CompetitionType competitionType) { ValidationResult retVal = ValidationResult.Success; if (competitionType != null && competitionType.CompetitorType == CompetitorType.Team) { if (competitionType.PlayersPerTeam < Constants.Validation.MinPlyersCountPerTeam || competitionType.PlayersPerTeam > Constants.Validation.MaxPlayersCountPerTeam) { retVal = new ValidationResult(String.Format("For team games players per team myst be between {0} and {1}", Constants.Validation.MinPlyersCountPerTeam, Constants.Validation.MaxPlayersCountPerTeam), new string[] { "CompetitorType", "PlayersPerTeam" } ); } } return(retVal); }
public MatchHeaderInfo[] BuildMatches(CompetitionType competitionType, CompetitionDetails competitionDetails) { var helper = new KnockoutMatchProvisioningEngineHelper(); var pMatches = helper.ProvisionMatches(competitionType.PlayersCount, competitionType.QualifyingToFinalPlayersCount, competitionDetails.Players.Length); var fMatches = pMatches.Where(m => m.SectionCode == "MD").ToArray(); var qMatches = pMatches.Where(m => m.SectionCode == "Q").ToArray(); var rankedPlayersCount = competitionType.PlayersCount - competitionType.QualifyingToFinalPlayersCount; var qPlayersCount = competitionDetails.Players.Length - rankedPlayersCount; if (qPlayersCount <= competitionType.QualifyingToFinalPlayersCount) { qPlayersCount = 0; } var matches = new List <MatchHeaderInfo>(); var finalPlayersCount = PlayersCountCalculator.CalculatePlayersCount(rankedPlayersCount); var qualifyingPlayersCount = PlayersCountCalculator.CalculatePlayersCount(qPlayersCount); var finalSectionMatches = CreateSectionMatches(finalPlayersCount, CompetitionSection.Final).ToArray(); var qualifyingSectionMatches = CreateSectionMatches(qualifyingPlayersCount, CompetitionSection.Qualifying, competitionType.QualifyingToFinalPlayersCount).ToArray(); var consolationSectionMatches = CreateConselationMatches(finalPlayersCount); for (var i = 0; i < fMatches.Length; i++) { finalSectionMatches[i].Player1Code = fMatches[i].Player1Code; finalSectionMatches[i].Player2Code = fMatches[i].Player2Code; } for (var i = 0; i < qMatches.Length; i++) { qualifyingSectionMatches[i].Player1Code = qMatches[i].Player1Code; qualifyingSectionMatches[i].Player2Code = qMatches[i].Player2Code; } matches.AddRange(qualifyingSectionMatches); matches.AddRange(finalSectionMatches); matches.AddRange(consolationSectionMatches); return(matches.ToArray()); }
internal static List <CompetitionType> ReadTypes(SqlDataReader reader) { var list = new List <CompetitionType>(); var stringList = ReadObject(reader, "Types", "").Split(new[] { "++" }, StringSplitOptions.None); foreach (var pair in stringList) { var rulePair = pair.Split(new[] { "||" }, StringSplitOptions.None); int id; var compRule = new CompetitionType(); if (rulePair.Length < 2) { continue; } if (TryParse(rulePair[0], out id)) { compRule.Id = id; } compRule.Type = rulePair[1]; list.Add(compRule); } return(list); }
public Definition(CompetitionType type, CompetitionLevel level) : base(type, level) { }
private void ShowCompetitionEndScoreEx(CompetitionType type, CompetitionLevel level, string competitionName) { mCurrentScore += mMoodScoreBonus; int currentMoneyReward = 0x0; List<EquestrianCenter.PositionScoring> positionScoringTuning = EquestrianCenter.PositionScoringTuning; if (mCompetitionType == CompetitionType.Racing) { RaceShuffle(); } mCurrentPosition = GetPlaceInRace(type, level, EquestrianCenter.kNumberOfCompetitors, mCurrentScore, out currentMoneyReward); Responder.Instance.HudModel.UpdateCompetitionStanding(this); FinishType poorFinish = FinishType.PoorFinish; if ((mCurrentPosition >= EquestrianCenter.kPositionsForFinishTypes[0x1]) && (mCurrentPosition < EquestrianCenter.kPositionsForFinishTypes[0x0])) { poorFinish = FinishType.StandardFinish; } else if (mCurrentPosition == EquestrianCenter.kPositionsForFinishTypes[0x2]) { poorFinish = FinishType.Victory; } RidingSkill skill = Actor.SimDescription.SkillManager.GetSkill<RidingSkill>(SkillNames.Riding); skill.AddPoints(EquestrianCenter.kSkillPointsAdded[0x0]); bool flag = type == CompetitionType.CrossCountry; if ((flag || (type == CompetitionType.Racing)) && !Horse.BuffManager.HasElement(BuffNames.PetSkillFatigue)) { Horse.SimDescription.SkillManager.GetSkill<Racing>(SkillNames.Racing).AddPoints(EquestrianCenter.kSkillPointsAdded[0x1]); } if ((flag || (type == CompetitionType.Jumping)) && !Horse.BuffManager.HasElement(BuffNames.PetSkillFatigue)) { Horse.SimDescription.SkillManager.GetSkill<Jumping>(SkillNames.Jumping).AddPoints(EquestrianCenter.kSkillPointsAdded[0x2]); } if (currentMoneyReward != 0x0) { if (skill.IsEquestrianChampion()) { currentMoneyReward = (int)(currentMoneyReward * RidingSkill.EquestrianChampionPrizeMultiplier); } Actor.ModifyFunds(currentMoneyReward); skill.UpdateXpForEarningMoney(currentMoneyReward); EventTracker.SendEvent(new JockeyEvent(EventTypeId.kJockeyEvent, Actor, currentMoneyReward)); } string str = Localization.LocalizeString(false, "UI/Caption/HudCompetitionPanel/Place:Position" + mCurrentPosition, new object[0x0]); switch (poorFinish) { case FinishType.PoorFinish: if (Actor.IsActiveSim) { Audio.StartSound("sting_eques_poor_finish"); } if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse))) { Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterPoorFinish, null, Actor, new object[] { Horse, Actor, str, competitionName }); } return; case FinishType.StandardFinish: if (Actor.IsActiveSim) { Audio.StartSound("sting_eques_standard_finish"); } if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse))) { Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterStandardFinish, null, Actor, new object[] { Horse, Actor, str, competitionName }); } return; case FinishType.Victory: RidingSkill.WonCompetition(Actor.SimDescription, Horse.SimDescription, type, level); if (Actor.IsActiveSim) { Audio.StartSound("sting_eques_victory_finish"); } if (!Target.mPlayerHasParticipatedAndWon) { Target.mPlayerHasParticipatedAndWon = true; EventTracker.SendEvent(new EquestrianCompetitionEvent(EventTypeId.kEquestrianCompetition, Actor.FirstName, Actor.IsFemale, Horse.FirstName, Horse.IsFemale, competitionName)); } if ((StoryProgression.Main.Skills.MatchesAlertLevel(Actor)) || (StoryProgression.Main.Skills.MatchesAlertLevel(Horse))) { Sim.ActiveActor.ShowTNSIfSelectable(TNSNames.EquestrianCenterVictory, null, Actor, new object[] { Horse, Actor, competitionName }); } AddCompetitionTrophy(type, level); return; } }