case 4377

This commit is contained in:
2023-05-12 23:07:47 +00:00
parent d76cffe5c1
commit a42f1a92f2
6 changed files with 52 additions and 13 deletions

View File

@@ -198,6 +198,27 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Get list of Customer Contacts for workorder
/// </summary>
/// <param name="id">Customer Id</param>
/// <returns>Name list</returns>
[HttpGet("contact-name-list/{id}")]
public async Task<IActionResult> GetContactNameList([FromRoute] long id)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
CustomerBiz biz = CustomerBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var o = await biz.GetContactNameListAsync(id);
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
return Ok(ApiOkResponse.Response(o));
}
// /// <summary>
// /// Get service (physical) address for this customer
// /// </summary>

View File

@@ -202,6 +202,14 @@ namespace AyaNova.Biz
return await ct.Customer.AsNoTracking().OrderBy(x => x.Name).Select(x => new NameIdActiveItem { Name = x.Name, Id = x.Id, Active = x.Active }).ToListAsync();
}
////////////////////////////////////////////////////////////////////////////////////////////////
//GET LIST OF CONTACTS FOR THIS CUSTOMER FOR SELECTION ON WORKORDERS
//
internal async Task<List<string>> GetContactNameListAsync(long customerId)
{
return await ct.User.AsNoTracking().Where(z => z.Active && z.UserType == UserType.Customer && z.CustomerId == customerId).OrderBy(x => x.Name).Select(x=> x.Name).ToListAsync();
}
////////////////////////////////////////////////////////////////////////////////////////////////
//SEARCH
//

View File

@@ -98,11 +98,12 @@ function ayRegisterHelpers() {
Handlebars.registerHelper("ayT", function (translationKey) {
if (ayTranslationKeyCache[translationKey] == undefined) {
throw `ayT reporting helper error: the key "${translationKey}" is not present in the translation cache, did you forget to include it in your call to "await ayGetTranslations(['ExampleTranslationKey1','ExampleTranslationKey2','etc']);" in ayPrepareData()\nTranslationKeyCache contains: ${JSON.stringify(
ayTranslationKeyCache,
null,
3
)}?`;
return `**Error: "${translationKey}" translation key not cached or unknown**`;
// throw `ayT reporting helper error: the key "${translationKey}" is not present in the translation cache, did you forget to include it in your call to "await ayGetTranslations(['ExampleTranslationKey1','ExampleTranslationKey2','etc']);" in ayPrepareData()\nTranslationKeyCache contains: ${JSON.stringify(
// ayTranslationKeyCache,
// null,
// 3
// )}?`;
// return translationKey;
}
return ayTranslationKeyCache[translationKey];