Skip to content
Snippets Groups Projects
Commit ea3d0776 authored by Sandra Westerhoff's avatar Sandra Westerhoff
Browse files

Update: Owner of a project can be contacted (coscine/issues#1202)

parent 09e990ac
No related branches found
No related tags found
1 merge request!8Update: Owner of a project can be contacted (coscine/issues#1202)
...@@ -24,6 +24,7 @@ namespace Coscine.Api.Pid.Controllers ...@@ -24,6 +24,7 @@ namespace Coscine.Api.Pid.Controllers
public class PidController : Controller public class PidController : Controller
{ {
private readonly ResourceModel _resourceModel; private readonly ResourceModel _resourceModel;
private readonly ProjectModel _projectModel;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly Emitter _emitter; private readonly Emitter _emitter;
...@@ -35,6 +36,7 @@ namespace Coscine.Api.Pid.Controllers ...@@ -35,6 +36,7 @@ namespace Coscine.Api.Pid.Controllers
_configuration = Program.Configuration; _configuration = Program.Configuration;
_emitter = new Emitter(this._configuration); _emitter = new Emitter(this._configuration);
_resourceModel = new ResourceModel(); _resourceModel = new ResourceModel();
_projectModel = new ProjectModel();
} }
/// <summary> /// <summary>
...@@ -46,6 +48,7 @@ namespace Coscine.Api.Pid.Controllers ...@@ -46,6 +48,7 @@ namespace Coscine.Api.Pid.Controllers
public IActionResult SendMailToOwner([FromBody] MessageObject messageObject) public IActionResult SendMailToOwner([FromBody] MessageObject messageObject)
{ {
var resource = _resourceModel.GetById(new Guid(messageObject.Guid)); var resource = _resourceModel.GetById(new Guid(messageObject.Guid));
var project = _projectModel.GetById(new Guid(messageObject.Guid));
var user = new User() var user = new User()
{ {
DisplayName = messageObject.Name, DisplayName = messageObject.Name,
...@@ -53,19 +56,31 @@ namespace Coscine.Api.Pid.Controllers ...@@ -53,19 +56,31 @@ namespace Coscine.Api.Pid.Controllers
}; };
var placeholder = new JObject() var placeholder = new JObject()
{ {
["resourceName"] = resource.DisplayName,
["requesterName"] = messageObject.Name, ["requesterName"] = messageObject.Name,
["requesterMail"] = messageObject.Email, ["requesterMail"] = messageObject.Email,
["requestMessage"] = messageObject.Message, ["requestMessage"] = messageObject.Message,
["pid"] = messageObject.Pid ["pid"] = messageObject.Pid
}; };
_emitter.EmitPIDOwnerContact(new PIDEventArgs(_configuration)
PIDEventArgs pidEventArgs = new PIDEventArgs(_configuration)
{ {
Requester = user, Requester = user,
Resource = resource,
SentCopy = messageObject.SendCopy, SentCopy = messageObject.SendCopy,
Placeholder = placeholder Placeholder = placeholder
}); };
if (resource != null)
{
placeholder["resourceName"] = resource.DisplayName;
pidEventArgs.Resource = resource;
}
else
{
placeholder["projectName"] = project.DisplayName;
pidEventArgs.Project = project;
}
_emitter.EmitPIDOwnerContact(pidEventArgs);
return Json(new JObject { ["status"] = "ok" }); return Json(new JObject { ["status"] = "ok" });
} }
} }
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL"> <Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath> <HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference> </Reference>
<Reference Include="Coscine.Action, Version=1.17.0.0, Culture=neutral, processorArchitecture=AMD64"> <Reference Include="Coscine.Action, Version=1.18.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.17.0\lib\net461\Coscine.Action.dll</HintPath> <HintPath>..\packages\Coscine.Action.1.18.0-topic-1202-pidap0002\lib\net461\Coscine.Action.dll</HintPath>
</Reference> </Reference>
<Reference Include="Coscine.ApiCommons, Version=1.11.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL"> <Reference Include="Coscine.ApiCommons, Version=1.11.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.11.0\lib\net461\Coscine.ApiCommons.dll</HintPath> <HintPath>..\packages\Coscine.ApiCommons.1.11.0\lib\net461\Coscine.ApiCommons.dll</HintPath>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Consul" version="0.7.2.6" targetFramework="net461" /> <package id="Consul" version="0.7.2.6" targetFramework="net461" />
<package id="Coscine.Action" version="1.17.0" targetFramework="net461" /> <package id="Coscine.Action" version="1.18.0-topic-1202-pidap0002" targetFramework="net461" />
<package id="Coscine.ApiCommons" version="1.11.0" targetFramework="net461" /> <package id="Coscine.ApiCommons" version="1.11.0" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" /> <package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Coscine.Database" version="1.27.0" targetFramework="net461" /> <package id="Coscine.Database" version="1.27.0" targetFramework="net461" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment