Exemplo n.º 1
0
        public void ScheduleConstructorHandlesMonthlyDayOfWeekSchedule()
        {
            const string expectedDayOfWeek = "Saturday";
            const int    occurrence        = 1;

            var sdkSchedule = new Schedule()
            {
                Frequency        = "Month",
                AdvancedSchedule = new AdvancedSchedule()
                {
                    WeekDays           = null,
                    MonthDays          = null,
                    MonthlyOccurrences = new List <AdvancedScheduleMonthlyOccurrence>()
                    {
                        new AdvancedScheduleMonthlyOccurrence()
                        {
                            Day        = expectedDayOfWeek,
                            Occurrence = occurrence,
                        },
                    },
                },
            };

            var schedule = new Model.Schedule("anyRg", "anyAccount", sdkSchedule);

            Assert.NotNull(schedule.MonthlyScheduleOptions);
            Assert.Null(schedule.WeeklyScheduleOptions);

            Assert.Null(schedule.MonthlyScheduleOptions.DaysOfMonth);
            Assert.NotNull(schedule.MonthlyScheduleOptions.DayOfWeek);

            Assert.Equal(expectedDayOfWeek, schedule.MonthlyScheduleOptions.DayOfWeek.Day);
            Assert.Equal(Enum.GetName(typeof(DayOfWeekOccurrence), occurrence), schedule.MonthlyScheduleOptions.DayOfWeek.Occurrence);
        }
Exemplo n.º 2
0
        public async Task <Occupancy> GetLastOccupancy()
        {
            Model.Schedule lastSchedule = await dc.Schedules.OrderByDescending(s => s.Day).FirstOrDefaultAsync();

            Occupancy lastOccupancy = new Occupancy(lastSchedule.Day);

            return(lastOccupancy);
        }
Exemplo n.º 3
0
        public void ScheduleConstructorHandlesWeeklySchedule()
        {
            var sdkSchedule = new Schedule()
            {
                Frequency        = "Week",
                AdvancedSchedule = new AdvancedSchedule()
                {
                    WeekDays = new List <string>()
                    {
                        "Monday"
                    },
                    MonthDays          = null,
                    MonthlyOccurrences = null,
                },
            };

            var schedule = new Model.Schedule("anyRg", "anyAccount", sdkSchedule);

            Assert.Null(schedule.MonthlyScheduleOptions);
            Assert.NotNull(schedule.WeeklyScheduleOptions);

            Assert.NotNull(schedule.WeeklyScheduleOptions.DaysOfWeek);
        }
