Esempio n. 1
0
        public void GetUserCalendars_CalendarsForMultipleUsers_ReturnsOnlyCalendarsForGivenUser()
        {
            var calendar1 = new Calendar
            {
                Name        = "Calendar 1",
                Description = "Description 1",
                User        = null,
                UserId      = 1,
                Events      = null
            };
            var calendar2 = new Calendar
            {
                Name        = "Calendar 2",
                Description = "Description 2",
                User        = null,
                UserId      = 2,
                Events      = null
            };

            _context.AddRange(calendar1, calendar2);
            _context.SaveChanges();
            var calendarRepo = new CalendarRepository(_context);

            var actual = calendarRepo.GetUserCalendars(1);

            Assert.Collection(actual,
                              calendar => Assert.Contains("Calendar 1", calendar.Name));
        }
Esempio n. 2
0
        public void GetCalendar_InvalidCalendarId_ReturnNull()
        {
            var calendarRepo = new CalendarRepository(_context);
            var actual       = calendarRepo.GetCalendar(3);

            Assert.Null(actual);
        }
Esempio n. 3
0
        public void RemoveCalendar_InvalidCalendarId_ReturnFalse()
        {
            var calendarRepo = new CalendarRepository(_context);
            var actual       = calendarRepo.DeleteCalendar(2);

            Assert.False(actual);
        }
Esempio n. 4
0
        public void EditCalendar_CalendarIdNotFound_ReturnFalse()
        {
            var calendar1 = new Calendar
            {
                Id          = 1,
                Name        = "Calendar 1",
                Description = "",
                User        = null,
                UserId      = 1,
                Events      = null
            };

            var editedCalendar = new Calendar
            {
                Id          = 2,
                Name        = "EditedCalendar 1",
                Description = "Description",
                User        = null,
                UserId      = 1,
                Events      = null
            };

            _context.Add(calendar1);
            _context.SaveChanges();

            var calendarRepo = new CalendarRepository(_context);
            var actual       = calendarRepo.EditCalendar(editedCalendar);

            Assert.False(actual);
        }
        public async Task <IHttpActionResult> Events(DateTime start, DateTime end)
        {
            var repository = new CalendarRepository();
            var events     = await repository.Events(start, end);

            return(Ok(events));
        }
Esempio n. 6
0
        public void RemoveCalendar_ValidCalendarId_ReturnTrue()
        {
            var calendar1 = new Calendar
            {
                Name        = "Calendar 1",
                Description = "",
                User        = null,
                UserId      = 1,
                Events      = null
            };
            var calendar2 = new Calendar
            {
                Name        = "Calendar 2",
                Description = "",
                User        = null,
                UserId      = 1,
                Events      = null
            };

            _context.AddRange(calendar1, calendar2);
            _context.SaveChanges();

            var calendarRepo = new CalendarRepository(_context);

            var actual = calendarRepo.DeleteCalendar(1);

            Assert.True(actual);
        }
Esempio n. 7
0
        public static PmsProject SelPmsObject(PmsProject _param)
        {
            if (_param.Type == null)
            {
                _param.Type = PmsConstant.TYPE_PROJECT;
            }
            PmsProject pmsProject = DaoFactory.GetData <PmsProject>("Pms.SelPmsProject", _param);

            pmsProject.BPolicy = BPolicyRepository.SelBPolicy(new BPolicy {
                Type = pmsProject.Type, OID = pmsProject.BPolicyOID
            }).First();
            pmsProject.Calendar = CalendarRepository.SelCalendar(new Calendar {
                Type = CommonConstant.TYPE_CALENDAR, OID = pmsProject.CalendarOID
            });
            PmsRelationship Member = PmsRelationshipRepository.SelPmsRelationship(new PmsRelationship {
                Type = PmsConstant.RELATIONSHIP_MEMBER, RootOID = pmsProject.OID, RoleOID = BDefineRepository.SelDefine(new BDefine {
                    Module = PmsConstant.MODULE_PMS, Type = CommonConstant.DEFINE_ROLE, Name = PmsConstant.ROLE_PM
                }).OID
            }).First();

            pmsProject.PMNm = PersonRepository.SelPerson(new Person {
                OID = Member.ToOID
            }).Name;
            return(pmsProject);
        }
