示例#1
0
        public ActionResult <Role> GetRoleById(int id)
        {
            var roleModelFromRepo = _repository.GetRoleById(id);

            if (roleModelFromRepo == null)
            {
                return(NotFound());
            }
            return(Ok(roleModelFromRepo));
        }
示例#2
0
        public ActionResult <User> CreateUser(UserDto userDto)
        {
            var roleModel = _roleRepo.GetRoleById(userDto.RoleId);

            if (roleModel == null)
            {
                return(NotFound());
            }
            var userModel = new User
            {
                Name     = userDto.Name,
                Email    = userDto.Email,
                Role     = roleModel,
                Password = userDto.Password
            };

            _repository.CreateUser(userModel);
            _repository.SaveChanges();
            return(Ok(userModel));
        }
示例#3
0
 public RoleModel GetRoleById(Guid RoleId)
 {
     return(_IRoleRepo.GetRoleById(RoleId));
 }