コード例 #1
0
        public PartialViewResult DisplayUpdates(int id)
        {
            var Updates = Mapper.Map <IEnumerable <GroupUpdate>, IEnumerable <GroupUpdateViewModel> >(groupUpdateService.GetUpdatesByGoal(id));

            foreach (var item in Updates)
            {
                item.IsSupported = groupUpdateSupportService.IsUpdateSupported(item.GroupUpdateId, User.Identity.GetUserId(), groupUserService);
                item.UserId      = groupUpdateUserService.GetGroupUpdateUser(item.GroupUpdateId).Id;
            }
            GroupUpdateListViewModel updates = new GroupUpdateListViewModel()
            {
                GroupUpdates = Updates,
                Metric       = groupGoalService.GetGroupGoal(id).Metric,
                Target       = groupGoalService.GetGroupGoal(id).Target
            };

            return(PartialView("_UpdateView", updates));
        }
コード例 #2
0
        public ActionResult EditUpdate(GroupUpdateFormModel newupdate)
        {
            GroupUpdate update = Mapper.Map <GroupUpdateFormModel, GroupUpdate>(newupdate);

            if (ModelState.IsValid)
            {
                groupUpdateService.EditUpdate(update);
                var Updates = Mapper.Map <IEnumerable <GroupUpdate>, IEnumerable <GroupUpdateViewModel> >(groupUpdateService.GetUpdatesByGoal(newupdate.GroupGoalId));
                foreach (var item in Updates)
                {
                    item.IsSupported = groupUpdateSupportService.IsUpdateSupported(item.GroupUpdateId, User.Identity.GetUserId(), groupUserService);
                    item.UserId      = groupUpdateUserService.GetGroupUpdateUser(item.GroupUpdateId).Id;
                }
                GroupUpdateListViewModel updates = new GroupUpdateListViewModel()
                {
                    GroupUpdates = Updates,
                    Metric       = groupGoalService.GetGroupGoal(newupdate.GroupGoalId).Metric,
                    Target       = groupGoalService.GetGroupGoal(newupdate.GroupGoalId).Target
                };
                return(PartialView("_UpdateView", updates));
            }
            return(null);
        }