Exemplo n.º 1
0
        public CalendarClassInFrontend ClassTimeToIndexOnCalendar(CalendarClass calendarClass)
        {
            var calendarClassInFronted = new CalendarClassInFrontend();

            var span = calendarClass.StartingTime.TimeOfDay.Subtract(_calendarStartingTime.TimeOfDay);
            var minutesFromCalendarStartingTime = (int)span.TotalMinutes;

            calendarClassInFronted.ClassStartingTimeIndex = minutesFromCalendarStartingTime / 15;

            span = calendarClass.EndingTime.TimeOfDay.Subtract(calendarClass.StartingTime.TimeOfDay);
            var classDurationInMinutes = (int)span.TotalMinutes;

            calendarClassInFronted.ClassDurationAsNumberOfIndexes = classDurationInMinutes / 15;
            if (calendarClassInFronted.ClassDurationAsNumberOfIndexes < 1)
            {
                calendarClassInFronted.ClassDurationAsNumberOfIndexes = 1;
            }

            calendarClassInFronted.ClassDayAsNumber    = ExtractDayAsNumber(calendarClass.Date);
            calendarClassInFronted.ClassStartingTimeId =
                $"{calendarClassInFronted.ClassDayAsNumber}-{calendarClassInFronted.ClassStartingTimeIndex}";

            calendarClassInFronted.ClassName         = calendarClass.ClassName;
            calendarClassInFronted.ClassStartingTime = calendarClass.StartingTime.ToString("HH:mm");
            calendarClassInFronted.ClassEndingTime   = calendarClass.EndingTime.ToString("HH:mm");

            return(calendarClassInFronted);
        }
 private void CalendarBdFrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (CalendarBdFrid.SelectedItem != null)
         {
             CalendarClass calendarClass = CalendarBdFrid.SelectedItem as CalendarClass;
             CalendarDate.SelectedDate = calendarClass.Date;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private async Task DeleteReservationsAsync(CalendarClass calendarClass,
                                                   CancellationToken cancellationToken = default)
        {
            var reservationsForClass = await _dbContext
                                       .Reservations
                                       .Where(m => m.ClassId == calendarClass.ClassId)
                                       .ToListAsync(cancellationToken);

            foreach (var reservation in reservationsForClass)
            {
                _dbContext.Remove(reservation);
            }

            _ = await _dbContext.SaveChangesAsync(cancellationToken);
        }
 private void CalendarSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         CalendarClass calendarClass = CalendarBdFrid.SelectedItem as CalendarClass;
         bdClassUpdate.UpdateDate(calendarClass.Id, (DateTime)CalendarDate.SelectedDate);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         refreshCalendarBdGrid();
     }
 }
        private void CalendarDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CalendarBdFrid.SelectedItem != null)
                {
                    CalendarClass calendarClass = CalendarBdFrid.SelectedItem as CalendarClass;

                    bdClassDelete.DeleteRowTable(calendarClass.Id, "Calendar");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                refreshCalendarBdGrid();
            }
        }
Exemplo n.º 6
0
        public JsonResult GetHeadings(DateTime start, DateTime end)
        {
            var viewmodel = new CalendarClass();
            var events    = new List <CalendarClass>();

            start = DateTime.Today.AddDays(-14);
            end   = DateTime.Today.AddDays(-14);

            foreach (var item in chm.GetList())
            {
                events.Add(new CalendarClass()
                {
                    title  = item.HeadingName,
                    start  = item.HeadingDate,
                    end    = item.HeadingDate.AddDays(-14),
                    allday = false
                });

                start = start.AddDays(7);
                end   = end.AddDays(7);
            }

            return(Json(events.ToArray(), JsonRequestBehavior.AllowGet));
        }