2024-05-21 20:55:12 +00:00
|
|
|
using BotSharp.Abstraction.Users.Enums;
|
|
|
|
|
|
2023-06-23 04:43:00 +00:00
|
|
|
namespace BotSharp.Core.Agents.Services;
|
|
|
|
|
|
|
|
|
|
public partial class AgentService
|
|
|
|
|
{
|
|
|
|
|
public async Task<bool> DeleteAgent(string id)
|
|
|
|
|
{
|
2024-11-14 23:33:26 +00:00
|
|
|
var userService = _services.GetRequiredService<IUserService>();
|
|
|
|
|
var auth = await userService.GetUserAuthorizations(id);
|
2024-05-21 20:55:12 +00:00
|
|
|
|
2024-11-14 23:33:26 +00:00
|
|
|
if (auth.IsAdmin || auth.AgentActions.Contains(UserAction.Edit))
|
2024-05-21 20:55:12 +00:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var deleted = _db.DeleteAgent(id);
|
|
|
|
|
return await Task.FromResult(deleted);
|
2023-06-23 04:43:00 +00:00
|
|
|
}
|
|
|
|
|
}
|