blob: e39d858c53ffc85d93e123d56bb5788ecadc20a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
using System.Threading.Tasks;
using DevHive.Data.Repositories;
using DevHive.Services.Services;
using Microsoft.AspNetCore.Mvc;
using DevHive.Web.Models.Identity.Role;
using AutoMapper;
using DevHive.Services.Models.Identity.Role;
using System;
namespace DevHive.Web.Controllers
{
[ApiController]
[Route("/api/[controller]")]
public class RoleController
{
private readonly RoleService _service;
private readonly IMapper _roleMapper;
public RoleController(DevHiveContext context)
{
this._service = new RoleService(context);
}
[HttpPost]
public Task<IActionResult> Create(CreateRoleWebModel createRoleWebModel)
{
RoleServiceModel roleServiceModel = this._roleMapper.Map<RoleServiceModel>(createRoleWebModel);
return this._service.CreateRole(roleServiceModel);
}
[HttpGet]
public Task<IActionResult> Get(Guid id)
{
return this._service.GetRoleById(id);
}
[HttpPut]
public Task<IActionResult> Update(UpdateRoleWebModel updateRoleWebModel)
{
RoleServiceModel roleServiceModel = this._roleMapper.Map<RoleServiceModel>(updateRoleWebModel);
return this._service.UpdateRole(roleServiceModel);
}
[HttpDelete]
public Task<IActionResult> Delete(Guid id)
{
return this._service.DeleteRole(id);
}
}
}
|