static void Main(string[] args) { week lun = week.Lundi; Console.WriteLine(lun); week Mar = week.Mardi; Console.WriteLine(Mar); week Mer = week.Mercredi; Console.WriteLine(Mer); week Jeu = week.Jeudi; Console.WriteLine(Jeu); week Ven = week.Vendredi; Console.WriteLine(Ven); week Sam = week.Samedi; Console.WriteLine(Sam); week Dim = week.Dimanche; Console.WriteLine(Dim); /*Correction * foreach (int i in Enum.GetValues(typeof(week))) ----> Permet d'afficher les valeurs indices de l'énumération 0,1,2,3... * foreach (string i in Enum.GetNames(typeof(week))) // Permet d'afficher les constantes de l'énumération*/ }
WeekDTO GetPastMatchesByWeekId(long weekId, DateTime date) { match[] _matches = null; List <MatchDTO> matches = new List <MatchDTO>(); week _week = null; using (var context = new escorcenterdbEntities()) { _week = (from w in context.weeks where w.enabled == true && w.id == weekId select w).FirstOrDefault <week>(); _matches = (from m in context.matches where m.enabled == true && m.week == _week.id && m.date < date select m).OrderByDescending(m => m.date).ToArray <match>(); } matches = ParseMatches(_matches); if (matches == null || _week == null) { return(null); } WeekDTO week = new WeekDTO() { DateFrom = _week.dateFrom.ToString(), DateTo = _week.dateTo.ToString(), Description = _week.description, Id = _week.id, Season = _week.season, Title = _week.title }; week.matches.AddRange(matches); return(week); }
private void initWeeks(DateTime start) { for (int n = 0; n < MAX_WEEKS; ++n) { weeks[n] = new week(start.AddDays(week.DAYS_PER_WEEK)); } }
static void Main(string[] args) { week lundi = week.Lundi; Console.WriteLine(lundi); week mardi = week.Mardi; Console.WriteLine(mardi); week mercredi = week.Mercredi; Console.WriteLine(mercredi); week jeudi = week.Jeudi; Console.WriteLine(jeudi); week vendredi = week.Vendredi; Console.WriteLine(vendredi); week samedi = week.Samedi; Console.WriteLine(samedi); week dimanche = week.Dimanche; Console.WriteLine(dimanche); Console.WriteLine(Enum.GetName(typeof(week), 4));// afficher un élément d'une énumération suivant son indice, à savoir 4 }
static void Main(string[] args) { /* * Array allDays = Enum.GetValues(typeof(week)); * * foreach (week day in allDays) * { * Console.WriteLine(day); * }*/ week lundi = week.Lundi; week mardi = week.Mardi; week mercredi = week.Mercredi; week jeudi = week.Jeudi; week vendredi = week.Vendredi; week samedi = week.Samedi; week dimanche = week.Dimanche; Console.WriteLine(lundi); Console.WriteLine(mardi); Console.WriteLine(mercredi); Console.WriteLine(jeudi); Console.WriteLine(vendredi); Console.WriteLine(samedi); Console.WriteLine(dimanche); }
static void Main(string[] args) { Console.WriteLine("------将字段转换为枚举值---------------"); Bb zsGender = Bb.女; Console.WriteLine((int)zsGender); Console.WriteLine("------将枚举值转换为字段--------------"); int myWorkDay = 4; Console.WriteLine((week)myWorkDay); Console.WriteLine("------将枚举转换为字符串--------------"); week myWorkDay3 = week.周三; Console.WriteLine(myWorkDay3.ToString()); Console.WriteLine(Convert.ToString(myWorkDay3)); Console.WriteLine("------将字符串转换为枚举值--------------"); week myWorkDay4 = week.周四; string mystr2 = myWorkDay4.ToString(); Console.WriteLine((week)Enum.Parse(typeof(week), mystr2)); Console.ReadKey(); }
static void Main(string[] args) { week a = week.Wed; //把week枚举中的wed赋给a Console.WriteLine(a); //输出a Console.WriteLine("使用强制转换后a为:{0}", (int)a); //强制转换为int类型输出 }
public static void Main(string[] args) { //枚举类型初始化 week day = week.Friday; Console.WriteLine(day); Console.ReadKey(); }
public ScoreEntry(TeamMatchupWithMatches teamMatchupWithMatches, week week) { this.teamMatchupWithMatches = teamMatchupWithMatches; this.week = week; this.Errors = new List <string>(); this.Validate(); }
static void Main() { week day = week.friday; int a = (int)day; int b = (int)week.saturday; Console.WriteLine("a={0},b={1}", a, b); Console.ReadLine(); }
private void OnListBoxSelectItemChange(week item) { //if (currentWeek == null) return; currentWeekId = item.idweek; // CurrentWeek = weeks.Where(p => p.idweek == currentWeekId).Last(); InitTable(item.idweek); }
static void Main(string[] args) { week num = week.SUN; for (int i = 0; i < 7; i++) { Console.WriteLine(num++); } Console.ReadKey(); }
public void Test_SetWorkingHours() { //Arrange section start // initializing hours Hour[] Monday = new Hour[] { }; Hour[] Tuesday = new Hour[] { new Hour { type = "open", value = 36000 }, new Hour { type = "close", value = 64800 } }; Hour[] Wednesday = new Hour[] { }; Hour[] Thursday = new Hour[] { new Hour { type = "open", value = 36000 }, new Hour { type = "close", value = 64800 } }; Hour[] Friday = new Hour[] { new Hour { type = "open", value = 36000 } }; Hour[] Saturday = new Hour[] { new Hour { type = "close", value = 36000 }, new Hour { type = "open", value = 36000 } }; Hour[] Sunday = new Hour[] { new Hour { type = "close", value = 36000 }, new Hour { type = "open", value = 43200 }, new Hour { type = "open", value = 756000 } }; // asigning it to week var week input = new week(); input.Monday = Monday; input.Tuesday = Tuesday; input.wednesday = Wednesday; input.Thursday = Thursday; input.Friday = Friday; input.Saturday = Saturday; input.Sunday = Sunday; // Expected viewModel expectation = new viewModel(); expectation.Monday = "Closed"; expectation.Tuesday = "11:00 am - 7:00 pm"; expectation.wednesday = "Closed"; expectation.Thursday = "11:00 am - 7:00 pm"; expectation.Friday = "11:00 am"; expectation.Saturday = "2:00 am - 11:00 am"; expectation.Sunday = "2:00 am - 1:00 pm - 10:00 pm"; //Arrange section Ended //Act Section }
public WeekResponse(week w) { Date = w.date; CourseId = w.courseId; YearId = w.yearId; SeasonIndex = w.seasonIndex; BadData = w.isBadData; PairingId = w.pairingId; IsPlayoff = w.isPlayoff; Id = w.id; }
private bool CheckWeek(week currWeek) { for (int i = 0; i < weeks.Count; i++) { if (weeks[i].dateFrom == currWeek.dateFrom && weeks[i].dateTo == currWeek.dateTo) { return(false); } } return(true); }
private teammatchup CreateTeamMatchup(team team1, team team2, week week, int matchOrder) { var tm = new teammatchup { week = week, matchOrder = matchOrder, matchComplete = false }; tm.teams.Add(team1); tm.teams.Add(team2); return(tm); }
public IHttpActionResult CreateWeek(WeekDTO _week) { week w = new week { dateFrom = DateTime.Now, dateTo = new DateTime(2016, 02, 29), enabled = true, description = _week.Description, season = (int)_week.Season, title = _week.Title }; using (var context = new escorcenterdbEntities()) { context.weeks.Add(w); context.SaveChanges(); } return(Ok(w)); }
public IHttpActionResult UpdateWeeks([FromBody] WeekDTO _week) { week weekMap = AutoMapper.Mapper.Map <WeekDTO, week>(_week); week w; using (var context = new escorcenterdbEntities()) { w = (from r in context.weeks where r.id == weekMap.id select r).FirstOrDefault(); w = weekMap; context.SaveChanges(); } return(Ok(w)); }
// POST: api/Weeks public IHttpActionResult Post([FromBody] week value) { try { return(ResponseMessage(Request.CreateResponse(new { response = weekService.insertWeek(value) }))); } catch (Exception e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.ToString()))); } }
public string insertWeek(week week) { try { week.available = true; context.week.Add(week); context.SaveChanges(); return(CONSTANTES.CONSTANTES.ServiceResponse.ok); } catch (Exception e) { return(CONSTANTES.CONSTANTES.ServiceResponse.error); } }
// Creates a schedule given the inputs private void CreateSchedule() { team anchorTeam = teams.First(); List <team> restOfTeams = teams.Skip(1).ToList(); LinkedList <teammatchup> createdMatchups = new LinkedList <teammatchup>(); LinkedList <week> createdWeeks = new LinkedList <week>(); int pairingIndex = 0; // This does a round robin algorithm in place on the teams. It assumes // an even number of teams. Is uses the first team as the "anchor" of the algorithm. for (int i = 0, j = 0; j < this.numberOfWeeks; i = (i - 1 < 0 ? restOfTeams.Count - 1 : i - 1), j++, pairingIndex++) { // Note that weeks are 1 based week currentWeek = new week { seasonIndex = j + 1, date = this.selectedDates[j].DateTime, pairing = pairings[pairingIndex % pairings.Count], course = courses[j % courses.Count] }; createdWeeks.AddLast(currentWeek); // create anchor matchup. createdMatchups.AddLast(this.CreateTeamMatchup(anchorTeam, restOfTeams[i], currentWeek, 0)); for (int k = 0; k < restOfTeams.Count / 2; k++) { int team1Index = i + 1 + k; if (team1Index > restOfTeams.Count - 1) { team1Index = team1Index % restOfTeams.Count; } int team2Index = i - 1 - k; if (team2Index < 0) { team2Index = restOfTeams.Count + team2Index; } createdMatchups.AddLast(this.CreateTeamMatchup(restOfTeams[team1Index], restOfTeams[team2Index], currentWeek, k + 1)); } } this.CreatedMatchups = createdMatchups.ToList(); this.CreatedWeeks = createdWeeks.ToList(); this.AssignTeeTimes2(); }
public ScoreEntryDataResponse( week currentWeek, IEnumerable <week> allWeeks, IDictionary <int, IEnumerable <player> > allPlayersForYear, IEnumerable <team> allTeamsForYear) { this.CurrentWeek = currentWeek == null ? null : new ScheduleWeek(currentWeek); this.Schedule = new ScheduleResponse { Weeks = allWeeks.Where(x => x.teammatchups.Count > 0).Select(x => new ScheduleWeek(x)) }; this.Teams = allTeamsForYear.Select(TeamResponse.From); this.TeamIdToPlayer = allPlayersForYear.ToDictionary(x => x.Key, x => x.Value.Select(y => new PlayerWebResponse(y))); }
public string updateWeek(week week) { try { var result = context.week.FirstOrDefault(x => x.id == week.id); if (result != null) { result.weekTypeId = week.weekTypeId; result.startDate = week.startDate; result.endDate = week.endDate; result.mesocycleId = week.mesocycleId; context.SaveChanges(); } return(CONSTANTES.CONSTANTES.ServiceResponse.ok); } catch (Exception e) { return(CONSTANTES.CONSTANTES.ServiceResponse.error); } }
static void Main(string[] args) { week lundi = week.Lundi; week mardi = week.Mardi; week mercredi = week.Mercredi; week jeudi = week.Jeudi; week vendredi = week.Vendredi; week samedi = week.Samedi; week dimanche = week.Dimanche; Console.WriteLine(lundi); Console.WriteLine(mardi); Console.WriteLine(mercredi); Console.WriteLine(jeudi); Console.WriteLine(vendredi); Console.WriteLine(samedi); Console.WriteLine(dimanche); Console.WriteLine((week)4); //Console.WriteLine(Enum.GetName(typeof(week),4)); }
public ScheduleWeek(week w, GroupedPlayoffMatchup playoffMatchup, bool includeMatches = false) : base(w) { this.TeamMatchups = w.teammatchups.Select(x => includeMatches ? new TeamMatchupWithResults(x) : new ScheduleTeamMatchup(x)).OrderBy(x => x.MatchOrder).ToList(); this.Course = CourseResponse.From(w.course); this.Pairing = w.pairing.pairingText; if (playoffMatchup != null) { this.PlayoffMatchups = playoffMatchup.PlayoffMatchups.Select(y => new { team1 = TeamResponse.From(y.Team1), team2 = TeamResponse.From(y.Team2), team1Seed = y.Team1Seed, team2Seed = y.Team2Seed, playoffType = y.PlayoffType }); } }
static void Main(string[] args) { week myweek = week.mon; string display = $"今天是 {myweek}"; Console.WriteLine($"今天是 {myweek}"); Console.WriteLine(display); if (myweek == week.mon) { Console.WriteLine(display); } else { Console.WriteLine("false"); } int i = (int)myweek; Console.WriteLine($"myweek的數字是{i}"); Console.ReadLine(); }
public string updateWeek(week week) { return(weekRepository.updateWeek(week)); }
public string insertWeek(week week) { return(weekRepository.insertWeek(week)); }
public ScheduleWeek(week w) : this(w, null, false) { }
private void Reset_OnClick(object sender, RoutedEventArgs e) { this.vals = new week(); }