This commit is contained in:
@@ -117,7 +117,7 @@ namespace AyaNova.Api.Controllers
|
||||
ContractBiz biz = ContractBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
CustomerBiz biz = CustomerBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace AyaNova.Api.Controllers
|
||||
CustomerNoteBiz biz = CustomerNoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.Customer))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace AyaNova.Api.Controllers
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace AyaNova.Api.Controllers
|
||||
GlobalOpsBackupSettingsBiz biz = GlobalOpsBackupSettingsBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace AyaNova.Api.Controllers
|
||||
GlobalOpsNotificationSettingsBiz biz = GlobalOpsNotificationSettingsBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace AyaNova.Api.Controllers
|
||||
HeadOfficeBiz biz = HeadOfficeBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace AyaNova.Api.Controllers
|
||||
LoanUnitBiz biz = LoanUnitBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace AyaNova.Api.Controllers
|
||||
// MemoBiz biz = MemoBiz.GetBiz(ct, HttpContext);
|
||||
// if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
// var o = await biz.PutAsync(updatedObject);
|
||||
// if (o == null)
|
||||
// {
|
||||
// if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
NotifySubscriptionBiz biz = NotifySubscriptionBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace AyaNova.Api.Controllers
|
||||
PartAssemblyBiz biz = PartAssemblyBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace AyaNova.Api.Controllers
|
||||
PartBiz biz = PartBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
PartWarehouseBiz biz = PartWarehouseBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
ProjectBiz biz = ProjectBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
PurchaseOrderBiz biz = PurchaseOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.QuotePutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.QuotePutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -344,7 +344,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItem) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.ItemPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.ItemPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -451,7 +451,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemExpense) || biz.UserIsSubContractorFull || biz.UserIsSubContractorRestricted)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.ExpensePutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.ExpensePutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -559,7 +559,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemLabor))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.LaborPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.LaborPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -667,7 +667,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemLoan) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.LoanPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.LoanPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -776,7 +776,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemOutsideService) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.OutsideServicePutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.OutsideServicePutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -883,7 +883,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemPart) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PartPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PartPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -990,7 +990,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemScheduledUser) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.ScheduledUserPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.ScheduledUserPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -1096,7 +1096,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemTask))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.TaskPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.TaskPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -1202,7 +1202,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemTravel))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.TravelPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.TravelPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -1308,7 +1308,7 @@ namespace AyaNova.Api.Controllers
|
||||
QuoteBiz biz = QuoteBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.QuoteItemUnit) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.UnitPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.UnitPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
162
server/AyaNova/Controllers/QuoteStatusController.cs
Normal file
162
server/AyaNova/Controllers/QuoteStatusController.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using EnumsNET;
|
||||
|
||||
namespace AyaNova.Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("8.0")]
|
||||
[Route("api/v{version:apiVersion}/quote-status")]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
public class QuoteStatusController : ControllerBase
|
||||
{
|
||||
private readonly AyContext ct;
|
||||
private readonly ILogger<QuoteStatusController> log;
|
||||
private readonly ApiServerState serverState;
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
/// <param name="dbcontext"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="apiServerState"></param>
|
||||
public QuoteStatusController(AyContext dbcontext, ILogger<QuoteStatusController> logger, ApiServerState apiServerState)
|
||||
{
|
||||
ct = dbcontext;
|
||||
log = logger;
|
||||
serverState = apiServerState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create QuoteStatus
|
||||
/// </summary>
|
||||
/// <param name="newObject"></param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostQuoteStatus([FromBody] QuoteStatus newObject, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
QuoteStatusBiz biz = QuoteStatusBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
QuoteStatus o = await biz.CreateAsync(newObject);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction(nameof(QuoteStatusController.GetQuoteStatus), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get QuoteStatus
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>QuoteStatus</returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetQuoteStatus([FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
QuoteStatusBiz biz = QuoteStatusBiz.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.GetAsync(id);
|
||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update QuoteStatus
|
||||
/// </summary>
|
||||
/// <param name="updatedObject"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> PutQuoteStatus([FromBody] QuoteStatus updatedObject)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
QuoteStatusBiz biz = QuoteStatusBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency })); ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete QuoteStatus
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>NoContent</returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteQuoteStatus([FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
QuoteStatusBiz biz = QuoteStatusBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!await biz.DeleteAsync(id))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get Status list
|
||||
/// </summary>
|
||||
/// <returns>List in alphabetical order of all work order status items</returns>
|
||||
[HttpGet("list")]
|
||||
public async Task<IActionResult> StatusList()
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!Authorized.HasSelectRole(HttpContext.Items, AyaType.QuoteStatus))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var allStates = await ct.QuoteStatus.AsNoTracking().OrderBy(z => z.Name).ToListAsync();
|
||||
var currentUserRoles = UserRolesFromContext.Roles(HttpContext.Items);
|
||||
var allowedStates = allStates.Where(z => currentUserRoles.HasAnyFlags(z.SelectRoles)).ToList();
|
||||
|
||||
// foreach (var item in rpts)
|
||||
// {
|
||||
// if (CurrentUserRoles.HasAnyFlags(item.roles))
|
||||
// {
|
||||
// ret.Add(new NameIdItem() { Name = item.name, Id = item.id });
|
||||
// }
|
||||
// }
|
||||
return Ok(ApiOkResponse.Response(new { all = allStates, allowed = allowedStates }));
|
||||
}
|
||||
|
||||
//------------
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
ReminderBiz biz = ReminderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace AyaNova.Api.Controllers
|
||||
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
ReviewBiz biz = ReviewBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
ServiceRateBiz biz = ServiceRateBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace AyaNova.Api.Controllers
|
||||
TaskGroupBiz biz = TaskGroupBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
TaxCodeBiz biz = TaxCodeBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace AyaNova.Api.Controllers
|
||||
TranslationBiz biz = TranslationBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AyaNova.Api.Controllers
|
||||
TravelRateBiz biz = TravelRateBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace AyaNova.Api.Controllers
|
||||
UnitBiz biz = UnitBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace AyaNova.Api.Controllers
|
||||
UnitModelBiz biz = UnitModelBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace AyaNova.Api.Controllers
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.User) && !Authorized.HasModifyRole(HttpContext.Items, AyaType.Customer))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
VendorBiz biz = VendorBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace AyaNova.Api.Controllers
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.WorkOrderPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.WorkOrderPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -345,7 +345,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItem) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.ItemPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.ItemPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -452,7 +452,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemExpense) || biz.UserIsSubContractorFull || biz.UserIsSubContractorRestricted)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.ExpensePutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.ExpensePutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -560,7 +560,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemLabor))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.LaborPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.LaborPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -668,7 +668,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemLoan) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.LoanPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.LoanPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -777,7 +777,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemOutsideService) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.OutsideServicePutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.OutsideServicePutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -884,7 +884,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemPart) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PartPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PartPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -990,7 +990,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemPartRequest) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PartRequestPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PartRequestPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -1096,7 +1096,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemScheduledUser) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.ScheduledUserPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.ScheduledUserPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -1202,7 +1202,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemTask))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.TaskPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.TaskPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -1308,7 +1308,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemTravel))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.TravelPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.TravelPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
@@ -1414,7 +1414,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemUnit) || biz.UserIsRestrictedType)
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.UnitPutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.UnitPutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderItemPriorityBiz biz = WorkOrderItemPriorityBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderItemStatusBiz biz = WorkOrderItemStatusBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
WorkOrderStatusBiz biz = WorkOrderStatusBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
|
||||
Reference in New Issue
Block a user