test: edit user action backend
This commit is contained in:
parent
74c0d5235b
commit
ce50b7ef3e
|
@ -798,6 +798,23 @@ public class Controller : ControllerBase
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost(nameof(UpdateAction))]
|
||||||
|
public async Task<ActionResult<IEnumerable<Object>>> UpdateAction([FromBody] UserAction action, Token authToken)
|
||||||
|
{
|
||||||
|
var session = Db.GetSession(authToken);
|
||||||
|
var actionSuccess = await session.UpdateUserAction(action);
|
||||||
|
return actionSuccess ? Ok() : Unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost(nameof(DeleteAction))]
|
||||||
|
public async Task<ActionResult<IEnumerable<Object>>> DeleteAction([FromBody] UserAction action, Token authToken)
|
||||||
|
{
|
||||||
|
var session = Db.GetSession(authToken);
|
||||||
|
var actionSuccess = await session.DeleteUserAction(action);
|
||||||
|
return actionSuccess ? Ok() : Unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost(nameof(EditInstallationConfig))]
|
[HttpPost(nameof(EditInstallationConfig))]
|
||||||
public async Task<ActionResult<IEnumerable<Object>>> EditInstallationConfig([FromBody] Configuration config, Int64 installationId,Token authToken)
|
public async Task<ActionResult<IEnumerable<Object>>> EditInstallationConfig([FromBody] Configuration config, Int64 installationId,Token authToken)
|
||||||
|
|
|
@ -145,6 +145,34 @@ public static class SessionMethods
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<Boolean> UpdateUserAction(this Session? session, UserAction action)
|
||||||
|
{
|
||||||
|
var user = session?.User;
|
||||||
|
|
||||||
|
if (user is null || user.UserType == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
action.UserName = user.Name;
|
||||||
|
|
||||||
|
Db.UpdateAction(action);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static async Task<Boolean> DeleteUserAction(this Session? session, UserAction action)
|
||||||
|
{
|
||||||
|
var user = session?.User;
|
||||||
|
|
||||||
|
if (user is null || user.UserType == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
action.UserName = user.Name;
|
||||||
|
|
||||||
|
Db.Delete(action);
|
||||||
|
Console.WriteLine("---------------Deleted the Action in the database-----------------");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static Boolean Delete(this Session? session, Folder? folder)
|
public static Boolean Delete(this Session? session, Folder? folder)
|
||||||
{
|
{
|
||||||
var user = session?.User;
|
var user = session?.User;
|
||||||
|
|
|
@ -108,6 +108,19 @@ public static partial class Db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateAction(UserAction updatedAction)
|
||||||
|
{
|
||||||
|
var existingAction = UserActions.FirstOrDefault(action => action.Id == updatedAction.Id);
|
||||||
|
if (existingAction != null)
|
||||||
|
{
|
||||||
|
existingAction.Description = updatedAction.Description;
|
||||||
|
existingAction.Timestamp = updatedAction.Timestamp;
|
||||||
|
//Update(existingAction);
|
||||||
|
Console.WriteLine("---------------Updated the Action in the database-----------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void HandleError(Error newError,int installationId)
|
public static void HandleError(Error newError,int installationId)
|
||||||
{
|
{
|
||||||
//Find the total number of errors for this installation
|
//Find the total number of errors for this installation
|
||||||
|
|
|
@ -28,6 +28,11 @@ public static partial class Db
|
||||||
return Update(obj: warning);
|
return Update(obj: warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static Boolean Update(UserAction action)
|
||||||
|
// {
|
||||||
|
// return Update(obj: action);
|
||||||
|
// }
|
||||||
|
|
||||||
public static Boolean Update(Installation installation)
|
public static Boolean Update(Installation installation)
|
||||||
{
|
{
|
||||||
return Update(obj: installation);
|
return Update(obj: installation);
|
||||||
|
|
Loading…
Reference in New Issue