Skip to content
Snippets Groups Projects

New: Modify SPGroups on User changes

Merged Marius Politze requested to merge Product/328-SPGroupHandling into Sprint/201920
2 files
+ 42
28
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -11,24 +11,22 @@ using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using Coscine.Configuration;
namespace Coscine.Api.Project.Controllers
{
public class ProjectController : Controller
{
private readonly Authenticator _authenticator;
private readonly List<IProjectAction> _projectActions;
private readonly ProjectModel _projectModel;
private readonly IConfiguration _configuration;
private readonly Emitter _emitter;
public ProjectController()
{
_authenticator = new Authenticator(this, Program.Configuration);
_projectActions = new List<IProjectAction>()
{
new PIDAction(),
new SharePointSiteAction()
};
_configuration = Program.Configuration;
_projectModel = new ProjectModel();
_emitter = new Emitter(this._configuration);
}
[Route("[controller]")]
@@ -164,16 +162,9 @@ namespace Coscine.Api.Project.Controllers
projectInstituteModel.Delete(projectInstitute);
}
FireEvents((projectAction, projectEventArgs) =>
_emitter.EmitProjectDelete(new ProjectEventArgs(_configuration)
{
try
{
projectAction.OnProjectDelete(project, projectEventArgs);
}
catch (Exception)
{
// Filter exception, because sometimes the PID or SharePoint site might not be generated in e.g. tests
}
Project = project
});
_projectModel.Delete(project);
@@ -195,19 +186,14 @@ namespace Coscine.Api.Project.Controllers
subProjectModel.LinkSubProject(projectObject.ParentId, project.Id);
}
FireEvents((projectAction, projectEventArgs) => projectAction.OnProjectCreate(project, projectEventArgs));
_emitter.EmitProjectCreate(new ProjectEventArgs(_configuration)
{
Project = project,
ProjectOwner = user
});
return _projectModel.CreateReturnObjectFromDatabaseObject(project);
}));
}
private void FireEvents(Action<IProjectAction, ProjectEventArgs> eventAction)
{
ProjectEventArgs projectEventArgs = new ProjectEventArgs(Program.Configuration, new object[0]);
foreach (var projectAction in _projectActions)
{
eventAction(projectAction, projectEventArgs);
}
}
}
}
Loading