Esempio n. 8
0
        public async Task <ActionResult> UserInfo()
        {
            VolunteerRepository repo         = new VolunteerRepository(configModel.ConnectionString);
            CalendarRepository  calendarRepo = new CalendarRepository(configModel.ConnectionString);
            ClassRepository     classRepo    = new ClassRepository(configModel.ConnectionString);
            BusRepository       busRepo      = new BusRepository(configModel.ConnectionString);
            AttendanceModel     attendance;
            VolunteerModel      profile;
            var user = await userManager.GetUserAsync(User);

            bool checkedIn            = false;
            List <ClassModel> classes = new List <ClassModel>();
            List <BusModel>   buses   = new List <BusModel>();

            // Get the current user's profile
            try
            {
                profile = repo.GetVolunteer(user.VolunteerId);
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(e.Message));
            }

            if (profile == null)
            {
                return(Utilities.ErrorJson("Could not find user profile"));
            }

            if (configModel.DebugMode || DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
            {
                try
                {
                    attendance = calendarRepo.GetSingleAttendance(profile.Id, DateTime.Now.Date);

                    // determine if the current user has been checked in today
                    if (attendance != null && attendance.Attended == true)
                    {
                        checkedIn = true;
                    }

                    // Get the classes the user teaches and buses the user drives
                    classes = classRepo.GetClasses(true).Where(c => c.TeacherId == profile.Id).ToList();
                    buses   = busRepo.GetBusList(true).Where(b => b.DriverId == profile.Id).ToList();
                }
                catch (Exception e)
                {
                    return(Utilities.ErrorJson(e.Message));
                }
            }

            return(new JsonResult(new
            {
                Error = "",
                Profile = profile,
                CheckedIn = checkedIn,
                Classes = classes,
                Buses = buses
            }));
        }
        public void TestUpdateSeries()
        {
            var calendarRepository = new CalendarRepository();
            var calendarId         = calendarRepository.CreateCalendar(new CreateCalendarDto("MM-DD-YYYY", "", "", testLibrary.LibraryId));

            var seriesToCreate = new CreateSeriesDto("Test library", "https://ingvilt.test.url", -1, "test desc", -1, testLibrary.LibraryId, calendarId);
            var seriesId       = repository.CreateSeries(seriesToCreate);

            var seriesRetrieved = repository.GetSeries(seriesId).Result;
            var fileId          = mediaFileRepository.CreateMediaFile(new CreateMediaFileDto("C:/test.jpg", MediaFileType.IMAGE_TYPE, "test"));

            seriesRetrieved.Description += "1";
            seriesRetrieved.Name        += "2";
            seriesRetrieved.SiteURL      = "https://ingvilt.test2.url";
            seriesRetrieved.LogoFileId   = fileId;
            repository.UpdateSeries(seriesRetrieved);

            var updatedSeriesRetrieved = repository.GetSeries(seriesId).Result;

            Assert.AreEqual(seriesRetrieved.SeriesId, updatedSeriesRetrieved.SeriesId);
            Assert.AreEqual(seriesRetrieved.Name, updatedSeriesRetrieved.Name);
            Assert.AreEqual(seriesRetrieved.Description, updatedSeriesRetrieved.Description);
            Assert.AreEqual(seriesRetrieved.LibraryId, updatedSeriesRetrieved.LibraryId);
            Assert.AreEqual(seriesRetrieved.LogoFileId, updatedSeriesRetrieved.LogoFileId);
            Assert.AreEqual(seriesRetrieved.SiteURL, updatedSeriesRetrieved.SiteURL);
            Assert.AreEqual(seriesRetrieved.CalendarId, updatedSeriesRetrieved.CalendarId);
            CollectionAssert.AreEquivalent(new List <Series>()
            {
                updatedSeriesRetrieved
            }, repository.GetSeries(GetFirstPage()).Result.Results);
        }
Esempio n. 10
0
        public ActionResult FireTimes(string instanceName, string groupName, string itemName)
        {
            InstanceModel     instance = instanceRepo.GetInstance(instanceName);
            TriggerRepository trigRepo = new TriggerRepository(instance);

            TriggerFireTimesModel m = new TriggerFireTimesModel();

            m.Trigger = trigRepo.GetTrigger(itemName, groupName);

            CalendarRepository calRepo = new CalendarRepository(instance);

            m.Calendar = calRepo.GetCalendar(m.Trigger.CalendarName);

            ViewData["groupName"] = groupName;

            if (m.Trigger == null)
            {
                ViewData["triggerName"] = itemName;
                return(View("NotFound"));
            }
            else
            {
                return(View(m));
            }
        }
