public void deleteContest(int contestId) { ContestType contest = context.ContestType.Where(ct => ct.ContestTypeId == contestId).FirstOrDefault(); if (contest == null) { throw new AppException("Nie odnaleziono podanego konkursu"); } List <Participation> participations = context.Participation.Where(p => p.ContestId == contestId).ToList(); context.Participation.RemoveRange(participations); List <AllowedBreedsContest> allowedBreeds = context.AllowedBreedsContest.Where(p => p.ContestTypeId == contestId).ToList(); if (allowedBreeds.Count > 0) { context.AllowedBreedsContest.RemoveRange(allowedBreeds); } List <Contest> contests = context.Contest.Where(c => c.ContestTypeId == contestId).ToList(); if (contests.Count > 0) { context.Contest.RemoveRange(contests); } context.Remove(contest); context.SaveChanges(); }
public static List <Contest> GetActiveContestsForMember(ContestType Type, Member User) { var ActiveContests = GetActiveContests(Type); var BlockedContestsForMember = TableHelper.SelectRows <ContestsBlocked>(TableHelper.MakeDictionary("UserId", User.Id)); var resultList = new List <Contest>(); foreach (var active in ActiveContests) { bool IsOk = true; foreach (var blocked in BlockedContestsForMember) { if (blocked.ContestId == active.Id) { IsOk = false; } } if (UsersBannedFromContestsType.IsBannedFromContestType(User.Id, Type)) { IsOk = false; } if (IsOk) { resultList.Add(active); } } return(resultList); }
private void loadObject(DataSet dsContest) { if (dsContest.Tables.Count > 0) { if (dsContest.Tables[0].Rows.Count > 0) { DataRow drContest = dsContest.Tables[0].Rows[0]; ContestID = string.IsNullOrEmpty(drContest["ContestID"].ToString()) ? -1 : int.Parse(drContest["ContestID"].ToString()); MainContactCustomerID = string.IsNullOrEmpty(drContest["MainContactCustomerID"].ToString()) ? -1 : int.Parse(drContest["MainContactCustomerID"].ToString()); Association = string.IsNullOrEmpty(drContest["Association"].ToString()) ? string.Empty : drContest["Association"].ToString(); PubNumber = string.IsNullOrEmpty(drContest["PubNumber"].ToString()) ? -1 : int.Parse(drContest["PubNumber"].ToString()); Name = string.IsNullOrEmpty(drContest["Name"].ToString()) ? string.Empty : drContest["Name"].ToString(); BannerFileName = string.IsNullOrEmpty(drContest["BannerFileName"].ToString()) ? string.Empty : drContest["BannerFileName"].ToString(); SecondaryBannerFileName = string.IsNullOrEmpty(drContest["SecondaryBannerFileName"].ToString()) ? string.Empty : drContest["SecondaryBannerFileName"].ToString(); DisclaimerText = string.IsNullOrEmpty(drContest["DisclaimerText"].ToString()) ? string.Empty : drContest["DisclaimerText"].ToString(); StartDate = string.IsNullOrEmpty(drContest["StartDate"].ToString()) ? DateTime.MinValue : DateTime.Parse(drContest["StartDate"].ToString()); DeadlineDate = string.IsNullOrEmpty(drContest["DeadlineDate"].ToString()) ? DateTime.MinValue : DateTime.Parse(drContest["DeadlineDate"].ToString()); VotingDeadline = string.IsNullOrEmpty(drContest["VotingDeadline"].ToString()) ? DateTime.MinValue : DateTime.Parse(drContest["VotingDeadline"].ToString()); AnnouncementDate = string.IsNullOrEmpty(drContest["AnnouncementDate"].ToString()) ? DateTime.MinValue : DateTime.Parse(drContest["AnnouncementDate"].ToString()); FirstPrize = string.IsNullOrEmpty(drContest["FirstPrize"].ToString()) ? string.Empty : drContest["FirstPrize"].ToString(); WinnerContestEntryID = string.IsNullOrEmpty(drContest["WinnerContestEntryID"].ToString()) ? -1 : int.Parse(drContest["WinnerContestEntryID"].ToString()); ConfirmationText = string.IsNullOrEmpty(drContest["ConfirmationText"].ToString()) ? string.Empty : drContest["ConfirmationText"].ToString(); ConfirmationText = string.IsNullOrEmpty(drContest["ConfirmationText"].ToString()) ? string.Empty : drContest["ConfirmationText"].ToString(); NotificationEmailSubject = string.IsNullOrEmpty(drContest["NotificationEmailSubject"].ToString()) ? string.Empty : drContest["NotificationEmailSubject"].ToString(); NotificationEmailBody = string.IsNullOrEmpty(drContest["NotificationEmailBody"].ToString()) ? string.Empty : drContest["NotificationEmailBody"].ToString(); ConfirmationEmailSubject = string.IsNullOrEmpty(drContest["ConfirmationEmailSubject"].ToString()) ? string.Empty : drContest["ConfirmationEmailSubject"].ToString(); ConfirmationEmailBody = string.IsNullOrEmpty(drContest["ConfirmationEmailBody"].ToString()) ? string.Empty : drContest["ConfirmationEmailBody"].ToString(); JudgeGuidelines = string.IsNullOrEmpty(drContest["JudgeGuidelines"].ToString()) ? string.Empty : drContest["JudgeGuidelines"].ToString(); Type = string.IsNullOrEmpty(drContest["ContestTypeID"].ToString()) ? ContestType.Undefined : (ContestType)int.Parse(drContest["ContestTypeID"].ToString()); } } }
/// <summary> /// Creates a new Contest with predetermined teams. /// </summary> /// <param name="id">Numeric indentifier for the contest.</param> /// <param name="name">Contest Name.<param> /// <param name="description">Contest Description.</param> /// <param name="points">Points to be distributed to the winner(s).</param> /// <param name="mode">Contest mode for determining termination.</param> /// <param name="type">Contest type (group or individual)</param> /// <param name="start">Time to start the contest.</param> /// <param name="end">End Conditions to be observed.</param> /// <param name="statistic">Statistic on which the Contest is based.</param> /// <param name="teams">Teams participating in the Contest.</param> protected Contest(int id, string name, string description, int points, ContestEndMode mode, ContestType type, DateTime start, EndCondition end, Statistic statistic, List<Team> teams) : this(name, description, points, mode, type, start, end, statistic) { this.Teams = teams; }
public static void SaveBan(int userId, ContestType contestType) { var contestsTypestable = new UsersBannedFromContestsType(); contestsTypestable.UserId = userId; contestsTypestable.Type = contestType; contestsTypestable.Save(); }
private void LoadLatestWinners(ContestType Type, Literal LatestLiteral) { var List = ContestManager.GetLastestWinners(Type); LatestLiteral.Text += "<li>1st: " + List[0] + "</li>"; LatestLiteral.Text += "<li>2nd: " + List[1] + "</li>"; LatestLiteral.Text += "<li>3rd: " + List[2] + "</li>"; }
private ContestRegistrationViewModel CreateEditContestRegistrationViewModel(ContestType contestType) { if (contestType == ContestType.Individual) { return(new EditIndividualContestRegistrationViewModel()); } return(new EditTeamContestRegistrationViewModel()); }
public static string Get(Category category, out ContestType type) { type = category.GetContestType(); switch (category.SheetSize) { case 1: case 2: throw new NotImplementedException(); case 3: return(new RoundRobin3(category).Image); case 4: return(new RoundRobin4(category).Image); case 5: return(new RoundRobin5(category).Image); case 6: return(new RoundRobin6(category).Image); case 7: case 8: return(new DoubleElimination8(category).Image); case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: return(new DoubleElimination16(category).Image); case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: return(new DoubleElimination32(category).Image); default: throw new NotImplementedException(); } }
static void Generate1(synapse_client <data_processors.waypoints> client, string source, uint yy, uint mm, uint dd) { var contests = new ContestsType(); var contest = new ContestType(); contest.set_competition("Australian Racing"); contest.set_contestNumber(1); contest.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint"); contest.set_sportCode(SportEnum.SportEnum_gp); contest.set_datasource(source); contest.set_startDate(new DateType()).set_Value(utils.EncodeDate(yy, mm, dd)); //// var participant = new ParticipantType(); participant.set_number("1"); participant.set_barrier(new IntegerType()).set_Value(3); var entities = new EntitiesType(); var horse = entities.set_horse_element("horse", new HorseType()); horse.set_name("Small Runner"); horse.set_countryBorn(new TextType()).set_Value("AUS"); var jockey = entities.set_jockey_element("jockey", new PersonType()); jockey.set_name("S Clipperton"); jockey.set_sid("S Clipperton"); participant.set_entities(entities); contest.set_participants_element("1", participant); //// participant = new ParticipantType(); participant.set_number("1A"); participant.set_barrier(new IntegerType()).set_Value(2); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner"); participant.set_entities(entities); contest.set_participants_element("1A", participant); //// participant = new ParticipantType(); participant.set_number("2"); participant.set_barrier(new IntegerType()).set_Value(1); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Large Runner"); participant.set_entities(entities); contest.set_participants_element("2", participant); // contests.set_contest_element(source + "|" + yy.ToString() + mm.ToString() + dd.ToString() + ";1000001", contest); var waypoints = new waypoints(); var waypoint = new waypoint(); waypoint.set_timestamp(data_processors.federated_serialisation.utils.EncodeDateTime(DateTime.UtcNow)); waypoint.set_tag("contests_1.example.csharp.1"); waypoints.add_path_element(waypoint); client.publish("test." + source, contests, waypoints, false); }
public void SaveToTable() { //var timePeriod = new TimePeriod { StartDate=DateTime.Now, EndDate=DateTime.Parse("2018-05-28 07:00") }; var party = new ContestType { Name = "Träningstävling" }; var dbRepo = new DataBaseRepo(); var result = (DatabaseHolder)dbRepo.Save(party); Assert.Equal(ExecuteCodes.SuccessToExecute, result.ExecuteCodes); }
public async Task GetContestTypeResourceAsyncIntegrationTest() { // assemble PokeApiClient client = new PokeApiClient(); // act ContestType contestType = await client.GetResourceAsync <ContestType>(1); // assert Assert.True(contestType.Id != default(int)); }
public IHttpActionResult GetContextTypes(string idOrName) { PokeApiClient pokeApiClient = new PokeApiClient(); ContestType contestType = pokeApiClient.GetContestTypeByNameOrId(idOrName); if (contestType == null) { return(NotFound()); } return(Ok(contestType)); }
public Contest(Guid id, ContestType contestType, string code, string name, string description, string location, DateTimeOffset startDate, DateTimeOffset endDate) { this.Id = id; this.ContestType = contestType; this.Code = code; this.Name = name; this.Description = description; this.Location = location; this.StartDate = startDate; this.EndDate = endDate; }
private async Task updateClients(ContestType type, ContestSheetData contest, Category category) { if (type == ContestType.RoundRobin) { var rrDto = contest.ToRoundRobinDto(category); await _hub.Clients.Group($"t{contest.TournamentID}c{contest.CategoryID}").SendAsync("updateSheet", rrDto); } else { var dto = contest.ToDTO(); await _hub.Clients.Group($"t{contest.TournamentID}c{contest.CategoryID}").SendAsync("updateSheet", dto); } }
public Task Save(ContestType contestType) { if (contestType.Id == 0) { _context.ContestTypes.Add(contestType); } else { _context.Entry(contestType).State = EntityState.Modified; } return(_context.SaveChangesAsync()); }
public static bool IsBannedFromContestType(int userId, ContestType contestType) { var BlockedContestTypes = UsersBannedFromContestsType.Get(userId); foreach (var BlockedContestType in BlockedContestTypes) { if (BlockedContestType.Type == contestType) { return(true); } } return(false); }
/// <summary> /// Returns int or Money depending on the contest type /// </summary> /// <param name="Type"></param> /// <param name="Prize"></param> /// <returns></returns> public static object GetActionProperObject(ContestType Type, Money Points) { switch (Type) { case ContestType.Transfer: return(Points); case ContestType.Null: return(null); default: return(Points.GetRealTotals()); } }
/// <summary> /// Creates a new Contest. /// </summary> /// <param name="id">Numeric indentifier for the contest.</param> /// <param name="name">Contest Name.<param> /// <param name="description">Contest Description.</param> /// <param name="points">Points to be distributed to the winner(s).</param> /// <param name="mode">Contest mode for determining termination.</param> /// <param name="type">Contest type (group or individual)</param> /// <param name="start">Time to start the contest.</param> /// <param name="end">End Conditions to be observed.</param> /// <param name="statistic">Statistic on which the Contest is based.</param> public Contest(string name, string description, int points, ContestEndMode mode, ContestType type, DateTime start, EndCondition end, Statistic statistic) { this.Name = name; this.Description = description; this.Points = points; this.Mode = mode; this.Type = type; this.StartTime = start; this.EndCondition = end; this.StatisticBinding = statistic; this.Teams = new List<Team>(); }
private static List <Contest> GetMemberParticipatingContests(ContestType Type, string Username) { var activeList = GetActiveContests(Type); var resultList = new List <Contest>(); foreach (var contest in activeList) { if (contest.IsMemberParticipating(Username)) { resultList.Add(contest); } } return(resultList); }
public Contest planContest(Contest newContest) { ContestType contestType = context.ContestType.Where(ct => ct.ContestTypeId == newContest.ContestTypeId).FirstOrDefault(); if (contestType == null) { throw new AppException("Błędne id konkursu"); } if (contestType.Contest.Count > 0) { throw new AppException("Konkurs jest już zaplanowany"); } context.Contest.Add(newContest); context.SaveChanges(); return(context.Contest.Where(c => c.ContestId == newContest.ContestId).FirstOrDefault()); }
/// <summary> /// Fires when member made any action which can be applied for a contest. It checks if memeber /// is participating in any contests. If so, the contest data is being updated. /// Leave one credit NULL (int=0 or money=NULL) /// </summary> /// <param name="ActionType"></param> /// <returns></returns> public static void IMadeAnAction(ContestType ActionType, string Username, Money MoneyCredit, int IntCredit) { List <Contest> ContestList = GetMemberParticipatingContests(ActionType, Username); foreach (var contest in ContestList) { if (ActionType == ContestType.Transfer && contest.MinMembersDeposit > MoneyCredit) { continue; } var participant = ContestParticipant.GetParticipant(contest, Username); participant.Credit(IntCredit, MoneyCredit); participant.Save(); } }
public static void AddAndClean(ContestType Type, string w1, string w2, string w3) { //Check if there is something to clean int count = TableHelper.CountOf <ContestLatestWinners>(TableHelper.MakeDictionary("Type", (int)Type)); if (count > 0) { //Yes TableHelper.DeleteRows <ContestLatestWinners>(TableHelper.MakeDictionary("Type", (int)Type)); } ContestLatestWinners temp = new ContestLatestWinners(); temp.Type = Type; temp.Winner1 = w1; temp.Winner2 = w2; temp.Winner3 = w3; temp.Save(); }
public static List <Contest> GetActiveContests(ContestType Type) { var where = TableHelper.MakeDictionary("Type", (int)Type); var preList = TableHelper.SelectRows <Contest>(where); var resultList = new List <Contest>(); foreach (var elem in preList) { if (elem.Status == ContestStatus.Active && elem.DateStart <= DateTime.Now && elem.DateEnd >= DateTime.Now) { resultList.Add(elem); } } return(resultList); }
/// <summary> /// Gets 3 latest winners of this contest type /// 1st = [0] /// 2nd = [1] /// 3rd = [2] /// </summary> public static List <string> GetLastestWinners(ContestType Type) { List <string> result = new List <string>(); var LatestWinners = TableHelper.SelectRows <ContestLatestWinners> (TableHelper.MakeDictionary("Type", (int)Type)); if (LatestWinners.Count > 0) { string res1 = LatestWinners[0].Winner1; string res2 = LatestWinners[0].Winner2; string res3 = LatestWinners[0].Winner3; try { res1 = ContestManager.ReparseId(res1); } catch (Exception ex) { } try { res2 = ContestManager.ReparseId(res2); } catch (Exception ex) { } try { res3 = ContestManager.ReparseId(res3); } catch (Exception ex) { } result.Add(res1); result.Add(res2); result.Add(res3); } else { result.Add("-"); result.Add("-"); result.Add("-"); } return(result); }
public List <PlanInfoDTO> getPlan() { List <PlanInfoDTO> plans = new List <PlanInfoDTO>(); List <Contest> contests = context.Contest.ToList(); if (contests.Count < 1) { throw new AppException("Brak zaplanowanych konkursów"); } var groupedContests = contests.GroupBy(c => c.StartDate.Date); foreach (var gContest in groupedContests) { List <ContestInfoDTO> contestInfoList = new List <ContestInfoDTO>(); foreach (Contest contest in gContest) { ContestType contestType = context.ContestType.Where(ct => ct.ContestTypeId == contest.ContestTypeId).FirstOrDefault(); Place place = context.Place.Where(p => p.PlaceId == contest.PlaceId).FirstOrDefault(); ContestInfoDTO contestInfo = new ContestInfoDTO { contestTypeId = contestType.ContestTypeId, contestId = contest.ContestId, name = contestType.NamePolish, placeName = place.Name, startDate = contest.StartDate, endDate = contest.EndDate }; contestInfoList.Add(contestInfo); } PlanInfoDTO planInfo = new PlanInfoDTO { date = gContest.Key.ToShortDateString(), contests = contestInfoList }; plans.Add(planInfo); } return(plans); }
public List <DogParticipationDTO> getDogParticipation(int dogId) { List <Participation> participations = context.Participation.Where(p => p.DogId == dogId).ToList(); if (participations == null) { return(null); } List <DogParticipationDTO> dogParticipations = new List <DogParticipationDTO>(); foreach (Participation participation in participations) { ContestType contest = context.ContestType.Where(ct => ct.ContestTypeId == participation.ContestId).FirstOrDefault(); Grade grade = context.Grade.Where(g => g.GradeId == participation.GradeId).FirstOrDefault(); string place = (participation.Place == null) ? "Nie przyznano" : participation.Place.ToString(); if (grade == null) { dogParticipations.Add(new DogParticipationDTO { participationId = participation.ParticipationId, dogId = participation.DogId, contestName = contest.NamePolish, grade = "Nie oceniono", place = place, description = participation.Description }); } else { dogParticipations.Add(new DogParticipationDTO { participationId = participation.ParticipationId, dogId = participation.DogId, contestName = contest.NamePolish, grade = grade.NamePolish, place = place, description = participation.Description }); } } return(dogParticipations); }
private void LoadContests(ContestType Type, PlaceHolder ContestLiteral, Member User, Button button, View view) { var list = ContestManager.GetActiveContestsForMember(Type, User); foreach (var contest in list) { ContestLiteral.Controls.Add(GetContestCode(contest, User)); } if (list.Count == 0) { button.Visible = false; } else if (noContestsAvailable) { //First of that kind, set the active view MenuMultiView.SetActiveView(view); noContestsAvailable = false; } }
public ContestType RetrieveSpecificContestType(IDbConnection connection, int contest_type_id) { ContestType contestType = null; using (IDbCommand command = database.CreateCommand()) { command.Connection = connection; command.CommandText = Query.GetSpecificContestType; command.Prepare(); command.AddWithValue("@contest_type_id", contest_type_id); using (IDataReader reader = command.ExecuteReader()) { if (reader.Read()) { contestType = new ContestType { Id = reader.CheckValue <int>("id"), Identifier = reader.CheckObject <string>("identifier") }; } } } // Command return(contestType); }
public ContestDetailsDTO editContest(int id, ContestDetailsDTO newContest) { ContestType contestType = context.ContestType.Where(ct => ct.ContestTypeId == id).FirstOrDefault(); if (contestType == null) { throw new AppException("Nie odnaleziono konkursu w bazie"); } Contest contest = context.Contest.Where(c => c.ContestTypeId == id).FirstOrDefault(); contestType.NamePolish = newContest.name; contestType.Enterable = newContest.isEnterable; if (contest != null) { contest.PlaceId = newContest.placeId; contest.StartDate = newContest.startDate; contest.EndDate = newContest.endDate; } context.SaveChanges(); return(getContest(id)); }
/// <summary> /// Gets all tasks asynchronously. /// </summary> /// <param name="contestType">Type of the contest.</param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException">contestType - Invalid contest type.</exception> public async Task <Result <IEnumerable <TaskBase> > > GetAllTasksAsync(ContestType contestType) { if (contestType == ContestType.Unknown) { throw new ArgumentOutOfRangeException(nameof(contestType), "Invalid contest type."); } try { var result = await this.taskRepository.ReadAsync(contestType); if (result.IsFaulted) { return(Error <IEnumerable <TaskBase> >(null, "No tasks were found for that contest type.")); } return(Success(result.Value, nameof(GetAllTasksAsync))); } catch (Exception ex) { return(Error <IEnumerable <TaskBase> >(null, ex)); } }
public IActionResult addContest([FromBody] ContestTypeDTO newContestType) { var claimsIdentity = this.User.Identity as ClaimsIdentity; try { userService.IsUserAnOrganizator(claimsIdentity); if (!appSettingsService.canEnter()) { throw new AppException("Akcja obecnie niedozwolona"); } List <AllowedBreedsContest> allowedBreeds = new List <AllowedBreedsContest>(); foreach (int breedId in newContestType.breedIds) { allowedBreeds.Add(new AllowedBreedsContest { BreedTypeId = breedId }); } ContestType contestType = new ContestType { Enterable = newContestType.isEnterable, NamePolish = newContestType.name, AllowedBreedsContest = allowedBreeds }; ContestType savedContestType = contestService.addContest(contestType); if (savedContestType == null) { throw new AppException("Błąd tworzenia konkursu"); } return(Ok()); } catch (Exception e) { return(BadRequest(new { message = e.Message })); } }
public void UpdateContest(int id, string title, string description, DateTime? startTime, DateTime? restTime, DateTime? hackStartTime, DateTime? endTime, ContestType? type, bool? printingEnabled) { using (DB db = new DB()) { CheckRole(db, UserRole.Manager); Contest contest = db.Contests.Find(id); if (contest == null) throw new FaultException<NotFoundError>(new NotFoundError { ID = id, Type = "Contest" }); if (title != null) contest.Title = title; if (startTime != null) contest.StartTime = startTime.Value; if (endTime != null) contest.EndTime = endTime.Value; if (restTime != null) contest.RestTime = restTime.Value; if (hackStartTime != null) contest.HackStartTime = hackStartTime.Value; if (contest.StartTime > contest.EndTime) throw new FaultException<ValidationError>(new ValidationError()); if (contest.RestTime != null && (contest.RestTime < contest.StartTime || contest.RestTime > contest.EndTime)) throw new FaultException<ValidationError>(new ValidationError()); if (contest.HackStartTime != null && (contest.HackStartTime < contest.StartTime || contest.HackStartTime > contest.EndTime)) throw new FaultException<ValidationError>(new ValidationError()); if (contest.RestTime != null && contest.HackStartTime != null && contest.RestTime > contest.HackStartTime) throw new FaultException<ValidationError>(new ValidationError()); if (description != null) contest.Description = description; if (type != null) contest.Type = type.Value; if (printingEnabled != null) contest.PrintingEnabled = printingEnabled.Value; db.SaveChanges(); if (ContestModified != null) System.Threading.Tasks.Task.Factory.StartNew(() => ContestModified(contest.ID)); } }
public int CreateContest(string title, string description, DateTime startTime, DateTime? restTime, DateTime? hackStartTime, DateTime endTime, ContestType type, bool printingEnabled) { using (DB db = new DB()) { CheckRole(db, UserRole.Manager); if (startTime > endTime) throw new FaultException<ValidationError>(new ValidationError()); if (restTime != null && (restTime < startTime || restTime > endTime)) throw new FaultException<ValidationError>(new ValidationError()); if (hackStartTime != null && (hackStartTime < startTime || hackStartTime > endTime)) throw new FaultException<ValidationError>(new ValidationError()); if (restTime != null && hackStartTime != null && restTime > hackStartTime) throw new FaultException<ValidationError>(new ValidationError()); Contest contest = new Contest { Description = description, EndTime = endTime, PrintingEnabled = printingEnabled, StartTime = startTime, RestTime = restTime, HackStartTime = hackStartTime, Title = title, Type = type }; db.Contests.Add(contest); db.SaveChanges(); if (NewContest != null) System.Threading.Tasks.Task.Factory.StartNew(() => NewContest(contest.ID)); return contest.ID; } }
/// <summary> /// Creates a new goal-based Contest /// </summary> /// <param name="name">Contest Name.</param> /// <param name="description">Contest Description.</param> /// <param name="points">Points to be distributed to the winner(s).</param> /// <param name="start">Time to start the contest.</param> /// <param name="end">Score at which to end the contest.</param> /// <param name="statistic">Statistic on which the Contest is based.</param> /// <returns>ID of the newly created Contest.</returns> public static int CreateContest(ContestType type, string name, string description, int points, DateTime start, float end, Statistic statistic) { return ContestDAO.CreateNewContest(new Contest(name, description, points, ContestEndMode.GoalBased, type, start, new EndCondition(end), statistic)); }
public ContestDetailsDTO getContest(int id) { ContestDetailsDTO contestDetails; ContestType contestType = context.ContestType.Where(ct => ct.ContestTypeId == id).FirstOrDefault(); if (contestType == null) { throw new AppException("Nie odnaleziono konkursu o podanym id"); } List <BreedInfoDTO> allowedBreeds = new List <BreedInfoDTO>(); List <AllowedBreedsContest> allowed = context.AllowedBreedsContest.Where(abc => abc.ContestTypeId == id).ToList(); foreach (AllowedBreedsContest abc in allowed) { DogBreed breed = context.DogBreed.Where(db => db.BreedId == abc.BreedTypeId).FirstOrDefault(); allowedBreeds.Add(new BreedInfoDTO { breedId = abc.BreedTypeId, name = breed.NamePolish }); } List <ParticipationInfoDTO> participations = new List <ParticipationInfoDTO>(); List <Participation> part = context.Participation.Where(p => p.ContestId == id).ToList(); foreach (Participation p in part) { Dog dog = context.Dog.Where(d => d.DogId == p.DogId).FirstOrDefault(); DogBreed breed = context.DogBreed.Where(db => db.BreedId == dog.BreedId).FirstOrDefault(); Grade grade = context.Grade.Where(g => g.GradeId == p.GradeId).FirstOrDefault(); DogClass classD = context.DogClass.Where(c => c.ClassId == dog.ClassId).FirstOrDefault(); string place = (p.Place == null) ? "Nie przyznano" : p.Place.ToString(); if (grade == null) { participations.Add(new ParticipationInfoDTO { participationId = p.ParticipationId, dogId = p.DogId, name = dog.Name, breedName = breed.NamePolish, className = classD.NamePolish, chipNumber = dog.ChipNumber, gradeId = 0, grade = "Nie oceniono", place = place, description = p.Description }); } else { participations.Add(new ParticipationInfoDTO { participationId = p.ParticipationId, dogId = p.DogId, name = dog.Name, breedName = breed.NamePolish, className = classD.NamePolish, chipNumber = dog.ChipNumber, gradeId = grade.GradeId, grade = grade.NamePolish, place = place, description = p.Description }); } } Contest contest = context.Contest.Where(c => c.ContestTypeId == id).FirstOrDefault(); if (contest == null) { contestDetails = new ContestDetailsDTO { contestTypeId = contestType.ContestTypeId, contestId = -1, name = contestType.NamePolish, isEnterable = Convert.ToBoolean(contestType.Enterable), placeId = -1, placeName = null, startDate = new DateTime(), endDate = new DateTime(), allowedBreeds = allowedBreeds, participants = participations }; } else { Place place = context.Place.Where(p => p.PlaceId == contest.PlaceId).FirstOrDefault(); contestDetails = new ContestDetailsDTO { contestTypeId = contestType.ContestTypeId, contestId = contest.ContestId, name = contestType.NamePolish, isEnterable = Convert.ToBoolean(contestType.Enterable), placeId = contest.PlaceId, placeName = place.Name, startDate = contest.StartDate, endDate = contest.EndDate, allowedBreeds = allowedBreeds, participants = participations }; } return(contestDetails); }
static void Generate2(synapse_client <data_processors.waypoints> client) { var contests_20150401 = new ContestsType(); var contests_20150402 = new ContestsType(); var qt_contest1 = new ContestType(); qt_contest1.set_competition("Australian Racing"); qt_contest1.set_contestNumber(1); qt_contest1.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint"); qt_contest1.set_sportCode(SportEnum.SportEnum_gp); qt_contest1.set_datasource("qt"); qt_contest1.set_startDate(new DateType()).set_Value(utils.EncodeDate(2015, 04, 01)); //// var participant = new ParticipantType(); participant.set_number("1"); participant.set_barrier(new IntegerType()).set_Value(3); var entities = new EntitiesType(); var horse = entities.set_horse_element("horse", new HorseType()); horse.set_name("Small Runner"); horse.set_countryBorn(new TextType()).set_Value("AUS"); var jockey = entities.set_jockey_element("jockey", new PersonType()); jockey.set_name("S Clipperton"); jockey.set_sid("S Clipperton"); participant.set_entities(entities); qt_contest1.set_participants_element("1", participant); //// participant = new ParticipantType(); participant.set_number("1A"); participant.set_barrier(new IntegerType()).set_Value(2); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("1A", participant); //// participant = new ParticipantType(); participant.set_number("2"); participant.set_barrier(new IntegerType()).set_Value(1); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Large Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("2", participant); // contests_20150401.set_contest_element("qt|20150401;1000001", qt_contest1); client.publish("test.qt", contests_20150401, null, false, Encoding.ASCII.GetBytes("contests_20150401")); //////////////////////////////////////////////////////////////// qt_contest1 = new ContestType(); qt_contest1.set_competition("Australian Racing"); qt_contest1.set_contestNumber(1); qt_contest1.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint"); qt_contest1.set_sportCode(SportEnum.SportEnum_gp); qt_contest1.set_datasource("qt"); qt_contest1.set_startDate(new DateType()).set_Value(utils.EncodeDate(2015, 04, 02)); //// participant = new ParticipantType(); participant.set_number("1"); participant.set_barrier(new IntegerType()).set_Value(3); entities = new EntitiesType(); horse = entities.set_horse_element("horse", new HorseType()); horse.set_name("Small Runner"); horse.set_countryBorn(new TextType()).set_Value("AUS"); jockey = entities.set_jockey_element("jockey", new PersonType()); jockey.set_name("S Clipperton"); jockey.set_sid("S Clipperton"); participant.set_entities(entities); qt_contest1.set_participants_element("1", participant); //// participant = new ParticipantType(); participant.set_number("1A"); participant.set_barrier(new IntegerType()).set_Value(2); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("1A", participant); //// participant = new ParticipantType(); participant.set_number("2"); participant.set_barrier(new IntegerType()).set_Value(1); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Large Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("2", participant); // contests_20150402.set_contest_element("qt|20150402;1000001", qt_contest1); client.publish("test.qt", contests_20150402, null, false, Encoding.ASCII.GetBytes("contests_20150402")); //////////////////////////////////////////////////////////////// ////// Jockey change - publish delta ///// var a_contest = contests_20150401.get_contest_element("qt|20150401;1000001"); if (a_contest != null) { var a_participant = a_contest.get_participants_element("1"); if (a_participant != null) { var a_entities = a_participant.get_entities(); if (a_entities != null) { var a_jockey = a_entities.get_jockey_element("jockey"); if (a_jockey != null) { a_jockey.set_name("D J Browne"); a_jockey.set_sid("4317"); } else { Console.WriteLine("Jockey not found!"); } } else { Console.WriteLine("Entities not found!"); } } else { Console.WriteLine("Participant 1 not found!"); } } else { Console.WriteLine("Contest not found!"); } client.publish("test.qt", contests_20150401, null, true, Encoding.ASCII.GetBytes("contests_20150401")); /////////////////////////////////////////////////////////////// ///// Jockey change - publish delta ///// a_contest = contests_20150402.get_contest_element("qt|20150402;1000001"); if (a_contest != null) { var a_participant = a_contest.get_participants_element("1"); if (a_participant != null) { var a_entities = a_participant.get_entities(); if (a_entities != null) { var a_jockey = a_entities.get_jockey_element("jockey"); if (a_jockey != null) { a_jockey.set_name("D J Browne"); a_jockey.set_sid("4317"); } else { Console.WriteLine("Jockey not found!"); } } else { Console.WriteLine("Entities not found!"); } } else { Console.WriteLine("Participant 1 not found!"); } } else { Console.WriteLine("Contest not found!"); } client.publish("test.qt", contests_20150402, null, true, Encoding.ASCII.GetBytes("contests_20150402")); }
/// <summary> /// Creates a new goal-based Contest /// </summary> /// <param name="type">Determines whether the contest in Individual or Group-based.</param> /// <param name="name">Contest Name.</param> /// <param name="description">Contest Description.</param> /// <param name="start">Time to start the contest.</param> /// <param name="end">Score at which to end the contest.</param> /// <param name="searchable">True if the Contest can be found by searching (public), false if private.</param> /// <param name="statistic">Statistic on which the Contest is based.</param> /// <param name="creatorId">UserID of the creator of the contest.</param> /// <returns>ID of the newly created Contest.</returns> public static int CreateContest(ContestType type, string name, string description, DateTime start, float end, bool searchable, Statistic statistic, int creatorId) { Contest newContest = new Contest { Name = name, Description = description, Mode = ContestEndMode.GoalBased, Type = type, StartTime = start, EndValue = end, StatisticBinding = statistic, IsSearchable = searchable, DeactivatedTime = null, IsActive = true, CreatorId = creatorId }; return ContestDAO.CreateNewContest(newContest); }