Esempio n. 1
0
        public static Hour HourAdd()
        {
            var hour = HourTestHelper.HourNew();

            hour = HourRepository.HourSave(hour);

            return(hour);
        }
Esempio n. 2
0
        public void Hour_Fetch()
        {
            var hour = HourTestHelper.HourNew();

            hour = HourRepository.HourSave(hour);

            hour = HourRepository.HourFetch(hour.HourId);

            Assert.IsTrue(hour != null, "Row returned should not equal null");
        }
Esempio n. 3
0
        public void Hour_Add()
        {
            var hour = HourTestHelper.HourNew();

            Assert.IsTrue(hour.IsValid, "IsValid should be true");

            hour = HourRepository.HourSave(hour);

            Assert.IsTrue(hour.HourId != 0, "HourId should be a non-zero value");

            HourRepository.HourFetch(hour.HourId);
        }
Esempio n. 4
0
        public void Hour_Edit()
        {
            var hour = HourTestHelper.HourNew();

            var notes = hour.Notes;

            Assert.IsTrue(hour.IsValid, "IsValid should be true");

            hour = HourRepository.HourSave(hour);

            hour = HourRepository.HourFetch(hour.HourId);

            hour.Notes = DataHelper.RandomString(20);

            hour = HourRepository.HourSave(hour);

            hour = HourRepository.HourFetch(hour.HourId);

            Assert.IsTrue(hour.Notes != notes, "Name should have different value");
        }
Esempio n. 5
0
        public void Hour_Delete()
        {
            var hour = HourTestHelper.HourNew();

            Assert.IsTrue(hour.IsValid, "IsValid should be true");

            hour = HourRepository.HourSave(hour);

            hour = HourRepository.HourFetch(hour.HourId);

            HourRepository.HourDelete(hour.HourId);

            try
            {
                HourRepository.HourFetch(hour.HourId);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.GetBaseException() is InvalidOperationException);
            }
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            var model = new HourFormModel();
            var hour  = HourRepository.HourFetch(id);

            this.Map(collection, hour);

            hour = HourRepository.HourSave(hour);

            if (hour.IsValid)
            {
                return(this.RedirectToAction("Details", "Story", new { id = hour.StoryId }));
            }

            model.Title = "Hour Edit";
            model.Hour  = hour;
            model.Story = StoryRepository.StoryFetch(hour.StoryId);

            ModelHelper.MapBrokenRules(this.ModelState, hour);

            return(this.View(model));
        }