public async Task <ReadResponseMessage <TEntity> > Handle()
        {
            var repository = _unitOfWork.GetRepository <TEntity>();
            // First get all assets, then filter by those that are in
            var allData = await repository.GetAll();

            var response = ResponseFactory.BuildReadResponse($"{allData.Count()} Records returned", allData);

            return(response);
        }
예제 #2
0
        /// <summary>
        /// Handles getting a list of users that are information asset owners and returns the ones the specified user has access to.
        /// </summary>
        /// <param name="userId">accepts an <see cref="int"/> which specifies the id of the user that wants to view the list of Information Asset Owners</param>
        /// <returns></returns>
        public async Task <ReadResponseMessage <User> > Handle(string businessAreaName)
        {
            var repository = _unitOfWork.GetRepository <User>();
            var users      = await repository.GetAll();

            var results  = users.Where(x => x.IsIAO == true && x.BusinessArea.BusinessAreaName == businessAreaName);
            var response = ResponseFactory.BuildReadResponse($"{results.Count()} records returned", results);

            return(response);
        }
예제 #3
0
        /// <summary>
        /// Handles getting a list of users that are information asset owners and returns the ones the specified user has access to.
        /// </summary>
        /// <param name="userId">accepts an <see cref="int"/> which specifies the id of the user that wants to view the list of Information Asset Owners</param>
        /// <returns></returns>
        public async Task <ReadResponseMessage <User> > Handle(int userId)
        {
            var repository = _unitOfWork.GetRepository <User>();
            var user       = await repository.Get(userId);

            var iaoUsers = new List <User>();

            foreach (var item in user.LinkedUsers)
            {
                if (item.LinkedUser.IsIAO)
                {
                    iaoUsers.Add(item.LinkedUser);
                }
            }

            var response = ResponseFactory.BuildReadResponse($"{user.LinkedUsers.Count()} records returned", iaoUsers);

            return(response);
        }
        public async Task <ReadResponseMessage <Asset> > Handle(int userId)
        {
            try
            {
                var userRepo = _unitOfWork.GetRepository <User>();
                var user     = await userRepo.Get(userId);

                var repository = _unitOfWork.GetRepository <Asset>();
                // First get all assets, then filter by those that are in
                var allAssets = await repository.GetAll();

                var myAssets = allAssets.Where(x => user.LinkedUsers.Any(u => u.LinkedUser.UserId == x.InformationAssetOwner.UserId));
                var response = ResponseFactory.BuildReadResponse($"{myAssets.Count()} Information Assets Returned", myAssets);
                return(response);
            }
            catch (Exception ex)
            {
                return(new ReadResponseMessage <Asset>()
                {
                    InnerException = ex, OutputMessage = "Failed to get a list of Information Assets", ResponseType = ResponseTypes.Error
                });
            }
        }