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
......@@ -24,6 +24,7 @@ namespace Coscine.Api.Pid.Controllers
public class PidController : Controller
{
private readonly ResourceModel _resourceModel;
private readonly ProjectModel _projectModel;
private readonly IConfiguration _configuration;
private readonly Emitter _emitter;
......@@ -35,6 +36,7 @@ namespace Coscine.Api.Pid.Controllers
_configuration = Program.Configuration;
_emitter = new Emitter(this._configuration);
_resourceModel = new ResourceModel();
_projectModel = new ProjectModel();
}
/// <summary>
......@@ -46,6 +48,7 @@ namespace Coscine.Api.Pid.Controllers
public IActionResult SendMailToOwner([FromBody] MessageObject messageObject)
{
var resource = _resourceModel.GetById(new Guid(messageObject.Guid));
var project = _projectModel.GetById(new Guid(messageObject.Guid));
var user = new User()
{
DisplayName = messageObject.Name,
......@@ -53,19 +56,31 @@ namespace Coscine.Api.Pid.Controllers
};
var placeholder = new JObject()
{
["resourceName"] = resource.DisplayName,
["requesterName"] = messageObject.Name,
["requesterMail"] = messageObject.Email,
["requestMessage"] = messageObject.Message,
["pid"] = messageObject.Pid
};
_emitter.EmitPIDOwnerContact(new PIDEventArgs(_configuration)
PIDEventArgs pidEventArgs = new PIDEventArgs(_configuration)
{
Requester = user,
Resource = resource,
SentCopy = messageObject.SendCopy,
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" });
}
}
......
......@@ -51,8 +51,8 @@
<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>
</Reference>
<Reference Include="Coscine.Action, Version=1.17.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.17.0\lib\net461\Coscine.Action.dll</HintPath>
<Reference Include="Coscine.Action, Version=1.18.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.18.0-topic-1202-pidap0002\lib\net461\Coscine.Action.dll</HintPath>
</Reference>
<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>
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<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.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Coscine.Database" version="1.27.0" targetFramework="net461" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment