This commit is contained in:
2021-06-30 18:24:30 +00:00
parent ad50aeac4a
commit 41da081ce5
4 changed files with 85 additions and 7 deletions

View File

@@ -92,6 +92,41 @@ namespace AyaNova.Api.Controllers
//Creating a user creates a user options so no need for create ever
// /// <summary>
// /// Create UserOptions
// /// </summary>
// /// <param name="newObject"></param>
// /// <param name="apiVersion">From route path</param>
// /// <returns></returns>
// [HttpPost]
// public async Task<IActionResult> PostUserOptions([FromBody] UserOptions newObject, ApiVersion apiVersion)
// {
// if (!serverState.IsOpen)
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
// // var UserId = UserIdFromContext.Id(HttpContext.Items);
// // //preclearance
// // //the biz object will further check
// // if (newObject.Id != UserId)
// // {
// // //Also used for Contacts (customer type user or ho type user)
// // //by users with no User right so further biz rule required depending on usertype
// // //this is just phase 1
// // if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.User) && !Authorized.HasCreateRole(HttpContext.Items, AyaType.Customer))
// // return StatusCode(403, new ApiNotAuthorizedResponse());
// // }
// UserOptionsBiz biz = new UserOptionsBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
// if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState));
// UserOptions o = await biz.CreateAsync(newObject);
// if (o == null)
// return BadRequest(new ApiErrorResponse(biz.Errors));
// else
// return CreatedAtAction(nameof(UserOptionsController.GetUserOptions), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
// }
/// <summary>
/// Update UserOptions
@@ -106,9 +141,8 @@ namespace AyaNova.Api.Controllers
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!ModelState.IsValid)
{
return BadRequest(new ApiErrorResponse(ModelState));
}
var UserId = UserIdFromContext.Id(HttpContext.Items);
var o = await ct.UserOptions.SingleOrDefaultAsync(z => z.UserId == id);
@@ -118,6 +152,8 @@ namespace AyaNova.Api.Controllers
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
}
//preclearance
//the biz object will further check
if (id != UserId)
{
//Also used for Contacts (customer type user or ho type user)