diff --git a/server/AyaNova/Controllers/FormCustomController.cs b/server/AyaNova/Controllers/FormCustomController.cs
index 17fa2119..afd6760c 100644
--- a/server/AyaNova/Controllers/FormCustomController.cs
+++ b/server/AyaNova/Controllers/FormCustomController.cs
@@ -127,28 +127,28 @@ namespace AyaNova.Api.Controllers
}
}
- ///
- /// Get available types allowed for Custom fields
- /// Used to build UI for customizing a form
- ///
- /// Required roles:
- /// BizAdminFull only has rights to customize forms
- ///
- ///
- /// A list of type string values valid for custom fields
- [HttpGet("AvailableCustomTypes")]
- public ActionResult GetAvailableCustomTypes()
- {
- if (serverState.IsClosed)
- return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
+ // ///
+ // /// Get available types allowed for Custom fields
+ // /// Used to build UI for customizing a form
+ // ///
+ // /// Required roles:
+ // /// BizAdminFull only has rights to customize forms
+ // ///
+ // ///
+ // /// A list of type string values valid for custom fields
+ // [HttpGet("AvailableCustomTypes")]
+ // public ActionResult GetAvailableCustomTypes()
+ // {
+ // if (serverState.IsClosed)
+ // return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
- if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
- return StatusCode(403, new ApiNotAuthorizedResponse());
+ // if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
+ // return StatusCode(403, new ApiNotAuthorizedResponse());
- if (!ModelState.IsValid)
- return BadRequest(new ApiErrorResponse(ModelState));
- return Ok(ApiOkResponse.Response(CustomFieldType.ValidCustomFieldTypes, true));
- }
+ // if (!ModelState.IsValid)
+ // return BadRequest(new ApiErrorResponse(ModelState));
+ // return Ok(ApiOkResponse.Response(CustomFieldType.ValidCustomFieldTypes, true));
+ // }
///
@@ -221,38 +221,38 @@ namespace AyaNova.Api.Controllers
}
- ///
- /// Post FormCustom
- ///
- /// Required roles: BizAdminFull
- ///
- ///
- /// Automatically filled from route path, no need to specify in body
- ///
- [HttpPost]
- public async Task PostFormCustom([FromBody] FormCustom inObj, ApiVersion apiVersion)
- {
- if (!serverState.IsOpen)
- return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
+ // ///
+ // /// Post FormCustom
+ // ///
+ // /// Required roles: BizAdminFull
+ // ///
+ // ///
+ // /// Automatically filled from route path, no need to specify in body
+ // ///
+ // [HttpPost]
+ // public async Task PostFormCustom([FromBody] FormCustom inObj, ApiVersion apiVersion)
+ // {
+ // if (!serverState.IsOpen)
+ // return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
- //Instantiate the business object handler
- FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
+ // //Instantiate the business object handler
+ // FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
- //check rights
- if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
- return StatusCode(403, new ApiNotAuthorizedResponse());
+ // //check rights
+ // if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
+ // return StatusCode(403, new ApiNotAuthorizedResponse());
- if (!ModelState.IsValid)
- return BadRequest(new ApiErrorResponse(ModelState));
+ // if (!ModelState.IsValid)
+ // return BadRequest(new ApiErrorResponse(ModelState));
- //Create and validate
- FormCustom o = await biz.CreateAsync(inObj);
- if (o == null)
- return BadRequest(new ApiErrorResponse(biz.Errors));
- else
- return CreatedAtAction(nameof(FormCustomController.GetFormCustom), new { formkey = o.FormKey, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
+ // //Create and validate
+ // FormCustom o = await biz.CreateAsync(inObj);
+ // if (o == null)
+ // return BadRequest(new ApiErrorResponse(biz.Errors));
+ // else
+ // return CreatedAtAction(nameof(FormCustomController.GetFormCustom), new { formkey = o.FormKey, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
- }
+ // }
diff --git a/server/AyaNova/biz/FormAvailableFields.cs b/server/AyaNova/biz/FormAvailableFields.cs
index f175d852..b80084d8 100644
--- a/server/AyaNova/biz/FormAvailableFields.cs
+++ b/server/AyaNova/biz/FormAvailableFields.cs
@@ -2,6 +2,10 @@ using System.Collections.Generic;
namespace AyaNova.Biz
{
+ //************************************************
+ // This contains all the fields that are on customizable forms
+ //in addition it serves as a source for valid form keys in AvailableFormKeys
+ //
public static class FormAvailableFields
{
diff --git a/server/AyaNova/biz/FormCustomBiz.cs b/server/AyaNova/biz/FormCustomBiz.cs
index 2a7af22c..3b215a60 100644
--- a/server/AyaNova/biz/FormCustomBiz.cs
+++ b/server/AyaNova/biz/FormCustomBiz.cs
@@ -26,6 +26,7 @@ namespace AyaNova.Biz
internal static FormCustomBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
{
+
return new FormCustomBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
}
@@ -88,6 +89,14 @@ namespace AyaNova.Biz
//Get one
internal async Task GetAsync(string formKey)
{
+ TODO: this must create the formCustom record if it doesn't already exist
+ //Step 1: check if exists, if it does then just return it
+
+ //If it doesn't exist, vet the form key name is ok by checking with this list
+ //FormAvailableFields.AvailableFormKeys
+ // and if it is then create it, save to db and then return it
+
+
var ret = await ct.FormCustom.SingleOrDefaultAsync(m => m.FormKey == formKey);
//Do not log this, it's going to be called a zillion times anyway
return ret;