This commit is contained in:
@@ -26,7 +26,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
internal static FormCustomBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
|
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));
|
return new FormCustomBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,17 +89,31 @@ namespace AyaNova.Biz
|
|||||||
//Get one
|
//Get one
|
||||||
internal async Task<FormCustom> GetAsync(string formKey)
|
internal async Task<FormCustom> 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
|
//Step 1: check if exists, if it does then just return it
|
||||||
|
if (await ExistsAsync(formKey))
|
||||||
|
{
|
||||||
|
return await ct.FormCustom.SingleOrDefaultAsync(m => m.FormKey == formKey);
|
||||||
|
}
|
||||||
|
|
||||||
//If it doesn't exist, vet the form key name is ok by checking with this list
|
//If it doesn't exist, vet the form key name is ok by checking with this list
|
||||||
//FormAvailableFields.AvailableFormKeys
|
if (!FormAvailableFields.AvailableFormKeys.Contains(formKey))
|
||||||
// and if it is then create it, save to db and then return it
|
{
|
||||||
|
//Nope, whatever it is, it's not valid
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name is valid, make a new formcustom for the name specified, save to db and then return it
|
||||||
|
//NOTE: This assumes that the client will make it a legal form custom and so it doesn't include any pre-defined stock fields that are required etc
|
||||||
|
//this just makes an empty template suitable for the client to work with
|
||||||
|
var fc = new FormCustom()
|
||||||
|
{
|
||||||
|
FormKey = formKey,
|
||||||
|
Template = @"[]"
|
||||||
|
};
|
||||||
|
|
||||||
|
//Create and save to db
|
||||||
|
return await CreateAsync(fc);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user