This commit is contained in:
@@ -59,29 +59,7 @@ namespace AyaNova.Api.Controllers
|
||||
return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Duplicate CustomerServiceRequest
|
||||
// /// (Wiki and Attachments are not duplicated)
|
||||
// /// </summary>
|
||||
// /// <param name="id">Source object id</param>
|
||||
// /// <param name="apiVersion">From route path</param>
|
||||
// /// <returns>CustomerServiceRequest</returns>
|
||||
// [HttpPost("duplicate/{id}")]
|
||||
// public async Task<IActionResult> DuplicateCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext);
|
||||
// if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
// CustomerServiceRequest o = await biz.DuplicateAsync(id);
|
||||
// if (o == null)
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// else
|
||||
// return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get CustomerServiceRequest
|
||||
@@ -150,52 +128,53 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reject CustomerServiceRequest
|
||||
/// </summary>
|
||||
/// <param name="id">Source object id</param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns>CustomerServiceRequest</returns>
|
||||
[HttpPost("reject/{id}")]
|
||||
public async Task<IActionResult> RejectCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
CustomerServiceRequest o = await biz.RejectAsync(id);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Reject CustomerServiceRequest
|
||||
// /// </summary>
|
||||
// /// <param name="id">Source object id</param>
|
||||
// /// <param name="apiVersion">From route path</param>
|
||||
// /// <returns>CustomerServiceRequest</returns>
|
||||
// [HttpPost("reject/{id}")]
|
||||
// public async Task<IActionResult> RejectCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext);
|
||||
// if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
// CustomerServiceRequest o = await biz.RejectAsync(id);
|
||||
// if (o == null)
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// else
|
||||
// return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Accept CustomerServiceRequest
|
||||
/// </summary>
|
||||
/// <param name="id">Source object id</param>
|
||||
/// <param name="workorderid">Existing WorkOrder to accept to, 0 creates new workorder</param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns>CustomerServiceRequest with WorkOrderItemId set</returns>
|
||||
[HttpPost("accept/{id}/{workorderid}")]
|
||||
public async Task<IActionResult> AcceptCustomerServiceRequest([FromRoute] long id, [FromRoute] long workorderid, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
CustomerServiceRequest o = await biz.AcceptAsync(id, workorderid);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Accept CustomerServiceRequest to new WorkOrder
|
||||
// /// </summary>
|
||||
// /// <param name="id">Source CSR id</param>
|
||||
// /// <param name="apiVersion">From route path</param>
|
||||
// /// <returns>CustomerServiceRequest with WorkOrderItemId set</returns>
|
||||
// [HttpPost("accept/{id}/{workorderid}")]
|
||||
// public async Task<IActionResult> AcceptCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext);
|
||||
// if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
// CustomerServiceRequest o = await biz.AcceptAsync(id);
|
||||
// if (o == null)
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// else
|
||||
// return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -60,39 +60,6 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //DUPLICATE
|
||||
// //
|
||||
// internal async Task<CustomerServiceRequest> DuplicateAsync(long id)
|
||||
// {
|
||||
// CustomerServiceRequest dbObject = await GetAsync(id, false);
|
||||
// if (dbObject == null)
|
||||
// {
|
||||
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
// return null;
|
||||
// }
|
||||
// CustomerServiceRequest newObject = new CustomerServiceRequest();
|
||||
// CopyObject.Copy(dbObject, newObject, "Wiki");
|
||||
// string newUniqueName = string.Empty;
|
||||
// bool NotUnique = true;
|
||||
// long l = 1;
|
||||
// do
|
||||
// {
|
||||
// newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObject.Name, l++, 255);
|
||||
// NotUnique = await ct.CustomerServiceRequest.AnyAsync(m => m.Name == newUniqueName);
|
||||
// } while (NotUnique);
|
||||
// newObject.Name = newUniqueName;
|
||||
// newObject.Id = 0;
|
||||
// newObject.Concurrency = 0;
|
||||
// await ct.CustomerServiceRequest.AddAsync(newObject);
|
||||
// await ct.SaveChangesAsync();
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
// await SearchIndexAsync(newObject, true);
|
||||
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
// await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
// return newObject;
|
||||
// }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GET
|
||||
//
|
||||
@@ -175,43 +142,43 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//ACCEPT
|
||||
//
|
||||
internal async Task<CustomerServiceRequest> AcceptAsync(long csrId, long workorderId) //MIGRATE_OUTSTANDING waiting for workorder to be completed or at least have a customerid which it currently doesn't
|
||||
{
|
||||
var dbObject = await GetAsync(csrId, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
return null;
|
||||
}
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //ACCEPT
|
||||
// //
|
||||
// internal async Task<CustomerServiceRequest> AcceptAsync(long csrId, long workorderId) //MIGRATE_OUTSTANDING waiting for workorder to be completed or at least have a customerid which it currently doesn't
|
||||
// {
|
||||
// var dbObject = await GetAsync(csrId, false);
|
||||
// if (dbObject == null)
|
||||
// {
|
||||
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
throw new System.NotImplementedException("//MIGRATE_OUTSTANDING CustomerServiceRequestBiz::AcceptAsync - awaiting workorder completion ");
|
||||
// WorkOrder w=null;
|
||||
//if (workorderId==0){WorkOrderBiz.GenerateWorkOrder()} //this is how it would work in theory
|
||||
// throw new System.NotImplementedException("//MIGRATE_OUTSTANDING CustomerServiceRequestBiz::AcceptAsync - awaiting workorder completion ");
|
||||
// // WorkOrder w=null;
|
||||
// //if (workorderId==0){WorkOrderBiz.GenerateWorkOrder()} //this is how it would work in theory
|
||||
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//REJECT
|
||||
//
|
||||
internal async Task<CustomerServiceRequest> RejectAsync(long csrId)
|
||||
{
|
||||
var dbObject = await GetAsync(csrId, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
return null;
|
||||
}
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //REJECT
|
||||
// //
|
||||
// internal async Task<CustomerServiceRequest> RejectAsync(long csrId)
|
||||
// {
|
||||
// var dbObject = await GetAsync(csrId, false);
|
||||
// if (dbObject == null)
|
||||
// {
|
||||
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
//Nothing to validate as it just came from the db and rejecting doesn't require validation
|
||||
dbObject.Status = CustomerServiceRequestStatus.Declined;
|
||||
await PutAsync(dbObject);
|
||||
return dbObject;
|
||||
}
|
||||
// //Nothing to validate as it just came from the db and rejecting doesn't require validation
|
||||
// dbObject.Status = CustomerServiceRequestStatus.Declined;
|
||||
// await PutAsync(dbObject);
|
||||
// return dbObject;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -495,7 +462,7 @@ namespace AyaNova.Biz
|
||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||
{
|
||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<CustomerServiceRequestBiz>();
|
||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
@@ -507,8 +474,16 @@ namespace AyaNova.Biz
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
var o = (CustomerServiceRequest)proposedObj;
|
||||
bool WasAccepted = false;
|
||||
bool WasDeclined = false;
|
||||
if (!isNew)
|
||||
{
|
||||
WasAccepted = ((CustomerServiceRequest)currentObj).Status == CustomerServiceRequestStatus.Accepted;
|
||||
WasDeclined = ((CustomerServiceRequest)currentObj).Status == CustomerServiceRequestStatus.Declined;
|
||||
}
|
||||
|
||||
//CSR ACCEPTED
|
||||
if (!WasAccepted && o.Status == CustomerServiceRequestStatus.Accepted)//TAGS NOT RELEVANT
|
||||
{
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.CSRAccepted).ToListAsync();
|
||||
string SourceName = string.Empty;
|
||||
@@ -535,6 +510,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//CSR REJECTED
|
||||
if (!WasDeclined && o.Status == CustomerServiceRequestStatus.Declined)//TAGS NOT RELEVANT
|
||||
{
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.CSRRejected).ToListAsync();
|
||||
string SourceName = string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user