public async Task <RoleForListDto> Create(RoleForCreationAndUpdateDto roleForCreationAndUpdateDto) { var checkRoleNameFormRepo = await roleDal.GetAsync(x => x.Name.ToLower() == roleForCreationAndUpdateDto.Name.ToLower()); if (checkRoleNameFormRepo != null) { throw new RestException(HttpStatusCode.BadRequest, new { RoleAlreadyExist = Messages.RoleNameAlreadyExist }); } var roleForCreate = mapper.Map <Role>(roleForCreationAndUpdateDto); var createdRole = await roleDal.Add(roleForCreate); var spec = new RolesWithRoleCategorySpecification(createdRole.Id); var roleToReturn = await roleDal.GetEntityWithSpecAsync(spec); return(mapper.Map <Role, RoleForListDto>(roleToReturn)); }