Beispiel #1
0
        public void Adding_ScheduleItem_On_Blacked_Out_Date_Should_Fail()
        {
            DateTime           blackedOutDate = DateTime.Now.AddDays(3);
            string             key            = KeyHelper.GetKey <IScheduleRepository>();
            var                repository     = RepositoryFactory.GetRepository <IScheduleRepository>(key);
            ScheduleController controller     = new ScheduleController();

            controller.CreateSchedule(TestFactories.GetDefaultLookup(), "Test Schedule", "This is a test", "test user");

            Schedule schedule = repository.GetAllSchedules().Last();

            controller.CreateBlackoutDate(schedule, "Test blackout date", blackedOutDate, "test user");

            try
            {
                controller.CreateScheduleItem(schedule, blackedOutDate, TestFactories.GetDefaultPerson(), new List <Baptizer>(),
                                              TestFactories.GetDefaultPerson(), true, "test user");
                Assert.Fail("controller.CreateScheduleItem() should throw an exception.");
            }
            catch (ValidationException ex)
            {
                Assert.IsTrue(ex.Errors[0].Contains("Unable to schedule a baptism on a Black Out Date."));
                Assert.AreEqual(ex.Errors.Count, 1);
            }
        }
Beispiel #2
0
        public Schedule CreateSchedule()
        {
            string             key        = KeyHelper.GetKey <IScheduleRepository>();
            var                repository = RepositoryFactory.GetRepository <IScheduleRepository>(key);
            ScheduleController controller = new ScheduleController();

            controller.CreateSchedule(TestFactories.GetDefaultLookup(), "Test Schedule", "This is a test", "test user");
            return(repository.GetAllSchedules().Last());
        }
Beispiel #3
0
        public void Schedule_Create()
        {
            string             key        = KeyHelper.GetKey <IScheduleRepository>();
            var                repository = RepositoryFactory.GetRepository <IScheduleRepository>(key);
            ScheduleController controller = new ScheduleController();

            controller.CreateSchedule(TestFactories.GetDefaultLookup(), "Test Schedule", "This is a test", "test user");
            var schedules = repository.GetAllSchedules();

            Assert.Greater(schedules.Count(), 3);

            Schedule schedule = repository.GetAllSchedules().Last();

            Assert.Greater(schedule.ScheduleID, 0);
            Assert.AreEqual(schedule.CreatedBy, "test user");
            Assert.AreEqual(schedule.ModifiedBy, "test user");
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ihScheduleID.Value == Constants.NULL_STRING)
                {
                    scheduleController.CreateSchedule(new Lookup(int.Parse(ddlCampus.SelectedValue)),
                                                      tbName.Text.Trim(), tbDescription.Text.Trim(), CurrentUser.Identity.Name);
                }
                else
                {
                    scheduleController.UpdateSchedule(int.Parse(ihScheduleID.Value), new Lookup(int.Parse(ddlCampus.SelectedValue)),
                                                      tbName.Text.Trim(), tbDescription.Text.Trim(), CurrentUser.Identity.Name);
                }

                ClearFields();
                ClearErrors();
                ShowView();
            }
            catch (ValidationException ex)
            {
                ShowErrors(ex.Errors);
            }
        }