BotSharp/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.DeleteAgent.cs

22 lines
581 B
C#
Raw Normal View History

2024-05-21 20:55:12 +00:00
using BotSharp.Abstraction.Users.Enums;
2024-11-15 02:19:53 +00:00
using BotSharp.Abstraction.Users.Models;
2024-05-21 20:55:12 +00:00
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>();
2024-11-15 02:19:53 +00:00
var auth = await userService.GetUserAuthorizations(new List<string> { id });
2024-05-21 20:55:12 +00:00
2024-11-15 02:19:53 +00:00
if (!auth.IsAgentActionAllowed(id, 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
}
}