From 55654241087979abe7cca4ef24ab65cf0b26829c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 22 Jan 2020 15:36:11 +0000 Subject: [PATCH] --- devdocs/todo.txt | 2 +- server/AyaNova/biz/DataListTemplateBiz.cs | 166 +++++++++++----------- 2 files changed, 85 insertions(+), 83 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 672d1312..31558d10 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -35,7 +35,7 @@ TEST CHANGES - New routes for lists - +TODO: REFACTOR GetNoLogAsync function is used in many places redundantly when the logging version could do the same thing but not log it with an optional bool switch so refactor that shit diff --git a/server/AyaNova/biz/DataListTemplateBiz.cs b/server/AyaNova/biz/DataListTemplateBiz.cs index 05753037..10623857 100644 --- a/server/AyaNova/biz/DataListTemplateBiz.cs +++ b/server/AyaNova/biz/DataListTemplateBiz.cs @@ -36,86 +36,80 @@ namespace AyaNova.Biz return new DataListTemplateBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull); } - //////////////////////////////////////////////////////////////////////////////////////////////// - //EXISTS - internal async Task ExistsAsync(long id) - { - return await ct.DataListTemplate.AnyAsync(e => e.Id == id); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - /// GET - internal async Task GetNoLogAsync(long fetchId) - { - //This is simple so nothing more here, but often will be copying to a different output object or some other ops - return await ct.DataListTemplate.SingleOrDefaultAsync(m => m.Id == fetchId); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - //CREATE - internal async Task CreateAsync(DataListTemplate inObj) - { - Validate(inObj, true); - if (HasErrors) - return null; - else - { - //do stuff with datafilter - DataListTemplate outObj = inObj; - outObj.UserId = UserId; + // //////////////////////////////////////////////////////////////////////////////////////////////// + // //EXISTS + // internal async Task ExistsAsync(long id) + // { + // return await ct.DataListTemplate.AnyAsync(e => e.Id == id); + // } - await ct.DataListTemplate.AddAsync(outObj); - await ct.SaveChangesAsync(); - //Handle child and associated items: - - //EVENT LOG - EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct); - - //SEARCH INDEXING - // Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name); - - return outObj; - - } - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - //CREATE - internal DataListTemplate Create(AyContext TempContext, DataListTemplate inObj) - { - Validate(inObj, true); - if (HasErrors) - return null; - else - { - //do stuff with datafilter - DataListTemplate outObj = inObj; - outObj.UserId = UserId; + // //////////////////////////////////////////////////////////////////////////////////////////////// + // //CREATE + // internal async Task CreateAsync(DataListTemplate inObj) + // { + // Validate(inObj, true); + // if (HasErrors) + // return null; + // else + // { + // //do stuff with datafilter + // DataListTemplate outObj = inObj; + // outObj.UserId = UserId; - TempContext.DataListTemplate.Add(outObj); - TempContext.SaveChanges(); + // await ct.DataListTemplate.AddAsync(outObj); + // await ct.SaveChangesAsync(); - //Handle child and associated items: + // //Handle child and associated items: - //EVENT LOG - EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext); + // //EVENT LOG + // EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct); - //SEARCH INDEXING - // Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name); + // //SEARCH INDEXING + // // Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name); - return outObj; + // return outObj; - } - } + // } + // } + + // //////////////////////////////////////////////////////////////////////////////////////////////// + // //CREATE + // internal DataListTemplate Create(AyContext TempContext, DataListTemplate inObj) + // { + // Validate(inObj, true); + // if (HasErrors) + // return null; + // else + // { + // //do stuff with datafilter + // DataListTemplate outObj = inObj; + // outObj.UserId = UserId; + + + // TempContext.DataListTemplate.Add(outObj); + // TempContext.SaveChanges(); + + // //Handle child and associated items: + + // //EVENT LOG + // EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext); + + // //SEARCH INDEXING + // // Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name); + + // return outObj; + + // } + // } //////////////////////////////////////////////////////////////////////////////////////////////// /// GET //Get one - internal async Task GetAsync(long fetchId) + internal async Task GetAsync(string DataListKey, bool log=true) { //This is simple so nothing more here, but often will be copying to a different output object or some other ops var ret = await ct.DataListTemplate.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId)); @@ -128,26 +122,34 @@ namespace AyaNova.Biz } - //get picklist (NOT PAGED) - internal async Task> GetPickListAsync(string listKey) + //////////////////////////////////////////////////////////////////////////////////////////////// + /// GET + internal async Task GetNoLogAsync(long fetchId) { - List items = new List(); - if (!string.IsNullOrWhiteSpace(listKey)) - { - items = await ct.DataListTemplate - .AsNoTracking() - .Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId)) - .OrderBy(m => m.Name) - .Select(m => new NameIdItem() - { - Id = m.Id, - Name = m.Name - }).ToListAsync(); - - } - return items; + //This is simple so nothing more here, but often will be copying to a different output object or some other ops + return await ct.DataListTemplate.SingleOrDefaultAsync(m => m.Id == fetchId); } + // //get picklist (NOT PAGED) + // internal async Task> GetPickListAsync(string listKey) + // { + // List items = new List(); + // if (!string.IsNullOrWhiteSpace(listKey)) + // { + // items = await ct.DataListTemplate + // .AsNoTracking() + // .Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId)) + // .OrderBy(m => m.Name) + // .Select(m => new NameIdItem() + // { + // Id = m.Id, + // Name = m.Name + // }).ToListAsync(); + + // } + // return items; + // } +