コード例 #1
0
        public async Task <Operation> GetByIdWithGraphAsync(int id)
        {
            BaseSpecification <Operation> spec = new BaseSpecification <Operation>(O => O.Id == id);

            spec.AddInclude(o => o.IdCategorieNavigation);
            return(await _repositoryAsync.GetSingleBySpecAsync(spec));
        }
コード例 #2
0
        public async Task <IReadOnlyList <Operation> > ListAllWithGraphAsync()
        {
            BaseSpecification <Operation> spec = new BaseSpecification <Operation>();

            spec.AddInclude(o => o.IdCategorieNavigation);
            spec.ApplyOrderBy(O => O.Dateoperation);
            return(await this.ListAsync(spec));
        }
コード例 #3
0
        public async Task<IReadOnlyList<Categorie>> ListAllWithGraphAsync()
        {
            BaseSpecification<Categorie> spec = new BaseSpecification<Categorie>();
            spec.AddInclude(C => C.IdTypecategorieNavigation);
            spec.ApplyOrderBy(C => C.Libelle);

            return await _repositoryAsync.ListAsync(spec);            
        }
コード例 #4
0
        public async Task <List <MusicLabelDto> > GetAlbumMusicLabels(int albumId)
        {
            var spec = new BaseSpecification <AlbumMusicLabel>(x => x.AlbumId == albumId);

            spec.AddInclude(x => x.MusicLabel);

            var albumMLabelRepo   = _uow.GetRepository <AlbumMusicLabel>();
            var albumMLabelsQuery = albumMLabelRepo.SpecAsQueryable(spec);
            var musicLabels       = await albumMLabelsQuery.Select(y => y.MusicLabel).ToListAsync();

            var dto = Mapper.Map <List <MusicLabelDto> >(musicLabels);

            return(dto);
        }
コード例 #5
0
        public async Task <IList <TDto> > GetEntities(params Expression <Func <TEntity, object> >[] includes)
        {
            var spec = new BaseSpecification <TEntity>();

            for (int i = 0; i < includes.Length; i++)
            {
                var include = includes[i];
                spec.AddInclude(include);
            }
            var list = await _repository.ListAsync(spec);

            var dto = Mapper.Map <IList <TDto> >(list);

            return(dto);
        }
コード例 #6
0
        public async Task <TDto> GetById(int id, params Expression <Func <TEntity, object> >[] includes)
        {
            var spec = new BaseSpecification <TEntity>(x => x.Id == id);

            for (int i = 0; i < includes.Length; i++)
            {
                var include = includes[i];
                spec.AddInclude(include);
            }

            var list = await _repository.ListAsync(spec);

            var entity = list.FirstOrDefault();

            var dto = Mapper.Map <TDto>(entity);

            return(dto);
        }
コード例 #7
0
ファイル: MessageService.cs プロジェクト: bakay-1991/chat
        public async Task <Message> CreateMessageAsync(Guid userId, string text, Guid?ToUserId, Guid?ToGroupId)
        {
            Guard.Against.NullOrEmpty(text, nameof(text));
            if (ToUserId == null && ToGroupId == null)
            {
                throw new Exception("Missed receiver.");
            }

            Message message = new Message()
            {
                Created = DateTime.UtcNow, FromUserId = userId, Text = text, ToUserId = ToUserId, ToGroupId = ToGroupId
            };

            await _messageRepository.AddAsync(message);

            BaseSpecification <Message> messageSpec = new BaseSpecification <Message>();

            messageSpec.AddCriteria(x => x.Id == message.Id);
            messageSpec.AddInclude(x => x.FromUser);

            return(await _messageRepository.FirstOrDefaultAsync(messageSpec));
        }