Exemplo n.º 1
0
        public async Task <ActionResult> ByGroup(int projectId, int characterGroupId, string export)
        {
            var characterGroup = await ProjectRepository.GetGroupAsync(projectId, characterGroupId);

            var groupIds = await GetChildrenGroupIds(projectId, characterGroupId);

            var characters =
                (await ProjectRepository.GetCharacterByGroups(projectId, groupIds)).Where(ch => ch.IsActive).ToList();

            if (characterGroup == null)
            {
                return(HttpNotFound());
            }

            var plots = await PlotRepository.GetPlotsWithTargets(projectId);

            var list = new CharacterListByGroupViewModel(CurrentUserId,
                                                         characters, characterGroup);

            var exportType = GetExportTypeByName(export);

            if (exportType == null)
            {
                return(View("ByGroup", list));
            }

            return(await ExportWithCustomFronend(list.Items, list.Title, exportType.Value,
                                                 new CharacterListItemViewModelExporter(list.Fields, UriService), list.ProjectName));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> ByGroup(int projectId, int characterGroupId, string export)
        {
            var characterGroup = await ProjectRepository.GetGroupAsync(projectId, characterGroupId);

            var groupIds = await GetChildrenGroupIds(projectId, characterGroupId);

            var characters =
                (await ProjectRepository.GetCharacterByGroups(projectId, groupIds)).Where(ch => ch.IsActive).ToList();

            if (characterGroup == null)
            {
                return(NotFound());
            }

            var plots = await PlotRepository.GetPlotsWithTargets(projectId);

            var list = new CharacterListByGroupViewModel(CurrentUserId,
                                                         characters, characterGroup);

            var exportType = ExportTypeNameParserHelper.ToExportType(export);

            if (exportType == null)
            {
                return(View("ByGroup", list));
            }

            return(await Export(list, exportType));
        }
        private async Task <ActionResult> MasterCharacterList(int projectId, Func <Character, bool> predicate, string export, string title, Func <CharacterListItemViewModel, bool> viewModelPredicate)
        {
            var characters = (await ProjectRepository.GetCharacters(projectId)).Where(predicate).ToList();

            var error = await AsMaster(characters, projectId);

            if (error != null)
            {
                return(error);
            }

            var plots = await PlotRepository.GetPlotsWithTargets(projectId);

            var project = await GetProjectFromList(projectId, characters);

            var list = new CharacterListViewModel(CurrentUserId, title, characters, plots, project, viewModelPredicate);

            var exportType = GetExportTypeByName(export);

            if (exportType == null)
            {
                return(View("Index", list));
            }

            return(await ExportWithCustomFronend(list.Items, list.Title, exportType.Value, new CharacterListItemViewModelExporter(list.Fields, UriService), list.ProjectName));
        }