This commit is contained in:
@@ -150,6 +150,52 @@ 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>
|
||||
/// Accept CustomerServiceRequest
|
||||
/// </summary>
|
||||
/// <param name="id">Source object id</param>
|
||||
/// <param name="workorderid">Existing WorkOrder to accept to, if left empty 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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -184,6 +184,89 @@ 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
|
||||
{
|
||||
CustomerServiceRequest dbObject = await ct.CustomerServiceRequest.SingleOrDefaultAsync(m => m.Id == csrId);
|
||||
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==null){
|
||||
// w=WorkOrderBiz.;
|
||||
// }
|
||||
|
||||
// CustomerServiceRequest SnapshotOfOriginalDBObj = new CustomerServiceRequest();
|
||||
// CopyObject.Copy(dbObject, SnapshotOfOriginalDBObj);
|
||||
// CopyObject.Copy(putObject, dbObject, "Id");
|
||||
// dbObject.Tags = TagBiz.NormalizeTags(dbObject.Tags);
|
||||
// dbObject.CustomFields = JsonUtil.CompactJson(dbObject.CustomFields);
|
||||
// ct.Entry(dbObject).OriginalValues["Concurrency"] = putObject.Concurrency;
|
||||
// await ValidateAsync(dbObject, SnapshotOfOriginalDBObj);
|
||||
// if (HasErrors) return null;
|
||||
// try
|
||||
// {
|
||||
// await ct.SaveChangesAsync();
|
||||
// }
|
||||
// catch (DbUpdateConcurrencyException)
|
||||
// {
|
||||
// if (!await ExistsAsync(putObject.Id))
|
||||
// AddError(ApiErrorCode.NOT_FOUND);
|
||||
// else
|
||||
// AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
// return null;
|
||||
// }
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
// await SearchIndexAsync(dbObject, false);
|
||||
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||
// await HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj);
|
||||
//return dbObject;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//REJECT
|
||||
//
|
||||
internal async Task<CustomerServiceRequest> RejectAsync(long csrId)
|
||||
{
|
||||
CustomerServiceRequest dbObject = await ct.CustomerServiceRequest.SingleOrDefaultAsync(m => m.Id == csrId);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
return null;
|
||||
}
|
||||
CustomerServiceRequest SnapshotOfOriginalDBObj = new CustomerServiceRequest();
|
||||
CopyObject.Copy(dbObject, SnapshotOfOriginalDBObj);
|
||||
dbObject.Status = CustomerServiceRequestStatus.Declined;
|
||||
await ValidateAsync(dbObject, SnapshotOfOriginalDBObj);
|
||||
if (HasErrors) return null;
|
||||
try
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!await ExistsAsync(dbObject.Id))
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
else
|
||||
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
return null;
|
||||
}
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
await SearchIndexAsync(dbObject, false);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj);
|
||||
return dbObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//SEARCH
|
||||
//
|
||||
|
||||
@@ -247,6 +247,33 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //GENERATE
|
||||
// //
|
||||
// internal async Task<WorkOrder> GenerateWorkOrderAsync(long customerId)//MIGRATE_OUTSTANDING will need more overloads as required and fleshing out later
|
||||
// {
|
||||
// WorkOrder newObject = new WorkOrder();
|
||||
// newObject.
|
||||
// await WorkOrderValidateAsync(newObject, null);
|
||||
// if (HasErrors)
|
||||
// return null;
|
||||
// else
|
||||
// {
|
||||
// newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
|
||||
// newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
|
||||
// await ct.WorkOrder.AddAsync(newObject);
|
||||
// await ct.SaveChangesAsync();
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
// await WorkOrderSearchIndexAsync(newObject, true);
|
||||
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
// await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
// return newObject;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//RESTART SERIAL
|
||||
//
|
||||
|
||||
@@ -58,6 +58,9 @@ todo: Consider adding latitude / longitude to wo, quote, pm objects
|
||||
public string CustomFields { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
// [Required]
|
||||
// public long CustomerId {get;set;}
|
||||
|
||||
//dependents
|
||||
public List<WorkOrderItem> Items { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user