public bool IsAnyDictionaryByEntityName(string entityName) { var dicType = _dicTypeResolver.Resolve(entityName); var dictionaries = _context.Set(dicType) as IQueryable <IDictionaryEntity <int> >; return(dictionaries.Any()); }
internal override Task <IQueryable> Handle(IDicTypeResolver dicTypeResolver, NiisWebContext context, Query message) { var dicType = dicTypeResolver.Resolve(message.Dictype); var dictionaries = context.Set(dicType); return(Task.FromResult(dictionaries)); }
internal override Task <IQueryable> Handle(IDicTypeResolver dicTypeResolver, NiisWebContext context, Query message) { var dicType = dicTypeResolver.Resolve(message.Dictype); var dictionaries = context.Set(dicType).Cast <DictionaryEntity <int> >(); return(Task.FromResult( dictionaries.Where(d => message.Codes.Contains(d.Code)) as IQueryable)); }
async Task <SelectOptionDto> IAsyncRequestHandler <Query, SelectOptionDto> .Handle(Query message) { var dicType = _dicTypeResolver.Resolve(message.Dictype); var dictionaries = _context.Set(dicType); var dto = await dictionaries.ProjectTo <SelectOptionDto>().SingleOrDefaultAsync(d => d.Id == message.Id); if (dto == null) { throw new DataNotFoundException(nameof(dicType), DataNotFoundException.OperationType.Read, message.Id); } return(dto); }
public async Task <IEnumerable <BaseTreeNodeDto> > Handle(Query message) { var dicType = _dicTypeResolver.Resolve(message.DicType); if (!dicType.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IClassification <>))) { throw new ArgumentException( $"{message.DicType} not implements an interface {typeof(IClassification<>).Name}"); } var dictionaries = await _context.Set(dicType).Cast <dynamic>().ToListAsync(); return(_mapper.Map <IEnumerable <BaseTreeNodeDto> >(dictionaries.Where(d => d.ParentId == null))); }
Task <IDictionaryEntity <int> > IAsyncRequestHandler <Query, IDictionaryEntity <int> > .Handle(Query message) { var dicType = _dicTypeResolver.Resolve(message.Dictype); var dictionaries = _context.Set(dicType) as IQueryable <IDictionaryEntity <int> >; var dictionary = dictionaries?.SingleOrDefault(d => d.Id == message.Id); //var dto = await dictionaries.ProjectTo<BaseDictionaryDto>().SingleOrDefaultAsync(d => d.Id == message.Id); if (dictionary == null) { throw new DataNotFoundException(nameof(dicType), DataNotFoundException.OperationType.Read, message.Id); } return(Task.FromResult(dictionary)); }
internal override Task <IQueryable <SelectOptionDto> > Handle(IDicTypeResolver dicTypeResolver, NiisWebContext context, Query message) { var dicType = dicTypeResolver.Resolve(message.Dictype); if (message.Dictype.Equals(nameof(DicDocumentType))) { return(Task.FromResult(context.DicDocumentTypes .Where(dt => dt.Classification.Code.StartsWith(message.Codes[0]) && !dt.Classification.Code.Equals("01.01.01") && !dt.Classification.Code.Equals("01.02") && !dt.Classification.Code.Equals("001.06") ).ProjectTo <SelectOptionDto>())); } var dictionaries = context.Set(dicType).Cast <DictionaryEntity <int> >(); return(Task.FromResult(dictionaries.Where(d => message.Codes.Contains(d.Code)) .ProjectTo <SelectOptionDto>())); }
public bool ChechDictionaryId(string entityName, int id) { var dicType = _dicTypeResolver.Resolve(entityName); var dictionaries = _niisContext.Set(dicType) as IQueryable <IDictionaryEntity <int> >; if (dictionaries == null) { throw new ArgumentException($"Not found {entityName}"); } var dictionaryCode = dictionaries.Where(d => d.Id == id).Select(d => d.Code).FirstOrDefault(); if (string.IsNullOrEmpty(dictionaryCode)) { return(false); } return(true); }