From 7039b367bd3278ad347dc44429d74c88c9441420 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 22 Feb 2023 23:57:24 +0000 Subject: [PATCH] --- .../Controllers/AttachmentController.cs | 16 +------ server/AyaNova/biz/UserBiz.cs | 21 --------- server/AyaNova/biz/UserOptionsBiz.cs | 44 ++----------------- 3 files changed, 4 insertions(+), 77 deletions(-) diff --git a/server/AyaNova/Controllers/AttachmentController.cs b/server/AyaNova/Controllers/AttachmentController.cs index aab901f6..31b247dc 100644 --- a/server/AyaNova/Controllers/AttachmentController.cs +++ b/server/AyaNova/Controllers/AttachmentController.cs @@ -393,21 +393,7 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(ret)); } - // /// - // /// Utility to delete files that were uploaded but couldn't be stored for some reason, called by Attach route - // /// - // /// - // private static void DeleteTempFileUploadDueToBadRequest(ApiUploadProcessor.ApiUploadedFilesResult uploadFormData) - // { - // if (uploadFormData.UploadedFiles.Count > 0) - // { - // foreach (UploadedFileInfo a in uploadFormData.UploadedFiles) - // { - // System.IO.File.Delete(a.InitialUploadedPathName); - // } - // } - // } - + /// /// Delete Attachment diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index be60b25e..2a8bbd08 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -997,27 +997,6 @@ namespace AyaNova.Biz //Can delete? private async Task ValidateCanDelete(User inObj) { - // //To make this simple and avoid a whole host of issues and work - // //I've decided that a user can't be deleted if they have *any* activity in the event log - // //this way a newly created user can be deleted before they do any real work still to cover a scenario where a user - // //makes a user but then doesn't need it or did it wrong - // //This avoids the whole issues related to having to check every table everywhere for their work and - // //the associated fuckery with trying to back them out of those tables without knock-on effects - // //They can always make any user inactive to get rid of them and it will mean referential integrity issues are not there - - // //There's only one rule - have they done anything eventlog worthy yet? - // //if (await ct.Event.Select(z => z).Where(z => z.UserId == inObj.Id).Count() > 0) - // if (await ct.Event.AnyAsync(z => z.UserId == inObj.Id)) - // { - // //Theres no more specific error to show for this - // AddError(ApiErrorCode.INVALID_OPERATION, "generalerror", await Translate("ErrorDBForeignKeyViolation")); - // return; - // } - - //NOPE, the above is not going to fly for many reasons, going to have to do it the hard way - //Users need to know *what* is holding up deleting a user if they should choose to do so and - //the event log will eventually have a purge feature so it's not a reliable source - //the db would prevent it anyway, but it's best to do it right //FOREIGN KEY CHECKS if (await ct.Memo.AnyAsync(m => m.ToId == inObj.Id || m.FromId == inObj.Id)) diff --git a/server/AyaNova/biz/UserOptionsBiz.cs b/server/AyaNova/biz/UserOptionsBiz.cs index 4737f2a7..2ea3c8e9 100644 --- a/server/AyaNova/biz/UserOptionsBiz.cs +++ b/server/AyaNova/biz/UserOptionsBiz.cs @@ -36,48 +36,10 @@ namespace AyaNova.Biz //////////////////////////////////////////////////////////////////////////////////////////////// //UPDATE // + + //(never a create for this object) - //Creating a user creates a user options so no need for create ever - - // //////////////////////////////////////////////////////////////////////////////////////////////// - // //CREATE - // // - // internal async Task CreateAsync(UserOptions newObject) - // { - - // User u = await ct.User.AsNoTracking().SingleOrDefaultAsync(z => z.Id == newObject.UserId); - // if (u == null) - // { - // AddError(ApiErrorCode.NOT_FOUND, "id"); - // return null; - // } - // //Also used for Contacts (customer type user or ho type user) - // //by users with no User right but with Customer rights so need to double check here - // if ( - // (u.IsOutsideUser && !Authorized.HasModifyRole(CurrentUserRoles, AyaType.Customer)) || - // (!u.IsOutsideUser && !Authorized.HasModifyRole(CurrentUserRoles, AyaType.User)) - // ) - // { - // AddError(ApiErrorCode.NOT_AUTHORIZED); - // return null; - // } - - // Validate(newObject); - // if (HasErrors) - // return null; - // else - // { - - // await ct.UserOptions.AddAsync(newObject); - // await ct.SaveChangesAsync(); - // await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); - - // return newObject; - // } - // } - - - //put + //PUT internal async Task PutAsync(UserOptions dbObject, UserOptions inObj) {