This commit is contained in:
@@ -1,18 +1,13 @@
|
|||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
using AyaNova.Api.ControllerHelpers;
|
using AyaNova.Api.ControllerHelpers;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
|
|
||||||
|
|
||||||
namespace AyaNova.Api.Controllers
|
namespace AyaNova.Api.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -45,36 +40,30 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// /// <summary>
|
/// <summary>
|
||||||
// /// Get full DataListSavedColumnView object
|
/// Get DataListSavedColumnView
|
||||||
// /// </summary>
|
/// </summary>
|
||||||
// /// <param name="id"></param>
|
/// <param name="userId"></param>
|
||||||
// /// <returns>A single DataListSavedColumnView</returns>
|
/// <param name="listKey"></param>
|
||||||
// [HttpGet("{id}")]
|
/// <returns>DataListSavedColumnView</returns>
|
||||||
// public async Task<IActionResult> GetDataListSavedColumnView([FromRoute] long id)
|
[HttpGet("{userId}/{listKey}")]
|
||||||
// {
|
public async Task<IActionResult> GetDataListSavedColumnView([FromRoute] long userId, [FromRoute] string listKey)
|
||||||
// if (!serverState.IsOpen)
|
{
|
||||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
// //Instantiate the business object handler
|
DataListSavedColumnViewBiz biz = DataListSavedColumnViewBiz.GetBiz(ct, HttpContext);
|
||||||
// DataListSavedColumnViewBiz biz = DataListSavedColumnViewBiz.GetBiz(ct, HttpContext);
|
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
// if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
if (!ModelState.IsValid)
|
||||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
var o = await biz.GetAsync(userId, listKey, true);
|
||||||
// if (!ModelState.IsValid)
|
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
return Ok(ApiOkResponse.Response(o));
|
||||||
|
}
|
||||||
// var o = await biz.GetAsync(id);
|
|
||||||
// if (o == null)
|
|
||||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
// return Ok(ApiOkResponse.Response(o));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replace DataListSavedColumnView
|
/// Replace DataListSavedColumnView
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="newObject"></param>
|
/// <param name="newObject"></param>
|
||||||
@@ -94,45 +83,30 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// /// <summary>
|
/// <summary>
|
||||||
// /// Put (update) the single DataListSavedColumnView for this userid / listkey combo
|
/// Reset DataListSavedColumnView to factory defaults
|
||||||
// /// </summary>
|
/// </summary>
|
||||||
// /// <param name="inObj">Replacement default saved column view</param>
|
/// <param name="userId"></param>
|
||||||
// /// <returns></returns>
|
/// <param name="listKey"></param>
|
||||||
// [HttpPut]
|
/// <returns>NoContent</returns>
|
||||||
// public async Task<IActionResult> PutDataListSavedColumnView([FromBody] DataListSavedColumnView inObj)
|
[HttpDelete("{id}")]
|
||||||
// {
|
public async Task<IActionResult> DeleteProject([FromRoute] long userId, [FromRoute] string listKey)
|
||||||
// if (!serverState.IsOpen)
|
{
|
||||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
// if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
DataListSavedColumnViewBiz biz = DataListSavedColumnViewBiz.GetBiz(ct, HttpContext);
|
||||||
// //Instantiate the business object handler
|
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||||
// DataListSavedColumnViewBiz biz = DataListSavedColumnViewBiz.GetBiz(ct, HttpContext);
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
if (!await biz.DeleteAsync(userId, listKey))
|
||||||
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
// try
|
return NoContent();
|
||||||
// {
|
}
|
||||||
// if (!await biz.PutAsync(inObj))
|
|
||||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
// }
|
|
||||||
// catch (DbUpdateConcurrencyException)
|
|
||||||
// {
|
|
||||||
// if (!await biz.ExistsAsync(inObj.Id))
|
|
||||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
// else
|
|
||||||
// return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
// }
|
|
||||||
// return Ok();
|
|
||||||
// //return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
|
|||||||
@@ -68,9 +68,7 @@ namespace AyaNova.Biz
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//GET
|
//GET
|
||||||
//
|
//
|
||||||
//Internal, used by datalistfetcher via datalisttableprocessingoptions constructor
|
//
|
||||||
//can be called without full biz instantiation as it doesn't rely on UserId in biz object or other shit
|
|
||||||
//maybe should be static?
|
|
||||||
internal async Task<DataListSavedColumnView> GetAsync(long userId, string listKey, bool createDefaultIfNecessary)
|
internal async Task<DataListSavedColumnView> GetAsync(long userId, string listKey, bool createDefaultIfNecessary)
|
||||||
{
|
{
|
||||||
var ret = await ct.DataListSavedColumnView.AsNoTracking().SingleOrDefaultAsync(z => z.UserId == userId && z.ListKey == listKey);
|
var ret = await ct.DataListSavedColumnView.AsNoTracking().SingleOrDefaultAsync(z => z.UserId == userId && z.ListKey == listKey);
|
||||||
@@ -90,6 +88,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//DELETE
|
//DELETE
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user