Пример #1
0
        private IReadOnlyCollection <IValueSetCode> GetCodes(Guid valueSetGuid)
        {
            var factory = new ValueSetCodeFactory();
            var codes   = this.uowManager.GetCodeDtos(valueSetGuid);

            return(codes.Select(factory.Build).ToList());
        }
Пример #2
0
        private async Task <PagedCollection <IValueSetCode> > CreatePagedCollectionAsync(
            IQueryable <ValueSetCodeDto> source,
            IPagerSettings pagerSettings)
        {
            var defaultItemsPerPage = this.sharedContext.Settings.DefaultItemsPerPage;
            var pagingStrategy      = this.pagingStrategyFactory.GetPagingStrategy <IValueSetCode>(defaultItemsPerPage);
            var orderingStrategy    = this.orderingStrategyFactory.GetValueSetCodeStrategy();

            pagingStrategy.EnsurePagerSettings(pagerSettings);

            var count = await source.CountAsync();

            source = orderingStrategy.SetOrdering(source, pagerSettings.AsOrderingParameters());

            var items = await source.Skip((pagerSettings.CurrentPage - 1) *pagerSettings.ItemsPerPage)
                        .Take(pagerSettings.ItemsPerPage)
                        .ToListAsync();

            var factory = new ValueSetCodeFactory();

            // Can't cache at this point since codeGuid can be null in db.
            // If this changes in the future, caching should/could be implemented.
            return(pagingStrategy.CreatePagedCollection(
                       items.Select(factory.Build),
                       count,
                       pagerSettings));
        }
Пример #3
0
 private ILookup <Guid, IValueSetCode> QueryValueSetCodeLookup(IEnumerable <Guid> valueSetGuids)
 {
     try
     {
         var factory = new ValueSetCodeFactory();
         return(this.sharedContext.ValueSetCodes.Where(dto => valueSetGuids.Contains(dto.ValueSetGUID))
                .AsNoTracking()
                .ToLookup(vsc => vsc.ValueSetGUID, vsc => factory.Build(vsc)));
     }
     catch (Exception ex)
     {
         this.logger.Error(ex, "Failed to query for ValueSetCode lookup for collection of ValueSetGUIDs");
         throw;
     }
 }
Пример #4
0
 public IReadOnlyCollection <IValueSetCode> GetValueSetCodesByCodeGuid(Guid codeGuid)
 {
     try
     {
         var factory = new ValueSetCodeFactory();
         return(this.sharedContext.ValueSetCodes.Where(dto => dto.CodeGUID == codeGuid)
                .AsNoTracking()
                .ToList()
                .Select(factory.Build)
                .ToList());
     }
     catch (Exception ex)
     {
         this.logger.Error(ex, "Failed to query ValueSetCodes by CodeGuid");
         throw;
     }
 }
Пример #5
0
        private IReadOnlyCollection <IValueSetCode> QueryValueSetCodes(IEnumerable <Guid> valueSetGuids)
        {
            try
            {
                var setGuids = valueSetGuids as Guid[] ?? valueSetGuids.ToArray();
                if (!setGuids.Any())
                {
                    return(new List <IValueSetCode>());
                }

                var factory = new ValueSetCodeFactory();
                return(this.sharedContext.ValueSetCodes.Where(dto => setGuids.Contains(dto.ValueSetGUID))
                       .AsNoTracking()
                       .ToList()
                       .Select(factory.Build)
                       .ToList());
            }
            catch (Exception ex)
            {
                this.logger.Error(ex, "Failed to query ValueSetCodes given a collection ValueSetGUID");
                throw;
            }
        }