public async Task <IActionResult> Agenda(string datestart = null) { DateTime DateStart; if (String.IsNullOrWhiteSpace(datestart) || !DateTime.TryParse(datestart, out DateStart) || DateStart == DateTime.MinValue) { DateStart = DateTime.Now; } try { List <AgendaResponse> agendaResponses = new List <AgendaResponse>(); for (int i = 0; i <= 7; i++) { agendaResponses.Add(new AgendaResponse() { Date = DateStart.AddDays(i), Wod = await _wodService.GetWodByDate(DateStart.AddDays(i)), IsRest = await _restdayService.IsRestDay(DateStart.AddDays(i)) }); } agendaResponses = agendaResponses.OrderBy(x => x.Date).ToList(); return(Ok(agendaResponses)); } catch (Exception ex) { _logger.LogError($"Agenda error: {ex.Message} - Date: {DateStart.ToLongDateString()}"); return(BadRequest()); } }
public DateTime CheckWorkingDaysInFuture(int NumberOfDays) { if (NumberOfDays <= 0) { throw new Exceptions.InvalidSettingsConfigurationException("The number of days in the future must be above 0."); } Reader = new WorkingDaysReader(); BankHolidaysList = Reader.ReadWorkingDaysFile(); WorkingDays = 0; CalendarDays = 0; DateToday = DateTime.UtcNow.Date; DateStart = DateToday; // Check if today is a bank holiday or falls on a weekend if (DateToday.DayOfWeek == DayOfWeek.Saturday || DateToday.DayOfWeek == DayOfWeek.Sunday || BankHolidaysList.Contains(DateStart.Date.ToString("yyyy-MM-dd"))) { int i = 0; while (DateToday.DayOfWeek != DayOfWeek.Saturday && DateToday.DayOfWeek != DayOfWeek.Sunday || BankHolidaysList.Contains(DateStart.ToString("yyyy-MM-dd"))) { i++; DateStart = DateToday.AddDays(i); } } while (WorkingDays <= (NumberOfDays - 1)) { WorkingDate = DateStart.AddDays(CalendarDays); if (WorkingDate.DayOfWeek != DayOfWeek.Saturday && WorkingDate.DayOfWeek != DayOfWeek.Sunday && !BankHolidaysList.Contains(WorkingDate.ToString("yyyy-MM-dd"))) { WorkingDays++; } CalendarDays++; } FinalDate = DateStart.AddDays(CalendarDays); while (FinalDate.DayOfWeek == DayOfWeek.Saturday || FinalDate.DayOfWeek == DayOfWeek.Sunday || BankHolidaysList.Contains(FinalDate.ToString("yyyy-MM-dd"))) { FinalDate = FinalDate.AddDays(1); CalendarDays++; } return(FinalDate); }
public TimesheetsOverviewWeekViewModel(TimesheetsCalendarViewModel parent, DateTime date, List <TimesheetSearchResult> timesheets, List <SessionSwitch> sessionSwitches) : base(parent) { WeekNumber = date.ToWeekNumber(); DateStart = date.ToPreviousDay(DayOfWeek.Monday); DateEnd = date.ToNextDay(DayOfWeek.Sunday); Days = new List <TimesheetsOverviewDayViewModel>(); for (var i = 0; i < 7; i++) { var dayDate = DateStart.AddDays(i); var day = new TimesheetsOverviewDayViewModel(this, dayDate); Days.Add(day); day.Timesheets.AddRange(timesheets.Where(x => x.StartTime.Date == day.Date).OrderBy(x => x.StartTime)); } }
// زر البحث private void btnSearch_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; DateTime DateStart; DateTime DateEnd; // خلال يوم if (comboBoxSaerch.SelectedIndex == 0) { DateStart = dateTimePickerStart.Value.Date; DateEnd = DateStart.AddDays(1).Date; }// حتى يوم else if (comboBoxSaerch.SelectedIndex == 1) { DateStart = Convert.ToDateTime("2018-01-01"); DateEnd = dateTimePickerStart.Value.Date; } // خلال شهر else if (comboBoxSaerch.SelectedIndex == 2) { DateStart = Convert.ToDateTime("2018-01-01"); DateEnd = dateTimePickerStart.Value.Date; } // خلال الفتره else { DateStart = dateTimePickerStart.Value.Date; DateEnd = dateTimePickerEND.Value.Date; } // اختيار الحساب if (Convert.ToInt32(comboBoxAccountName.SelectedValue) > 0) { // حساب تفصيلي if (radioButtonDateils.Checked) { //عملة محددة if (checkBoxAllCurnncy.Checked == false) { // اختيار العملة if ((Convert.ToInt32(comboBoxCurrncyName.SelectedValue) > 0)) { dataGridView1.DataSource = Acn.GetAccountDetalis(Convert.ToInt32(comboBoxAccountName.SelectedValue), Convert.ToInt32(comboBoxCurrncyName.SelectedValue), DateStart, DateEnd); } else { MessageBox.Show("يجب اختيار علمة محددة"); } } //كل العملات else { dataGridView1.DataSource = Acn.GetAccountDetalis(Convert.ToInt32(comboBoxAccountName.SelectedValue), DateStart, DateEnd); } } // الحساب الاجمالي else if (radioButtonTotal.Checked) { //عملة محددة if (checkBoxAllCurnncy.Checked == false) { // اختيار العملة if ((Convert.ToInt32(comboBoxCurrncyName.SelectedValue) > 0)) { dataGridView1.DataSource = Acn.GetAccountTotal(Convert.ToInt32(comboBoxAccountName.SelectedValue), Convert.ToInt32(comboBoxCurrncyName.SelectedValue)); } else { MessageBox.Show("يجب اختيار علمة محددة"); } } //كل العملات else { dataGridView1.DataSource = Acn.GetAccountTotal(Convert.ToInt32(comboBoxAccountName.SelectedValue)); } } } else { MessageBox.Show("يجب تحديد الحساب اولا"); } this.Cursor = Cursors.Default; }
public override DateTime GetDateEnd() { DateEnd = DateStart.AddDays(period); return(DateEnd); }