Esempio n. 11
0
        public void GetCalendar_ValidCalendarId_ReturnCalendar()
        {
            var calendar1 = new Calendar
            {
                Id          = 1,
                Name        = "Calendar 1",
                Description = "Description 1",
                User        = null,
                UserId      = 1,
                Events      = new System.Collections.Generic.List <Event>()
            };
            var calendar2 = new Calendar
            {
                Id          = 2,
                Name        = "Calendar 2",
                Description = "Description 2",
                User        = null,
                UserId      = 1,
                Events      = new System.Collections.Generic.List <Event>()
            };

            _context.AddRange(calendar1, calendar2);
            _context.SaveChanges();
            var calendarRepo = new CalendarRepository(_context);

            var actual = calendarRepo.GetCalendar(1);

            Assert.Equal(calendar1.Name, actual.Name);
            Assert.Equal(calendar1.Id, actual.Id);
        }
Esempio n. 12
0
        private void UseGoogleCalendar()
        {
            UserCredential credential;

            using (var stream =
                       new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
            {
                // The file token.json stores the user's access and refresh tokens, and is created
                // automatically when the authorization flow completes for the first time.
                string credPath = "token.json";
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
            }

            // Create Google Calendar API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            var calendarRepository = new CalendarRepository(service);

            calendarRepository.EventInsert("Hello", DateTime.Now);
        }
Esempio n. 13
0
        public void SearchDBKeyword_returns_1_results()
        {
            IEventRepository repo   = new CalendarRepository(new EventsData().Load());
            List <CalEvent>  actual = repo.Search("week", "", DateTime.MinValue, DateTime.MinValue, true, 0);

            Assert.IsNotNull(actual, "DB not returning results.");
        }
Esempio n. 14
0
        public void SearchByKeyword_returns_1_result()
        {
            IEventRepository repo     = new CalendarRepository(new MockEventsData().Load());
            List <CalEvent>  actual   = repo.Search("Grades Due");
            CalEvent         calEvent = new CalEvent()
            {
                CalendarId     = 1724,
                Title          = "Grades Due",
                Description    = "Suspendisse fermentum nibh ac cursus pretium. Vivamus neque urna, cursus vitae blandit ut, condimentum quis dui. Donec nec sollicitudin odio, id gravida lorem. Aliquam erat volutpat. Curabitur id turpis elementum libero volutpat lacinia. Vivamus fermentum nulla maximus ante volutpat, sit amet molestie tellus mollis. Duis pharetra tincidunt dolor quis congue. Nunc diam lacus, rhoncus in tristique ornare, mollis nec sem. Suspendisse dictum orci imperdiet ullamcorper pretium. Nulla sollicitudin libero massa, ut placerat justo laoreet pulvinar. Morbi luctus at massa vel sodales. Aenean bibendum lobortis mauris. Etiam at dignissim massa. Nulla sit amet condimentum sapien.",
                StartDate      = new DateTime(2015, 4, 23),
                EndDate        = new DateTime(2015, 4, 23),
                StartTime      = "7:00 PM",
                EndTime        = "9:00 PM",
                ContactName    = "Shatealy Johnson",
                ContactDetails = "*****@*****.**",
                EventType      = "calendar",
                Status         = "live",
                Url            = "http://www.google.com"
            };

            List <CalEvent> expected = new List <CalEvent>();

            expected.Add(calEvent);

            Assert.AreEqual(expected[0].CalendarId, actual[0].CalendarId, "CalendarId not equal");
            Assert.AreEqual(expected[0].Title, actual[0].Title, "Title not equal");
            Assert.AreEqual(expected[0].StartDate, actual[0].StartDate, "StartDate not equal");
            Assert.AreEqual(expected[0].EndDate, actual[0].EndDate, "EndDate not equal");
            Assert.AreEqual(expected[0].ContactName, actual[0].ContactName, "ContactName not equal");
            Assert.AreEqual(expected[0].EventType, actual[0].EventType, "EventType not equal");
            Assert.AreEqual(expected[0].Status, actual[0].Status, "Status not equal");
        }
Esempio n. 15
0
        public void SearchRange_returns_3_results()
        {
            IEventRepository repo     = new CalendarRepository(new MockEventsData().Load());
            List <CalEvent>  actual   = repo.Search("", "", DateTime.Now.AddYears(-1), DateTime.Now.AddYears(1), false, 0);
            List <CalEvent>  expected = new MockEventsData().Load();

            Assert.AreEqual(expected[1].CalendarId, actual[0].CalendarId, "CalendarId not equal in first");
            Assert.AreEqual(expected[1].Title, actual[0].Title, "Title not equal in first");
            Assert.AreEqual(expected[1].StartDate, actual[0].StartDate, "StartDate not equal in first");
            Assert.AreEqual(expected[1].EndDate, actual[0].EndDate, "EndDate not equal in first");
            Assert.AreEqual(expected[1].ContactName, actual[0].ContactName, "ContactName not equal in first");
            Assert.AreEqual(expected[1].EventType, actual[0].EventType, "EventType not equal in first");
            Assert.AreEqual(expected[1].Status, actual[0].Status, "Status not equal in first");

            Assert.AreEqual(expected[2].CalendarId, actual[1].CalendarId, "CalendarId not equal in second");
            Assert.AreEqual(expected[2].Title, actual[1].Title, "Title not equal in second");
            Assert.AreEqual(expected[2].StartDate, actual[1].StartDate, "StartDate not equal in second");
            Assert.AreEqual(expected[2].EndDate, actual[1].EndDate, "EndDate not equal in second");
            Assert.AreEqual(expected[2].ContactName, actual[1].ContactName, "ContactName not equal in second");
            Assert.AreEqual(expected[2].EventType, actual[1].EventType, "EventType not equal in second");
            Assert.AreEqual(expected[2].Status, actual[1].Status, "Status not equal in second");

            Assert.AreEqual(expected[3].CalendarId, actual[2].CalendarId, "CalendarId not equal in third");
            Assert.AreEqual(expected[3].Title, actual[2].Title, "Title not equal in third");
            Assert.AreEqual(expected[3].StartDate, actual[2].StartDate, "StartDate not equal in third");
            Assert.AreEqual(expected[3].EndDate, actual[2].EndDate, "EndDate not equal in third");
            Assert.AreEqual(expected[3].ContactName, actual[2].ContactName, "ContactName not equal in third");
            Assert.AreEqual(expected[3].EventType, actual[2].EventType, "EventType not equal in third");
            Assert.AreEqual(expected[3].Status, actual[2].Status, "Status not equal in third");
        }
Esempio n. 16
0
        public async Task <ActionResult> Events()
        {
            CalendarRepository repo = new CalendarRepository();
            var events = await repo.GetCalendarEvents();

            return(View(events));
        }
Esempio n. 17
0
        // Constructors

        public SubscriptionController()
        {
            _dataContext            = new DataContext();
            _calendarRepository     = new CalendarRepository(_dataContext);
            _userRepository         = new UserRepository(_dataContext);
            _subscriptionRepository = new Calendar_SubscriptionRepository(_dataContext);
        }
        ///<inheritdoc/>
        public override void Handle(BrokeredMessage message)
        {
            var calendarRepository = new CalendarRepository(new MyCompanyContext());
            var calendarId         = message.GetBody <int>();

            calendarRepository.Delete(calendarId);
        }
Esempio n. 19
0
        public void SearchByKeyword_returns_no_results()
        {
            IEventRepository repo     = new CalendarRepository(new MockEventsData().Load());
            List <CalEvent>  actual   = repo.Search("Nothing");
            Int32            expected = 0;

            Assert.AreEqual(expected, actual.Count, "Search result found");
        }
Esempio n. 20
0
        public void SearchDBOnlyActive_returns_10_results()
        {
            Int32            expected = 10;
            IEventRepository repo     = new CalendarRepository(new EventsData().Load());
            List <CalEvent>  actual   = repo.Search("", "", DateTime.MinValue, DateTime.MinValue, true, expected);

            Assert.AreEqual(expected, actual.Count, "DB not returning 10 results.");
        }
Esempio n. 21
0
        public void Search_returns_no_results()
        {
            IEventRepository repo     = new CalendarRepository(new MockEventsData().Load());
            List <CalEvent>  actual   = repo.Search("Nothing", "", DateTime.Now.AddYears(-1), DateTime.Now.AddYears(1), true, 0);
            Int32            expected = 0;

            Assert.AreEqual(expected, actual.Count, "Search result found");
        }
        public async Task <ActionResult> Calendar(string CalendarId)
        {
            var           calenRep = new CalendarRepository();
            CalendarParam calendar = new CalendarParam();

            calendar.calendar_id = CalendarId;
            return(View(calenRep.GetEvents(calendar)));
        }
 public async Task Add_Entrie_ToDb()
 {
     using (var context = HelperClass.CreateInMemoryDB(HelperClass.CreateItems(), dbName: "AddDb"))
     {
         var calendarRepository = new CalendarRepository(context);
         Assert.Equal(3, (await calendarRepository.GetCalendarEntriesAsync()).Count());
     }
 }
Esempio n. 24
0
        ///<inheritdoc/>
        public override void Handle(BrokeredMessage message)
        {
            var calendarRepository = new CalendarRepository(new MyCompanyContext());
            var dto      = message.GetBody <CalendarDTO>();
            var calendar = Mapper.Map <Calendar>(dto);

            calendarRepository.Add(calendar);
        }
        public async Task <IActionResult> VolunteerInfo(int id)
        {
            var user = await userManager.GetUserAsync(User);

            VolunteerRepository repo         = new VolunteerRepository(configModel.ConnectionString);
            CalendarRepository  calendarRepo = new CalendarRepository(configModel.ConnectionString);
            VolunteerModel      volunteer;
            AttendanceModel     attendance;
            bool checkedIn = false;

            // Ensure that ONLY staff accounts have access to this API endpoint
            if (user == null || !await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))
            {
                return(Utilities.ErrorJson("Not authorized"));
            }

            if (id == 0)
            {
                return(Utilities.ErrorJson("Must include an id"));
            }

            try
            {
                volunteer = repo.GetVolunteer(id);
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(configModel.DebugMode ? e.Message : "An error occurred while accessing the database."));
            }

            if (volunteer == null)
            {
                return(Utilities.ErrorJson("Invalid id"));
            }

            try
            {
                attendance = calendarRepo.GetSingleAttendance(volunteer.Id, DateTime.Now.Date);

                // determine if the current user has been checked in today
                if (attendance != null && attendance.Attended == true)
                {
                    checkedIn = true;
                }
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(e.Message));
            }

            return(new JsonResult(new
            {
                Error = "",
                Volunteer = volunteer,
                CheckedIn = checkedIn
            }));
        }
