Exemple #1
0
        public async Task <WorkspaceModel> GetWorkspaceById(long workspaceId)
        {
            var unitOfWork = _unitOfWorkFactory.CreateUnitOfWork();

            var result = await _workspaceDAL.GetWorkspaceById(unitOfWork, workspaceId);

            return(result);
        }
Exemple #2
0
        public async Task <UserLimitedModel> GetCurrentUser(UnitOfWork unitOfWork, Guid userId)
        {
            var trackedEntity = await unitOfWork.NeonContext.NeonUsers
                                .Include(x => x.UsersProfile)
                                .FirstOrDefaultAsync(x => x.UserId == userId);

            if (trackedEntity == null)
            {
                throw new NullReferenceException("User Not Found");
            }

            var trackedWorkspaceEntity = await _workspaceDAL.GetWorkspaceById(unitOfWork, trackedEntity.WorkspaceUsers.FirstOrDefault(x => x.UserId == userId).WorkspaceId);

            if (trackedWorkspaceEntity == null)
            {
                throw new NullReferenceException("A user must have a workspace");
            }

            var user = _mapper.Map <UserLimitedModel>(trackedEntity);

            user.Workspace = _mapper.Map <WorkspaceLimitedModel>(trackedWorkspaceEntity);

            return(user);
        }