Exemplo n.º 1
0
        public ActionResult CreateGoal(GroupGoalFormModel goal)
        {
            GroupGoal groupgoal = Mapper.Map <GroupGoalFormModel, GroupGoal>(goal);
            var       groupUser = groupUserService.GetGroupUser(User.Identity.GetUserId(), goal.GroupId);

            groupgoal.GroupUserId = groupUser.GroupUserId;
            //groupgoal.GroupUser = groupUser;
            //if (groupgoal.AssignedTo == null)
            //{
            //    groupgoal.AssignedGroupUserId = null;
            //}
            var errors = groupGoalService.CanAddGoal(groupgoal, groupUpdateService).ToList();

            ModelState.AddModelErrors(errors);
            if (ModelState.IsValid)
            {
                //groupgoal.GroupUser.UserId = ((SocialGoalUser)(User.Identity)).UserId;
                groupGoalService.CreateGroupGoal(groupgoal);
                return(RedirectToAction("Index", new { id = goal.GroupId }));
            }
            //goal.Group = groupService.GetGroup(goal.GroupUser.GroupId);
            var metrics = metricService.GetMetrics();
            var focuss  = focusService.GetFocussOfGroup(goal.GroupId);

            goal.Metrics = metrics.ToSelectListItems(-1);
            goal.Foci    = focuss.ToSelectListItems(-1);
            return(View(goal));
        }
Exemplo n.º 2
0
        public ViewResult EditGoal(int id)
        {
            var goal = groupGoalService.GetGroupGoal(id);
            GroupGoalFormModel editGoal = Mapper.Map <GroupGoal, GroupGoalFormModel>(goal);
            var metrics = metricService.GetMetrics();
            var focuss  = focusService.GetFocussOfGroup(goal.GroupUser.GroupId);

            if (goal.Metric != null)
            {
                editGoal.Metrics = metrics.ToSelectListItems(goal.Metric.MetricId);
            }
            else
            {
                editGoal.Metrics = metrics.ToSelectListItems(-1);
            }
            if (goal.Focus != null)
            {
                editGoal.Foci = focuss.ToSelectListItems(goal.Focus.FocusId);
            }
            else
            {
                editGoal.Foci = focuss.ToSelectListItems(-1);
            }
            return(View(editGoal));
        }
Exemplo n.º 3
0
        //[ActionName("CreateGoal")]
        public ViewResult CreateGoal(int id)
        {
            var metrics   = metricService.GetMetrics();
            var focuss    = focusService.GetFocussOfGroup(id);
            var groupGoal = new GroupGoalFormModel()
            {
                GroupId = id
            };

            groupGoal.Metrics = metrics.ToSelectListItems(-1);
            groupGoal.Foci    = focuss.ToSelectListItems(-1);
            return(View(groupGoal));
        }
Exemplo n.º 4
0
        public ActionResult EditGoal(GroupGoalFormModel editGoal)
        {
            GroupGoal groupGoal = Mapper.Map <GroupGoalFormModel, GroupGoal>(editGoal);
            var       errors    = groupGoalService.CanAddGoal(groupGoal, groupUpdateService);

            ModelState.AddModelErrors(errors);
            if (ModelState.IsValid)
            {
                groupGoalService.EditGroupGoal(groupGoal);
                return(RedirectToAction("GroupGoal", new { id = editGoal.GroupGoalId }));;
            }
            else
            {
                var metrics         = metricService.GetMetrics();
                var focuss          = focusService.GetFocus();
                var groupGoalToEdit = groupGoalService.GetGroupGoal(editGoal.GroupGoalId);
                editGoal.Group = groupService.GetGroup(editGoal.GroupId);
                if (groupGoalToEdit.Metric != null)
                {
                    editGoal.Metrics = metrics.ToSelectListItems(groupGoalToEdit.Metric.MetricId);
                }
                else
                {
                    editGoal.Metrics = metrics.ToSelectListItems(-1);
                }
                if (groupGoalToEdit.Focus != null)
                {
                    editGoal.Foci = focuss.ToSelectListItems(groupGoalToEdit.Focus.FocusId);
                }
                else
                {
                    editGoal.Foci = focuss.ToSelectListItems(-1);
                }
                //editGoal.Group = groupGoalToEdit.GroupUser.Group;
                return(View(editGoal));
            }
        }