Esempio n. 26
0
        public ActionResult Delete(Guid id)
        {
            var cr       = new CalendarRepository();
            var model    = cr.GetAll(UserController.currentUser.Id);
            var toDelete = model.Where(x => id.Equals(x.Id)).FirstOrDefault();

            cr.Delete(toDelete);
            return(RedirectToAction("Calendar"));
        }
        public async Task <ActionResult> QuickAdd(string CalendarId, string Summary)
        {
            var calenRep = new CalendarRepository();
            CalendarEventParam calendar = new CalendarEventParam();

            calendar.calendar_id = CalendarId;
            calendar.summary     = Summary;
            return(View(calenRep.QuickAddEvent(calendar)));
        }
        public async Task <ActionResult> DelEvent(string CalendarId, string EventId)
        {
            var calenRep = new CalendarRepository();
            CalendarEventParam calendar = new CalendarEventParam();

            calendar.calendar_id = CalendarId;
            calendar.event_id    = EventId;
            return(View(calenRep.DeleteEvent(calendar)));
        }
Esempio n. 29
0
        public async Task <IActionResult> EventEdit(EventModel eventModel)
        {
            var user = await userManager.GetUserAsync(User);

            CalendarRepository repo = new CalendarRepository(configModel.ConnectionString);
            EventModel         dbEvent;

            // Ensure that ONLY staff accounts have access to this API endpoint
            if (user == null || !await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))
            {
                return(Utilities.ErrorJson("Not authorized"));
            }

            // Validate that the required fields (name and date) are filled out.
            // Note that in C#, DateTimes are never null, so instead of checking for null, we check for DateTime.MinValue, which is the
            // default value that ASP.NET's model binding will provide if the date is not included in the API call.
            if (eventModel.Date == DateTime.MinValue || String.IsNullOrEmpty(eventModel.Name))
            {
                return(Utilities.ErrorJson("The event must have both a name and a date"));
            }
            if (eventModel.Id == 0)
            {
                return(Utilities.ErrorJson("Must specify an event to edit"));
            }

            // If the description is null, set it to an empty string instead just to avoid nulls in the database
            if (String.IsNullOrEmpty(eventModel.Description))
            {
                eventModel.Description = "";
            }

            // Get the existing event in the database
            dbEvent = repo.GetEvent(eventModel.Id);

            // Check that the event to be edited actually exists
            if (dbEvent == null)
            {
                return(Utilities.ErrorJson("Specified event does not exist"));
            }

            // Update the event in the database
            try
            {
                repo.UpdateEvent(eventModel);
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(e.Message));
            }

            return(new JsonResult(new
            {
                Error = ""
            }));
        }
