This commit is contained in:
2022-03-06 22:28:45 +00:00
parent ae8a77b4f3
commit 0065e71501
5 changed files with 49 additions and 1 deletions

View File

@@ -127,17 +127,61 @@ namespace AyaNova.Api.Controllers
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>
/// Get Subscription list
/// </summary>
/// <returns>User's notification subscription list </returns>
[HttpGet("list")]
public async Task<IActionResult> GetQueue()
public async Task<IActionResult> GetList()
{
if (!serverState.IsOpen)
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();

View File

@@ -1303,6 +1303,7 @@
"WarrantyExpires": "Gültig bis",
"WebAddress": "Webadresse",
"Welcome": "Willkommen in AyaNova",
"WhoWillBeNotified":"Wer wird benachrichtigt?",
"WorkOrder": "Arbeitsauftrag",
"WorkOrderAge": "Age",
"WorkOrderCloseByDate": "Fertigstellungsdatum",

View File

@@ -1303,6 +1303,7 @@
"WarrantyExpires": "Valid until",
"WebAddress": "Web Address",
"Welcome": "Welcome to AyaNova",
"WhoWillBeNotified":"Who will be notified?",
"WorkOrder": "Work order",
"WorkOrderAge": "Age",
"WorkOrderCloseByDate": "Date to be completed",

View File

@@ -1303,6 +1303,7 @@
"WarrantyExpires": "Válido hasta",
"WebAddress": "Dirección web",
"Welcome": "Bienvenido a AyaNova",
"WhoWillBeNotified":"¿Quién será notificado?",
"WorkOrder": "Orden de trabajo",
"WorkOrderAge": "Age",
"WorkOrderCloseByDate": "Fecha para completar",

View File

@@ -1303,6 +1303,7 @@
"WarrantyExpires": "Valable jusque",
"WebAddress": "Adresse Web",
"Welcome": "Bienvenue chez AyaNova",
"WhoWillBeNotified":"Qui sera notifié ?",
"WorkOrder": "Bon de travail",
"WorkOrderAge": "Age",
"WorkOrderCloseByDate": "Date à compléter",