This commit is contained in:
@@ -127,17 +127,61 @@ namespace AyaNova.Api.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get a list of which customers will potentially receive a notification based on tags
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customerTags"></param>
|
||||||
|
/// <param name="apiVersion">From route path</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("who")]
|
||||||
|
public async Task<IActionResult> GetWho([FromBody] List<string> customerTags, ApiVersion apiVersion)
|
||||||
|
{
|
||||||
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.CustomerNotifySubscription))
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
|
string custTagsWhere = DataList.DataListSqlFilterCriteriaBuilder.KPITagFilterToSqlCriteria("acustomer.tags", customerTags, false);
|
||||||
|
|
||||||
|
|
||||||
|
List<CustomerNotifySubscriptionWhoRecord> ret = new List<CustomerNotifySubscriptionWhoRecord>();
|
||||||
|
using (var cmd = ct.Database.GetDbConnection().CreateCommand())
|
||||||
|
{
|
||||||
|
await ct.Database.OpenConnectionAsync();
|
||||||
|
cmd.CommandText = $"select id, name, emailaddress from acustomer where active=true {custTagsWhere} order by name";
|
||||||
|
using (var dr = await cmd.ExecuteReaderAsync())
|
||||||
|
{
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
ret.Add(new CustomerNotifySubscriptionWhoRecord(dr.GetInt64(0), dr.GetString(1), dr.GetString(2) ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WHERE ARRAY['red','green'::varchar(255)] <@ tags
|
||||||
|
//array1.All(i => array2.Contains(i)) array1 <@ array2
|
||||||
|
//https://www.npgsql.org/efcore/mapping/array.html
|
||||||
|
// var ret = await ct.Customer.Where(z => z.Active == true && (customerTags.All(i => z.Tags.Contains(i)))).Select(c => new CustomerNotifySubscriptionWhoRecord(c.Id, c.Name, c.EmailAddress)).ToListAsync();
|
||||||
|
return Ok(ApiOkResponse.Response(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
private record CustomerNotifySubscriptionWhoRecord(long Id, string Name, string EmailAddress);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Subscription list
|
/// Get Subscription list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>User's notification subscription list </returns>
|
/// <returns>User's notification subscription list </returns>
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
public async Task<IActionResult> GetQueue()
|
public async Task<IActionResult> GetList()
|
||||||
{
|
{
|
||||||
if (!serverState.IsOpen)
|
if (!serverState.IsOpen)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
|
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.CustomerNotifySubscription))
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
|
||||||
var subs = await ct.CustomerNotifySubscription.AsNoTracking().ToListAsync();
|
var subs = await ct.CustomerNotifySubscription.AsNoTracking().ToListAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -1303,6 +1303,7 @@
|
|||||||
"WarrantyExpires": "Gültig bis",
|
"WarrantyExpires": "Gültig bis",
|
||||||
"WebAddress": "Webadresse",
|
"WebAddress": "Webadresse",
|
||||||
"Welcome": "Willkommen in AyaNova",
|
"Welcome": "Willkommen in AyaNova",
|
||||||
|
"WhoWillBeNotified":"Wer wird benachrichtigt?",
|
||||||
"WorkOrder": "Arbeitsauftrag",
|
"WorkOrder": "Arbeitsauftrag",
|
||||||
"WorkOrderAge": "Age",
|
"WorkOrderAge": "Age",
|
||||||
"WorkOrderCloseByDate": "Fertigstellungsdatum",
|
"WorkOrderCloseByDate": "Fertigstellungsdatum",
|
||||||
|
|||||||
@@ -1303,6 +1303,7 @@
|
|||||||
"WarrantyExpires": "Valid until",
|
"WarrantyExpires": "Valid until",
|
||||||
"WebAddress": "Web Address",
|
"WebAddress": "Web Address",
|
||||||
"Welcome": "Welcome to AyaNova",
|
"Welcome": "Welcome to AyaNova",
|
||||||
|
"WhoWillBeNotified":"Who will be notified?",
|
||||||
"WorkOrder": "Work order",
|
"WorkOrder": "Work order",
|
||||||
"WorkOrderAge": "Age",
|
"WorkOrderAge": "Age",
|
||||||
"WorkOrderCloseByDate": "Date to be completed",
|
"WorkOrderCloseByDate": "Date to be completed",
|
||||||
|
|||||||
@@ -1303,6 +1303,7 @@
|
|||||||
"WarrantyExpires": "Válido hasta",
|
"WarrantyExpires": "Válido hasta",
|
||||||
"WebAddress": "Dirección web",
|
"WebAddress": "Dirección web",
|
||||||
"Welcome": "Bienvenido a AyaNova",
|
"Welcome": "Bienvenido a AyaNova",
|
||||||
|
"WhoWillBeNotified":"¿Quién será notificado?",
|
||||||
"WorkOrder": "Orden de trabajo",
|
"WorkOrder": "Orden de trabajo",
|
||||||
"WorkOrderAge": "Age",
|
"WorkOrderAge": "Age",
|
||||||
"WorkOrderCloseByDate": "Fecha para completar",
|
"WorkOrderCloseByDate": "Fecha para completar",
|
||||||
|
|||||||
@@ -1303,6 +1303,7 @@
|
|||||||
"WarrantyExpires": "Valable jusque",
|
"WarrantyExpires": "Valable jusque",
|
||||||
"WebAddress": "Adresse Web",
|
"WebAddress": "Adresse Web",
|
||||||
"Welcome": "Bienvenue chez AyaNova",
|
"Welcome": "Bienvenue chez AyaNova",
|
||||||
|
"WhoWillBeNotified":"Qui sera notifié ?",
|
||||||
"WorkOrder": "Bon de travail",
|
"WorkOrder": "Bon de travail",
|
||||||
"WorkOrderAge": "Age",
|
"WorkOrderAge": "Age",
|
||||||
"WorkOrderCloseByDate": "Date à compléter",
|
"WorkOrderCloseByDate": "Date à compléter",
|
||||||
|
|||||||
Reference in New Issue
Block a user