Esempio n. 30
0
        public async Task <IActionResult> CancelEvent(EventViewModel eventViewModel)
        {
            int eventId = eventViewModel.eventId;
            var user    = await userManager.GetUserAsync(User);

            VolunteerRepository volRepo = new VolunteerRepository(configModel.ConnectionString);
            CalendarRepository  repo    = new CalendarRepository(configModel.ConnectionString);
            VolunteerModel      volunteer;
            EventModel          eventModel;
            EventSignupModel    signup;

            // Ensure that ONLY volunteer, volunteer captain, and bus driver accounts have access to this API endpoint
            if (user == null ||
                !(await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Volunteer.ToString()) ||
                  await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.VolunteerCaptain.ToString()) ||
                  await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.BusDriver.ToString())))
            {
                return(Utilities.ErrorJson("Event signup is available only to volunteers, volunteer captains, and bus drivers"));
            }

            volunteer = volRepo.GetVolunteer(user.VolunteerId);

            if (volunteer == null)
            {
                return(Utilities.ErrorJson("Unable to find volunteer profile"));
            }

            eventModel = repo.GetEvent(eventId);

            // Verify that the specified event exists
            if (eventModel == null)
            {
                return(Utilities.ErrorJson("Specified event does not exist."));
            }

            // Check if there is already a record of this user having signed up
            signup = repo.GetEventSignup(eventId, volunteer.Id);

            if (signup == null)
            {
                // If no record exists of the user signing up, or they have already cancelled, then let them know
                return(Utilities.ErrorJson("You are not signed up for this event"));
            }
            else
            {
                // Otherwise, update the record to indicate non-attendance
                repo.DeleteEventSignup(eventId, volunteer.Id);
            }

            return(new JsonResult(new
            {
                Error = ""
            }));
        }
