예제 #1
0
        public ActionResult Create(int?projectId, int?taskId)
        {
            var model = new HourFormModel();

            try
            {
                var hour = HourService.HourNew();

                if (projectId.HasValue &&
                    projectId.Value != 0)
                {
                    hour.ProjectId = projectId.Value;
                }

                if (taskId.HasValue &&
                    taskId.Value != 0)
                {
                    hour.TaskId = taskId.Value;
                }

                this.Map(hour, model, true);
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
            }

            return(this.View(model));
        }
예제 #2
0
        public ActionResult Edit(int id)
        {
            var model = new HourFormModel();
            var hour  = HourRepository.HourFetch(id);

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

            return(this.View(model));
        }
예제 #3
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));
        }
예제 #4
0
        public ActionResult Delete(int id)
        {
            var model = new HourFormModel();

            try
            {
                var hour = HourService.HourFetch(id);

                this.Map(hour, model, true);
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
            }

            return(this.View(model));
        }
예제 #5
0
        public ActionResult Create(int?projectId, int?taskId, HourFormModel model)
        {
            var hour = HourService.HourNew();

            Csla.Data.DataMapper.Map(model, hour, true);

            hour = HourService.HourSave(hour);

            if (hour.IsValid)
            {
                return(new JsonResult {
                    Data = this.Url.Action("Edit", new { id = hour.HourId, message = Resources.SaveSuccessfulMessage })
                });
            }

            this.Map(hour, model, false);

            return(this.View(model));
        }
예제 #6
0
        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));
        }
예제 #7
0
        public HourFormModel Map(Hour hour, HourFormModel model, bool ignoreBrokenRules)
        {
            Csla.Data.DataMapper.Map(hour, model, true);

            model.Tab          = "Hour";
            model.FindText     = string.Empty;
            model.FindCategory = "Hour";
            model.Users        = DataHelper.GetUserList();
            model.Projects     = DataHelper.GetProjectList();
            model.IsNew        = hour.IsNew;
            model.IsValid      = hour.IsValid;

            if (!ignoreBrokenRules)
            {
                foreach (var brokenRule in hour.BrokenRulesCollection)
                {
                    this.ModelState.AddModelError(string.Empty, brokenRule.Description);
                }
            }

            return(model);
        }
예제 #8
0
        public ActionResult Edit(int id, HourFormModel model)
        {
            var hour = HourService.HourFetch(id);

            Csla.Data.DataMapper.Map(model, hour, true);

            hour = HourService.HourSave(hour);

            if (hour.TaskId != 0)
            {
                model.Task = TaskService.TaskFetch(hour.TaskId);
            }

            if (hour.IsValid)
            {
                model.Message = Resources.SaveSuccessfulMessage;
            }

            this.Map(hour, model, true);

            return(this.View(model));
        }
예제 #9
0
        public ActionResult Edit(int id, string message)
        {
            var model = new HourFormModel();

            try
            {
                var hour = HourService.HourFetch(id);

                model.Message = message;

                if (hour.TaskId != 0)
                {
                    model.Task = TaskService.TaskFetch(hour.TaskId);
                }

                this.Map(hour, model, true);
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
            }

            return(this.View(model));
        }