private void AddHoliday(object p)
 {
     Holidays.Add(new Holiday()
     {
         Name = p.ToString(), Description = "Test button nieuwe reis", Destination = "Test", DepartureDate = DateTime.Now
     });
 }
Exemplo n.º 2
0
 /// <summary>
 /// Add holiday
 /// <para lang="tr">Tatil ekle</para>
 /// </summary>
 /// <param name="holiday"></param>
 /// <returns></returns>
 public WorkTimeCalculator AddHoliday(Holiday holiday)
 {
     if (holiday == null)
     {
         throw new ArgumentNullException("holiday");
     }
     Holidays.Add(holiday);
     return(this);
 }
Exemplo n.º 3
0
 protected void btnAdd_Click(Object Sender, EventArgs e)
 {
     if (Request.Form[hdnId.UniqueID] == "0")
     {
         oHoliday.Add(txtName.Text, DateTime.Parse(txtDate.Text), (chkEnabled.Checked == true ? 1 : 0));
     }
     else
     {
         oHoliday.Update(Int32.Parse(Request.Form[hdnId.UniqueID]), txtName.Text, DateTime.Parse(txtDate.Text), (chkEnabled.Checked == true ? 1 : 0));
     }
     Response.Redirect(Request.Path);
 }
 private void GetDataAsync()
 {
     for (int i = 1950; i < 2051; i++)
     {
         var data = GetDataByYearAsync(i);
         if (data.IsFaulted)
         {
             throw new CallApiException(data.Exception.Message, data.Exception.InnerException);
         }
         Holidays.Add(i, data.Result);
     }
 }
Exemplo n.º 5
0
        public async Task <CustomError> AddHoliday(string name, string description, string destination, DateTime holidayDepartureDate)
        {
            Holiday holiday = new Holiday(name, description, destination, holidayDepartureDate);

            (Holiday h, CustomError c) = await HolidayService.AddHoliday(holiday);

            if (h.ID >= 0 && c.Message == null)
            {
                Holidays.Add(h);
            }

            return(c);
        }
Exemplo n.º 6
0
        private void GetMonth(DateTime day)
        {
            // add holidays
            var holidays = new HolidayCalculator(day, Utils.ReadConfig("Holidays", "Path"));

            foreach (HolidayCalculator.Holiday h in holidays.OrderedHolidays)
            {
                if (h.Date.Month == day.Month)
                {
                    Holidays.Add(new Holiday(h.Name, h.Date));
                }
                // and days before holidays if theye're not weekends or holidays
                var yesterday = h.Date.AddDays(-1);
                if (yesterday.Month == day.Month &&
                    Holidays.FirstOrDefault(hl => hl.Date == yesterday) == default(Holiday) &&
                    yesterday.DayOfWeek != DayOfWeek.Saturday &&
                    yesterday.DayOfWeek != DayOfWeek.Sunday)
                {
                    SpecialDays.Add(new SpecialDay("Day before " + h.Name, yesterday.Date));
                }
            }

            // if the last day in month is day before holiday
            var firstInNextMonth = Last.AddDays(1);
            var hol = Holidays.FirstOrDefault(h => h.Date == firstInNextMonth);

            if (hol != null &&
                Last.Date.DayOfWeek != DayOfWeek.Saturday &&
                Last.Date.DayOfWeek != DayOfWeek.Sunday)
            {
                SpecialDays.Add(new SpecialDay("Day before " + hol.Name, Last.Date));
            }

            // get all fridays, if they're not holidays
            var startDate = First;

            while (startDate.DayOfWeek != DayOfWeek.Friday)
            {
                startDate = startDate.AddDays(1);
            }

            while (startDate < Last)
            {
                if (Holidays.FirstOrDefault(h => h.Date == startDate) == default(Holiday))
                {
                    SpecialDays.Add(new SpecialDay("Friday", startDate));
                }
                startDate = startDate.AddDays(7);
            }

            // get all weekends, if they're not holidays
            startDate = First;
            while (startDate.DayOfWeek != DayOfWeek.Saturday)
            {
                startDate = startDate.AddDays(1);
            }

            while (startDate < Last)
            {
                if (Holidays.FirstOrDefault(h => h.Date == startDate) == default(Holiday))
                {
                    NonWorkingDays.Add(new NonWorkingDay(startDate));
                }
                startDate = startDate.AddDays(1);
                if (Holidays.FirstOrDefault(h => h.Date == startDate) == default(Holiday))
                {
                    NonWorkingDays.Add(new NonWorkingDay(startDate));
                }
                startDate = startDate.AddDays(6);
            }
        }