Esempio n. 31
0
        /// <summary>
        /// When implemented in a derived class, executes the scheduled job asynchronously. Implementations that want to know whether
        ///             the scheduled job is being cancelled can get a <see cref="P:Microsoft.WindowsAzure.Mobile.Service.ScheduledJob.CancellationToken"/> from the <see cref="M:CancellationToken"/> property.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Threading.Tasks.Task"/> representing the asynchronous operation.
        /// </returns>
        public override async Task ExecuteAsync()
        {
            // Load Feed Message
            var dbConnStr = ConfigurationManager.ConnectionStrings["MTA_DB"].ConnectionString;

            var service = new StaticFileService(new StaticFileDownloader());


            StringBuilder sb = new StringBuilder();

            List<string> tableNames = new List<string>()
            {
                "agency",
                "calendar",
                "calendar_dates",
                "shapes",
                "stop_times",
                "transfers",
                "trips",
                "routes",
                "stops",
            };

            tableNames.ForEach(s => sb.AppendFormat("TRUNCATE TABLE {0};", s));

            using (var conn = new SqlConnection(dbConnStr))
            {
                using (var cmd = new SqlCommand(sb.ToString(), conn))
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }


                //Agency
                using (var repository = new AgencyRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetAgencies());
                }

//            using (var repository = new CalendarDateRepository(dbConnStr))
//            {
//                // Load Tables
//                repository.AddRange(service.GetCalendarDates());
//            }

                //Calendars
                using (var repository = new CalendarRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetCalendars());
                }
                //Route
                using (var repository = new RouteRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetRoutes());
                }
                //Shape
                using (var repository = new ShapeRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetShapes());
                }
                //Stop
                using (var repository = new StopRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetStops());
                }
                //Stop Time
                using (var repository = new StopTimeRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetStopTimes());
                }
                //Transfer
                using (var repository = new TransferRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetTransfers());
                }
                //Trip
                using (var repository = new TripRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetTrips());
                }

                // Build Stations
                using (var cmd = new SqlCommand("sp_BuildStations", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
//                    conn.Open();
                    cmd.ExecuteNonQuery();
                }

                using (var cmd = new SqlCommand("sp_CreateStaticSchedule", conn))
                {
                    cmd.CommandTimeout = 120;
                    cmd.CommandType = CommandType.StoredProcedure;
                    //                    conn.Open();

                    TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
                    DateTime easternTimeNow = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.Utc,
                                                                    easternZone);
                    cmd.Parameters.AddWithValue("@today", easternTimeNow);

                    cmd.ExecuteNonQuery();
                }
            }
        }