This commit is contained in:
2020-10-29 22:58:41 +00:00
parent 09d9f6849d
commit e52cc4053e
2 changed files with 12 additions and 13 deletions

View File

@@ -46,12 +46,12 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Get full DashboardView object /// Get DashboardView object for current User
/// There is always one for each user
/// </summary> /// </summary>
/// <param name="id"></param> /// <returns>Dashboard view</returns>
/// <returns>A single DashboardView</returns> [HttpGet()]
[HttpGet("{id}")] public async Task<IActionResult> GetDashboardView()
public async Task<IActionResult> GetDashboardView([FromRoute] long id)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -76,13 +76,12 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Put (update) DashboardView /// Put (update) logged in User's Dashboard view
/// </summary> /// </summary>
/// <param name="id"></param>
/// <param name="inObj"></param> /// <param name="inObj"></param>
/// <returns></returns> /// <returns></returns>
[HttpPut("{id}")] [HttpPut()]
public async Task<IActionResult> PutDashboardView([FromRoute] long id, [FromBody] DashboardView inObj) public async Task<IActionResult> PutDashboardView([FromBody] DashboardView inObj)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -107,7 +106,7 @@ namespace AyaNova.Api.Controllers
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
if (!await biz.ExistsAsync(id)) if (!await biz.ExistsAsync())
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
else else
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT)); return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));

View File

@@ -35,9 +35,9 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//EXISTS //EXISTS
internal async Task<bool> ExistsAsync(long id) internal async Task<bool> ExistsAsync()
{ {
return await ct.DashboardView.AnyAsync(z => z.Id == id); return await ct.DashboardView.AnyAsync(z => z.UserId == UserId);
} }