Example #1
0
        public ActionResult EditStory(StoryViewModel model, int[] selectedItems)
        {
            StoryDetail detail = model.ConvertToStoryDetail();

            int[] items = selectedItems;
            if (selectedItems == null)
            {
                items = new int[0];
            }
            if (model.Title == null)//Invalid Model State, dirty approach
            {
                model.AllGroups = new GroupViewModel[0];
                TaskResult <IEnumerable <GroupDetail> > groupDetailRequest = groupDataService.GetGroups(new DataRequest {
                    StartPosition = 0, Count = 100
                });
                if (groupDetailRequest.Data != null)
                {
                    model.AllGroups = groupDetailRequest.Data.Select(a => a.ConvertToGroupViewModel());
                }
                return(View(model));
            }
            detail.GroupDetails = items.Select(a => new GroupDetail {
                Id = a
            });
            storyDataService.PostStory(detail);
            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult Create(StoryViewModel model, int[] selectedItems)
        {
            if (model.Title == null)//Invalid Model State, dirty approach
            {
                return(View(model));
            }
            int[] items = selectedItems;
            if (selectedItems == null)
            {
                items = new int[0];
            }
            StoryDetail detail = model.ConvertToStoryDetail();

            detail.UserId       = UserDetails.Id;
            detail.GroupDetails = items.Select(a => new GroupDetail {
                Id = a
            });
            storyDataService.PostStory(detail);
            return(RedirectToAction("Index"));
        }