Ejemplo n.º 1
0
        public async Task <FarmResult> FindDetailAsync(IdRequestFilter <long> filter)
        {
            var exist = await _farmRepository.FindDetailAsync(filter);

            if (exist == null)
            {
                return(null);
            }

            var pictures = await _farmPictureRepository.GetFarmPicturesByFarmIdAsync(new IdRequestFilter <long>
            {
                Id              = filter.Id,
                CanGetDeleted   = filter.CanGetDeleted,
                CanGetInactived = filter.CanGetInactived
            });

            exist.Pictures = pictures.Select(x => new PictureResult
            {
                Id = x.PictureId
            });

            var createdByUserName = (await _userRepository.FindByIdAsync(exist.CreatedById)).DisplayName;

            exist.CreatedBy = createdByUserName;

            var updatedByUserName = (await _userRepository.FindByIdAsync(exist.UpdatedById)).DisplayName;

            exist.UpdatedBy = updatedByUserName;

            return(exist);
        }