Exemplo n.º 4
0
        private static void InitializeSchedules()
        {
            if (!context.Users.Any())
            {
                User user_01 = new User {
                    Name = "Chris Sakellarios", Profession = "Developer", Avatar = "avatar_02.png"
                };

                User user_02 = new User {
                    Name = "Charlene Campbell", Profession = "Web Designer", Avatar = "avatar_03.jpg"
                };

                User user_03 = new User {
                    Name = "Mattie Lyons", Profession = "Engineer", Avatar = "avatar_05.png"
                };

                User user_04 = new User {
                    Name = "Kelly Alvarez", Profession = "Network Engineer", Avatar = "avatar_01.png"
                };

                User user_05 = new User {
                    Name = "Charlie Cox", Profession = "Developer", Avatar = "avatar_03.jpg"
                };

                User user_06 = new User {
                    Name = "Megan	Fox", Profession = "Hacker", Avatar = "avatar_05.png"
                };

                context.Users.Add(user_01); context.Users.Add(user_02);
                context.Users.Add(user_03); context.Users.Add(user_04);
                context.Users.Add(user_05); context.Users.Add(user_06);

                context.SaveChanges();
            }

            if (!context.Schedules.Any())
            {
                Model.Schedule schedule_01 = new Model.Schedule
                {
                    Title       = "Meeting",
                    Description = "Meeting at work with the boss",
                    Location    = "Korai",
                    CreatorId   = 1,
                    Status      = ScheduleStatus.Valid,
                    Type        = ScheduleType.Work,
                    TimeStart   = DateTime.Now.AddHours(4),
                    TimeEnd     = DateTime.Now.AddHours(6),
                    Attendees   = new List <Attendee>
                    {
                        new Attendee()
                        {
                            ScheduleId = 1, UserId = 2
                        },
                        new Attendee()
                        {
                            ScheduleId = 1, UserId = 3
                        },
                        new Attendee()
                        {
                            ScheduleId = 1, UserId = 4
                        }
                    }
                };

                Model.Schedule schedule_02 = new Model.Schedule
                {
                    Title       = "Coffee",
                    Description = "Coffee with folks",
                    Location    = "Athens",
                    CreatorId   = 2,
                    Status      = ScheduleStatus.Valid,
                    Type        = ScheduleType.Coffee,
                    TimeStart   = DateTime.Now.AddHours(3),
                    TimeEnd     = DateTime.Now.AddHours(6),
                    Attendees   = new List <Attendee>
                    {
                        new Attendee()
                        {
                            ScheduleId = 2, UserId = 1
                        },
                        new Attendee()
                        {
                            ScheduleId = 1, UserId = 3
                        },
                        new Attendee()
                        {
                            ScheduleId = 2, UserId = 4
                        }
                    }
                };

                Model.Schedule schedule_03 = new Model.Schedule
                {
                    Title       = "Shopping day",
                    Description = "Shopping therapy",
                    Location    = "Attica",
                    CreatorId   = 3,
                    Status      = ScheduleStatus.Valid,
                    Type        = ScheduleType.Shopping,
                    TimeStart   = DateTime.Now.AddHours(3),
                    TimeEnd     = DateTime.Now.AddHours(6),
                    Attendees   = new List <Attendee>
                    {
                        new Attendee()
                        {
                            ScheduleId = 3, UserId = 1
                        },
                        new Attendee()
                        {
                            ScheduleId = 3, UserId = 4
                        },
                        new Attendee()
                        {
                            ScheduleId = 3, UserId = 5
                        }
                    }
                };

                Model.Schedule schedule_04 = new Model.Schedule
                {
                    Title       = "Family",
                    Description = "Thanks giving day",
                    Location    = "Home",
                    CreatorId   = 5,
                    Status      = ScheduleStatus.Valid,
                    Type        = ScheduleType.Other,
                    TimeStart   = DateTime.Now.AddHours(3),
                    TimeEnd     = DateTime.Now.AddHours(6),
                    Attendees   = new List <Attendee>
                    {
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 1
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 2
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 5
                        }
                    }
                };

                Model.Schedule schedule_05 = new Model.Schedule
                {
                    Title       = "Friends",
                    Description = "Friends giving day",
                    Location    = "Home",
                    CreatorId   = 5,
                    Status      = ScheduleStatus.Cancelled,
                    Type        = ScheduleType.Other,
                    TimeStart   = DateTime.Now.AddHours(5),
                    TimeEnd     = DateTime.Now.AddHours(7),
                    Attendees   = new List <Attendee>
                    {
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 1
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 2
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 3
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 4
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 5
                        }
                    }
                };

                Model.Schedule schedule_06 = new Model.Schedule
                {
                    Title       = "Meeting with the boss and collegues",
                    Description = "Discuss project planning",
                    Location    = "Office",
                    CreatorId   = 3,
                    Status      = ScheduleStatus.Cancelled,
                    Type        = ScheduleType.Other,
                    TimeStart   = DateTime.Now.AddHours(22),
                    TimeEnd     = DateTime.Now.AddHours(30),
                    Attendees   = new List <Attendee>
                    {
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 1
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 2
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 5
                        }
                    }
                };

                Model.Schedule schedule_07 = new Model.Schedule
                {
                    Title       = "Scenario presentation",
                    Description = "Discuss new movie's scenario",
                    Location    = "My special place",
                    CreatorId   = 6,
                    Status      = ScheduleStatus.Cancelled,
                    Type        = ScheduleType.Other,
                    TimeStart   = DateTime.Now.AddHours(11),
                    TimeEnd     = DateTime.Now.AddHours(13),
                    Attendees   = new List <Attendee>
                    {
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 4
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 2
                        },
                        new Attendee()
                        {
                            ScheduleId = 4, UserId = 3
                        }
                    }
                };

                context.Schedules.Add(schedule_01); context.Schedules.Add(schedule_02);
                context.Schedules.Add(schedule_03); context.Schedules.Add(schedule_04);
                context.Schedules.Add(schedule_05); context.Schedules.Add(schedule_06);
            }

            context.SaveChanges();
        }
Exemplo n.º 5
0
 public static bool Insert(Model.Schedule model)
 {
     return(DAL.DB.Insert <Model.Schedule>(model));
 }
Exemplo n.º 6
0
 public static bool Update(Guid id, Model.Schedule model)
 {
     return(DAL.DB.Update <Model.Schedule>(id, model));
 }