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 = "Должность добавлена" })); }
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()); }
public async Task <IActionResult> AddRole(RoleDtoAdd newRole) { var result = await _auth.AddRole(newRole); return(Ok(result)); }
public async Task <object> CreateRole(string role) { var result = await _authService.AddRole(role); return(Ok(result)); }