Select Git revision
-
Marcel Nellesen authoredMarcel Nellesen authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
RoleController.cs 1.02 KiB
using Coscine.Database.Models;
using Coscine.Database.ReturnObjects;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
namespace Coscine.Api.Project.Controllers
{
/// <summary>
/// This controller represents the actions which can be taken with a role object
/// </summary>
[Authorize]
public class RoleController : Controller
{
private readonly RoleModel _roleModel;
/// <summary>
/// RoleController specifying a RoleModel
/// </summary>
public RoleController()
{
_roleModel = new RoleModel();
}
/// <summary>
/// Returns all available roles
/// </summary>
/// <returns>All Roles </returns>
[Route("[controller]")]
public ActionResult<IEnumerable<RoleObject>> Index()
{
return Json(_roleModel.GetAll()
.Select((role) => new RoleObject(role.Id, role.DisplayName)));
}
}
}