public IActionResult Index([FromHeader] string sendJson)
        {
            ViewBag.Active = "Schedule";
            string sqlString = "SELECT * FROM Schedule ORDER BY datetime(StartTime)";

            var eventList = ScheduleDBConnector.GetSchedules(Constants.DATA_SOURCE, sqlString);

            return(sendJson != null && sendJson.Equals("True") ? Json(eventList) : (IActionResult)View(eventList));
        }
Exemplo n.º 2
0
        public IActionResult Index(int year, int month, int day, [FromHeader] string sendJson)
        {
            if (month < 1 || month > 12 || day < 1 || day > 31)
            {
                return(sendJson != null && sendJson.Equals("True") ? Json(new List <Schedule>()) : (IActionResult)View("Views/Schedule/Index.cshtml", null));
            }

            string sqlString = "SELECT * FROM Schedule WHERE Date(StartTime) = \"" + year + "-" + (month < 10 ? "0" : "") + month + "-" + (day < 10 ? "0" : "") + day + "\"";

            var model = ScheduleDBConnector.GetSchedules(Constants.DATA_SOURCE, sqlString);

            return(sendJson != null && sendJson.Equals("True") ? Json(model) : (IActionResult)View("Views/Schedule/Index.cshtml", model));
        }
Exemplo n.º 3
0
        public void TestDelete()
        {
            Schedule schedule = new Schedule();

            schedule.EventTitle       = "Test title";
            schedule.EventDescription = "Description";
            schedule.StartTime        = "2018-01-22 22:11:32";
            Assert.True(ScheduleDBConnector.Create(dataSource, schedule));

            List <Schedule> schedules = ScheduleDBConnector.GetSchedules(dataSource, "SELECT * FROM Schedule ORDER BY datetime(StartTime)");

            Assert.NotNull(schedules);

            Assert.True(FaqDBConnector.Delete(dataSource, (int)schedules[0].Id));
        }
Exemplo n.º 4
0
        public void TestInsert()
        {
            List <Schedule> schedules = ScheduleDBConnector.GetSchedules(dataSource, "SELECT * FROM Schedule ORDER BY datetime(StartTime)");

            Assert.NotNull(schedules);
            int count = schedules.Count;

            Schedule schedule = new Schedule();

            schedule.EventTitle       = "Test title";
            schedule.EventDescription = "Description";
            schedule.StartTime        = "2018-01-22 22:11:32";
            Assert.True(ScheduleDBConnector.Create(dataSource, schedule));


            schedules = ScheduleDBConnector.GetSchedules(dataSource, "SELECT * FROM Schedule ORDER BY datetime(StartTime)");
            Assert.NotNull(schedules);
            Assert.Equal(count + 1, schedules.Count);
        }
Exemplo n.º 5
0
        public void TestRetrieveAll()
        {
            List <Schedule> schedules = ScheduleDBConnector.GetSchedules(dataSource, "SELECT * FROM Schedule ORDER BY datetime(StartTime)");

            Assert.NotNull(schedules);
        }