예제 #1
0
        public ActionResult Edit(GoalFormModel editGoal)
        {
            Goal goalToEdit = Mapper.Map <GoalFormModel, Goal>(editGoal);
            var  errors     = goalService.CanAddGoal(goalToEdit, updateService);

            ModelState.AddModelErrors(errors);
            if (ModelState.IsValid)
            {
                goalService.EditGoal(goalToEdit);
                return(RedirectToAction("Index", new { id = editGoal.GoalId }));
            }
            else
            {
                var metrics    = metricService.GetMetrics();
                var goalstatus = goalStatusService.GetGoalStatus();
                var goal       = goalService.GetGoal(editGoal.GoalId);
                if (goal.Metric != null)
                {
                    editGoal.Metrics = metrics.ToSelectListItems(goal.Metric.MetricId);
                }
                else
                {
                    editGoal.Metrics = metrics.ToSelectListItems(-1);
                }

                return(View(editGoal));
            }
        }
예제 #2
0
        public PartialViewResult Create()
        {
            var createGoal = new GoalFormModel();
            var metrics    = metricService.GetMetrics();
            var goalstatus = goalStatusService.GetGoalStatus();

            createGoal.Metrics = metrics.ToSelectListItems(-1);
            return(PartialView(createGoal));
        }
예제 #3
0
        public ActionResult Create(GoalFormModel createGoal)
        {
            Goal goal   = Mapper.Map <GoalFormModel, Goal>(createGoal);
            var  errors = goalService.CanAddGoal(goal, updateService).ToList();

            ModelState.AddModelErrors(errors);
            if (ModelState.IsValid)
            {
                goalService.CreateGoal(goal);
                return(RedirectToAction("Index", new { id = goal.GoalId }));
            }
            var metrics     = metricService.GetMetrics();
            var goalstatuss = goalStatusService.GetGoalStatus();

            createGoal.Metrics = metrics.ToSelectListItems(-1);
            return(View("Create", createGoal));
        }
예제 #4
0
        public ActionResult Edit(int id)
        {
            var           goal     = goalService.GetGoal(id);
            GoalFormModel editGoal = Mapper.Map <Goal, GoalFormModel>(goal);

            if (goal == null)
            {
                return(HttpNotFound());
            }
            var metrics = metricService.GetMetrics();

            if (goal.Metric != null)
            {
                editGoal.Metrics = metrics.ToSelectListItems(goal.Metric.MetricId);
            }
            else
            {
                editGoal.Metrics = metrics.ToSelectListItems(-1);
            }
            return(View(editGoal));
        }