public async Task <ActionResult <TSFeedback> > GetFeedback() { string userID = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "UserID", 10); await TS.AddActivityLog(userID, "Requested Feedback", MethodBase.GetCurrentMethod()); SymmKeyAndIV ClientSymmKeyAndIV = new SymmKeyAndIV { Key = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "ClientSymmKey", 5), IV = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "ClientSymmIV", 10) }; if (!string.IsNullOrEmpty(ClientSymmKeyAndIV.Key)) { TSFeedbackEntity feedbackEntity = await TS.FindFeedback(userID, true, string.Empty); if (feedbackEntity != null) { TSFeedback result = feedbackEntity.toTSFeedback(); GlobalFunctions.CmdEncryptEntitySymm(result, ClientSymmKeyAndIV); return(result); } else { return(new TSFeedback()); } } else { return(new TSFeedback()); } }
public async Task <ActionResult <TSFeedback> > AddFeedback([FromBody] TSFeedback TSFeedback) { GlobalFunctions.CmdDecryptEntityAsymm(TSFeedback); TSFeedback.UserID = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "UserID", 10); await TS.AddActivityLog(TSFeedback.UserID, "Add or update Feedback", MethodBase.GetCurrentMethod()); string userName = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "UserName", 10); if (!string.IsNullOrEmpty(TSFeedback.UserID)) { if (userName.Equals("demouser")) { return(new TSFeedback()); } } TSFeedbackEntity oldFeedback = await TS.FindFeedback(TSFeedback.UserID, true, string.Empty); if (oldFeedback is null) { string a = await TS.GetNewID("AllUsers", "LastFeedbackID", false); TSFeedback.FeedbackID = int.Parse(a); bool b = await TS.AddFeedback(TSFeedback); if (b) { await GlobalFunctions.NotifyAdmin("New Feedback " + userName + " " + TSFeedback.Text); await TS.UpdateSettingCounter("AllUsers", "FeedbackCount", true); } } else { if (oldFeedback.Text != TSFeedback.Text) { bool b = await TS.UpdateFeedback(TSFeedback); if (b) { await GlobalFunctions.NotifyAdmin("Feedback update to " + TSFeedback.Text + " " + userName); } } } SymmKeyAndIV ClientSymmKeyAndIV = new SymmKeyAndIV { Key = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "ClientSymmKey", 5), IV = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "ClientSymmIV", 10) }; if (!string.IsNullOrEmpty(ClientSymmKeyAndIV.Key)) { TSFeedbackEntity feedbackEntity = await TS.FindFeedback(TSFeedback.UserID, true, string.Empty); if (feedbackEntity != null) { TSFeedback result = feedbackEntity.toTSFeedback(); GlobalFunctions.CmdEncryptEntitySymm(result, ClientSymmKeyAndIV); return(result); } else { return(new TSFeedback()); } } else { return(new TSFeedback()); } }