コード例 #1
0
        public ActionResult Create(int storyId)
        {
            var model = new HourFormModel();
            var hour  = HourRepository.HourNew();

            hour.StoryId = storyId;

            model.Title = "Hour Create";
            model.Hour  = hour;
            model.Story = StoryRepository.StoryFetch(storyId);

            return(this.View(model));
        }
コード例 #2
0
        public static Hour HourNew()
        {
            var story = StoryTestHelper.StoryAdd();
            var user  = UserTestHelper.UserAdd();

            var hour = HourRepository.HourNew();

            hour.StoryId = story.StoryId;
            hour.UserId  = user.UserId;
            hour.Notes   = DataHelper.RandomString(50);

            return(hour);
        }
コード例 #3
0
        public void Hour_Create()
        {
            var hour = HourRepository.HourNew();

            Assert.IsTrue(hour.IsNew, "IsNew should be true");
            Assert.IsTrue(hour.IsDirty, "IsDirty should be true");
            Assert.IsFalse(hour.IsValid, "IsValid should be false");
            Assert.IsTrue(hour.IsSelfDirty, "IsSelfDirty should be true");
            Assert.IsFalse(hour.IsSelfValid, "IsSelfValid should be false");

            // Assert.IsTrue(ValidationHelper.ContainsRule(hour, DbType.String, "Name"),
            //    "Name should be required");
        }
コード例 #4
0
        public ActionResult Create(int storyId, FormCollection collection)
        {
            var model = new HourFormModel();
            var hour  = HourRepository.HourNew();

            hour.StoryId = storyId;

            this.Map(collection, hour);

            hour = HourRepository.HourSave(hour);

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

            model.Title = "Hour Create";
            model.Hour  = hour;
            model.Story = StoryRepository.StoryFetch(storyId);

            ModelHelper.MapBrokenRules(this.ModelState, hour);

            return(this.View(model));
        }