private async Task <ActionResult> CreateElementImpl(int projectId, int plotFolderId, string content, string todoField, ICollection <string> targets, PlotElementTypeView elementType) { var targetGroups = targets.OrEmptyList().GetUnprefixedGroups(); var targetChars = targets.OrEmptyList().GetUnprefixedChars(); await _plotService.CreatePlotElement(projectId, plotFolderId, content, todoField, targetGroups, targetChars, (PlotElementType)elementType); return(ReturnToPlot(projectId, plotFolderId)); }
public async Task <ActionResult> CreateElement(int projectId, int plotFolderId, string content, string todoField, [CanBeNull] ICollection <string> targets, PlotElementTypeView elementType) { var folder = await _plotRepository.GetPlotFolderAsync(projectId, plotFolderId); var error = AsMaster(folder, acl => acl.CanManagePlots); if (error != null) { return(error); } try { var targetGroups = targets.OrEmptyList().GetUnprefixedGroups(); var targetChars = targets.OrEmptyList().GetUnprefixedChars(); await _plotService.AddPlotElement(projectId, plotFolderId, CurrentUserId, content, todoField, targetGroups, targetChars, (PlotElementType)elementType); return(ReturnToPlot(plotFolderId, projectId)); } catch (Exception) { return(View(new AddPlotElementViewModel() { ProjectId = projectId, PlotFolderId = plotFolderId, PlotFolderName = folder.MasterTitle, Content = content, TodoField = todoField, })); } }
public async Task <ActionResult> CreateElement(int projectId, int plotFolderId, string content, string todoField, [CanBeNull] ICollection <string> targets, PlotElementTypeView elementType) { try { return(await CreateElementImpl(projectId, plotFolderId, content, todoField, targets, elementType)); } catch (Exception exception) { ModelState.AddException(exception); var folder = await _plotRepository.GetPlotFolderAsync(projectId, plotFolderId); if (folder == null) { return(NotFound()); } return(View(new AddPlotElementViewModel() { ProjectId = projectId, PlotFolderId = plotFolderId, PlotFolderName = folder.MasterTitle, Content = content, TodoField = todoField, })); } }
public Task <ActionResult> CreateHandout(int projectId, int plotFolderId, string content, string todoField, [CanBeNull] ICollection <string> targets, PlotElementTypeView elementType) { return(CreateElement(projectId, plotFolderId, content, todoField, targets, elementType)); }