public ActionResult <Role> GetRoleById(int id) { var roleModelFromRepo = _repository.GetRoleById(id); if (roleModelFromRepo == null) { return(NotFound()); } return(Ok(roleModelFromRepo)); }
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)); }
public RoleModel GetRoleById(Guid RoleId) { return(_IRoleRepo.GetRoleById(RoleId)); }