public void AddAppointment(Appointment e) { try { storage.createAppointment(e.Title, e.StartTime, e.EndTime); foreach (Day d in AllDays) { if (d.Date.Date.Equals(e.AppointmentDate.Date)) { d.AddEvent(e); storage.createAppointment(e.Title, e.StartTime, e.EndTime); return; } } Day newDay = new Day(e.AppointmentDate); newDay.AddEvent(e); AllDays.Add(newDay); Days.Add(newDay); } catch (Exception ex) { throw ex; } }
public void CreateAllDays() { try { var items = new List <CalendarDayBoxView>(); for (uint m = 1; m <= 12; m++) { DayOfWeek StartDayOfWeek = MyDate.GetDayOfWeekForShamsiCalendar(Year, (int)m, 1); int Column = MyDate.GetDayOfWeek(StartDayOfWeek); int Row = 0; int TotalDays = MyDate.GetDaysCountOfMonth(Year, (int)m); for (uint i = 1; i <= TotalDays; i++) { var dayBox = new CalendarDayBoxView(new CalendarDayBoxViewModel() { Day = i, Month = m, CalendarTextColor = CalendarTextColor, CalendarSelectedTextColor = CalendarSelectedTextColor, CalendarHighlightColor = CalendarHighlightColor, }) { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; dayBox.SetValue(Grid.ColumnProperty, Column + 1); dayBox.SetValue(Grid.RowProperty, Row); items.Add(dayBox); Column++; if (Column > 6) { Column = 0; Row++; } } } AllDays = items; var temp = AllDays.FirstOrDefault(d => d.DataContext.Day == ShamsiSelectedDate.Day && d.DataContext.Month == ShamsiSelectedDate.Month); if (temp == null) { temp = AllDays.FirstOrDefault(d => d.DataContext.Day == 29 && d.DataContext.Month == ShamsiSelectedDate.Month); } temp.DataContext.Select(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult Create(AllDays allDays) { if (ModelState.IsValid) { _dayService.Add(allDays); _dayService.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(allDays)); }
public ObservableCollection <Day> LoadEvents(DateTime from, DateTime to) { // List<Appointment> appointments = storage.getAppointments(); // AllDays = getDays(appointments); // AllDays.ForEach(d => d.AppointmentsList = d.AppointmentsList.OrderBy(e => e.StartTime).ToList()); List <Day> filteredList = AllDays.Where(d => d.Date.Date.CompareTo(from.Date) >= 0 && d.Date.Date.CompareTo(to.Date) <= 0).ToList(); Days = new ObservableCollection <Day>(filteredList); return(Days); }
//Readd XML file public static AllDays Read() { //Open XML file reader using (FileStream stream = File.OpenRead(FILENAME)) { XmlSerializer serializer = new XmlSerializer(typeof(AllDays)); AllDays = (AllDays)serializer.Deserialize(stream); } return(AllDays); }
public List <Day> LoadEvents(DateTime from, DateTime to, string user) { logUser(user); AllDays = getDays(storage.getAppointments(Login)); AllDays.ForEach(d => d.AppointmentsList = d.AppointmentsList.OrderBy(e => e.StartTime).ToList()); List <Day> filteredList = AllDays.Where(d => d.Date.Date.CompareTo(from.Date) >= 0 && d.Date.Date.CompareTo(to.Date) <= 0).ToList(); Days = filteredList; return(Days); }
private void CreateCarouselItems() { try { var temp = new List <CarouselItem>() { new CarouselItem(Year, 1) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 1)) }, new CarouselItem(Year, 2) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 2)) }, new CarouselItem(Year, 3) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 3)) }, new CarouselItem(Year, 4) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 4)) }, new CarouselItem(Year, 5) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 5)) }, new CarouselItem(Year, 6) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 6)) }, new CarouselItem(Year, 7) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 7)) }, new CarouselItem(Year, 8) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 8)) }, new CarouselItem(Year, 9) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 9)) }, new CarouselItem(Year, 10) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 10)) }, new CarouselItem(Year, 11) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 11)) }, new CarouselItem(Year, 12) { Days = new List <CalendarDayBoxView>( AllDays.Where(d => d.DataContext.Month == 12)) }, }; CarouselItems = temp; Position = (int)SelectedDayBox.Month - 1; } catch (Exception ex) { throw new Exception(ex.Message); } }