Files
mixtape/zero.Backoffice/Modules/Users/UserRolesController.cs
T

42 lines
1.2 KiB
C#
Raw Normal View History

2020-04-24 12:46:25 +02:00
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
2020-04-24 12:46:25 +02:00
using System.Threading.Tasks;
using zero.Core.Api;
using zero.Core.Entities;
using zero.Core.Identity;
using zero.Web.Models;
2020-04-24 12:46:25 +02:00
namespace zero.Web.Controllers
{
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Read)]
public class UserRolesController : BackofficeController
{
2021-11-23 22:56:22 +01:00
IUserRolesService Api;
IPermissionsService PermissionsApi;
2021-11-23 22:56:22 +01:00
public UserRolesController(IUserRolesService api, IPermissionsService permissionsApi)
2020-04-24 12:46:25 +02:00
{
Api = api;
2020-05-06 11:07:44 +02:00
PermissionsApi = permissionsApi;
2020-04-24 12:46:25 +02:00
}
2021-11-23 22:56:22 +01:00
public async Task<EditModel<ZeroUserRole>> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
2020-04-24 12:46:25 +02:00
2021-11-23 22:56:22 +01:00
public async Task<IList<ZeroUserRole>> GetAll() => await Api.GetAll();
2020-08-31 12:09:59 +02:00
public IList<PermissionCollection> GetAllPermissions() => PermissionsApi.GetAll();
2020-08-11 16:01:10 +02:00
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Update)]
2021-11-23 22:56:22 +01:00
public async Task<EntityResult<ZeroUserRole>> Save([FromBody] ZeroUserRole model) => await Api.Save(model);
2020-04-28 14:51:17 +02:00
2020-08-11 16:01:10 +02:00
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Update)]
2021-11-23 22:56:22 +01:00
public async Task<EntityResult<ZeroUserRole>> Delete([FromQuery] string id) => await Api.Delete(id);
2020-04-24 12:46:25 +02:00
}
}