コード例 #1
0
        public async Task <ActionResult <Position> > PostPosition([FromForm] Position position)
        {
            await _position.AddAsync(position);

            try
            {
                await _position.CommitAsync();
            }
            catch (Exception)
            {
                return(BadRequest(new { errors = new[] { "При добавлении произошла ошибка" } }));
            }
            await _authService.AddRole(position.Name);

            return(StatusCode(201, new { message = "Должность добавлена" }));
        }
コード例 #2
0
 public IHttpActionResult Create([FromBody] CreateRoleDto role)
 {
     try
     {
         _authService.AddRole(role.Name);
     }
     catch (LogicalException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch
     {
         return(BadRequest(AppSettings.INTERNAL_SERVER_ERROR_MESSAGE));
     }
     return(Ok());
 }
コード例 #3
0
        public async Task <IActionResult> AddRole(RoleDtoAdd newRole)
        {
            var result = await _auth.AddRole(newRole);

            return(Ok(result));
        }
コード例 #4
0
        public async Task <object> CreateRole(string role)
        {
            var result = await _authService.AddRole(role);

            return(Ok(result));
        }