コード例 #1
0
        public ObservableCollection <Service> GetActivitiesListing()
        {
            ObservableCollection <Service> FromDBService = new ObservableCollection <Service>();
            var ServiceDB = Database.Table <ServiceTable>();
            var ShiftDB   = Database.Table <ShiftTable>();

            foreach (ServiceTable ServiceFromDB in ServiceDB)
            {
                Service currentservice = new Service(ServiceFromDB.Name);
                foreach (ShiftTable ShiftFromDB in ShiftDB)
                {
                    if (ServiceFromDB.Id == ShiftFromDB.FKService)
                    {
                        Shift currentshift = new Shift(TimeSpan.ParseExact(ShiftFromDB.Start_hour, "c", null), TimeSpan.ParseExact(ShiftFromDB.End_hour, "c", null), ShiftFromDB.Minwo, ShiftFromDB.Optwo);
                        if (ShiftFromDB.mon == 1)
                        {
                            currentshift.Opening_Day[0].IsOpen = true;
                        }
                        else
                        {
                            currentshift.Opening_Day[0].IsOpen = false;
                        }
                        if (ShiftFromDB.tue == 1)
                        {
                            currentshift.Opening_Day[1].IsOpen = true;
                        }
                        else
                        {
                            currentshift.Opening_Day[1].IsOpen = false;
                        }
                        if (ShiftFromDB.wed == 1)
                        {
                            currentshift.Opening_Day[2].IsOpen = true;
                        }
                        else
                        {
                            currentshift.Opening_Day[2].IsOpen = false;
                        }
                        if (ShiftFromDB.thu == 1)
                        {
                            currentshift.Opening_Day[3].IsOpen = true;
                        }
                        else
                        {
                            currentshift.Opening_Day[3].IsOpen = false;
                        }
                        if (ShiftFromDB.fri == 1)
                        {
                            currentshift.Opening_Day[4].IsOpen = true;
                        }
                        else
                        {
                            currentshift.Opening_Day[4].IsOpen = false;
                        }
                        if (ShiftFromDB.sat == 1)
                        {
                            currentshift.Opening_Day[5].IsOpen = true;
                        }
                        else
                        {
                            currentshift.Opening_Day[5].IsOpen = false;
                        }
                        if (ShiftFromDB.sun == 1)
                        {
                            currentshift.Opening_Day[6].IsOpen = true;
                        }
                        else
                        {
                            currentshift.Opening_Day[6].IsOpen = false;
                        }
                        currentshift.Id = ShiftFromDB.Id;
                        currentservice.ShiftListing.Add(currentshift);
                    }
                }
                FromDBService.Add(currentservice);
            }
            return(FromDBService);
        }
コード例 #2
0
        public ObservableCollection <Service> GetServiceListing()
        {
            ObservableCollection <Service> FromDBService = new ObservableCollection <Service>();
            var ServiceDB = Database.Table <ServiceTable>();
            var ShiftDB   = Database.Table <ShiftTable>();

            foreach (ServiceTable ServiceFromDB in ServiceDB)
            {
                Service currentservice = new Service(ServiceFromDB.Name);
                foreach (ShiftTable ShiftFromDB in ShiftDB)
                {
                    if (ServiceFromDB.Id == ShiftFromDB.FKService)
                    {
                        Shift currentshift = new Shift(TimeSpan.ParseExact(ShiftFromDB.Start_hour, "c", null), TimeSpan.ParseExact(ShiftFromDB.End_hour, "c", null), ShiftFromDB.Minwo, ShiftFromDB.Optwo);
                        if (ShiftFromDB.mon == 1)
                        {
                            currentshift.Opening_Day[0].IsOpen = true;
                        }
                        if (ShiftFromDB.tue == 1)
                        {
                            currentshift.Opening_Day[1].IsOpen = true;
                        }
                        if (ShiftFromDB.wed == 1)
                        {
                            currentshift.Opening_Day[2].IsOpen = true;
                        }
                        if (ShiftFromDB.thu == 1)
                        {
                            currentshift.Opening_Day[3].IsOpen = true;
                        }
                        if (ShiftFromDB.fri == 1)
                        {
                            currentshift.Opening_Day[4].IsOpen = true;
                        }
                        if (ShiftFromDB.sat == 1)
                        {
                            currentshift.Opening_Day[5].IsOpen = true;
                        }
                        if (ShiftFromDB.sun == 1)
                        {
                            currentshift.Opening_Day[6].IsOpen = true;
                        }
                        currentservice.ShiftListing.Add(currentshift);
                    }
                }
                FromDBService.Add(currentservice);
            }



            //Check if shift isOpen
            ObservableCollection <Service> MyList = new ObservableCollection <Service> ();

            foreach (Service service in FromDBService)
            {
                Service servicetoadd = new Service(service.Service_name);
                MyList.Add(servicetoadd);
                foreach (Shift shift in service.ShiftListing)
                {
                    foreach (OpenWeekDay open in shift.Opening_Day)
                    {
                        if ((open.IsOpen == true) && (open.Day == this.Date_time.DayOfWeek))
                        {
                            MyList[MyList.IndexOf(servicetoadd)].ShiftListing.Add(shift);
                        }
                    }
                }
                if (servicetoadd.ShiftListing.Count == 0)
                {
                    MyList.Remove(servicetoadd);
                }
            }
            return(MyList);
        }