2020-04-24 12:46:25 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using zero.Core.Api;
|
|
|
|
|
using zero.Core.Entities;
|
|
|
|
|
using zero.Core.Identity;
|
|
|
|
|
|
|
|
|
|
namespace zero.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Read)]
|
|
|
|
|
public class UserRolesController : BackofficeController
|
|
|
|
|
{
|
2020-05-11 15:34:47 +02:00
|
|
|
IUserRolesApi Api;
|
|
|
|
|
IPermissionsApi PermissionsApi;
|
2020-04-27 15:49:14 +02:00
|
|
|
|
|
|
|
|
|
2020-05-11 15:34:47 +02:00
|
|
|
public UserRolesController(IUserRolesApi api, IPermissionsApi 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-08-31 12:09:59 +02:00
|
|
|
public async Task<IActionResult> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
|
2020-04-24 12:46:25 +02:00
|
|
|
|
|
|
|
|
|
2020-08-31 12:09:59 +02:00
|
|
|
public async Task<IActionResult> GetAll() => Json(await Api.GetAll());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IActionResult GetAllPermissions() => Json(PermissionsApi.GetAll());
|
2020-04-27 15:49:14 +02:00
|
|
|
|
|
|
|
|
|
2020-08-11 16:01:10 +02:00
|
|
|
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Update)]
|
2020-08-31 12:09:59 +02:00
|
|
|
public async Task<IActionResult> Save([FromBody] IUserRole model) => Json(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)]
|
2020-08-31 12:09:59 +02:00
|
|
|
public async Task<IActionResult> Delete([FromQuery] string id) => Json(await Api.Delete(id));
|
2020-04-24 12:46:25 +02:00
|
|
|
}
|
|
|
|
|
}
|