Exemplo n.º 1
0
        public object Get(GetSyncDialogOptions request)
        {
            var result = new SyncDialogOptions();

            result.Targets = _syncManager.GetSyncTargets(request.UserId)
                             .ToList();

            if (request.Category.HasValue)
            {
                result.Options = SyncHelper.GetSyncOptions(request.Category.Value);
            }
            else
            {
                var dtoOptions = new DtoOptions
                {
                    Fields = new List <ItemFields>
                    {
                        ItemFields.SyncInfo
                    }
                };

                var dtos = request.ItemIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                           .Select(_libraryManager.GetItemById)
                           .Where(i => i != null)
                           .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions))
                           .ToList();

                result.Options = SyncHelper.GetSyncOptions(dtos);
            }

            return(ToOptimizedResult(result));
        }
Exemplo n.º 2
0
        public object Get(GetSyncDialogOptions request)
        {
            var result = new SyncDialogOptions();

            result.Targets = _syncManager.GetSyncTargets(request.UserId)
                             .ToList();

            if (!string.IsNullOrWhiteSpace(request.TargetId))
            {
                result.Targets = result.Targets
                                 .Where(i => string.Equals(i.Id, request.TargetId, StringComparison.OrdinalIgnoreCase))
                                 .ToList();

                result.QualityOptions = _syncManager
                                        .GetQualityOptions(request.TargetId)
                                        .ToList();

                result.ProfileOptions = _syncManager
                                        .GetProfileOptions(request.TargetId)
                                        .ToList();
            }

            if (request.Category.HasValue)
            {
                result.Options = SyncHelper.GetSyncOptions(request.Category.Value);
            }
            else
            {
                var dtoOptions = new DtoOptions
                {
                    Fields = new List <ItemFields>
                    {
                        ItemFields.SyncInfo
                    }
                };

                var auth = AuthorizationContext.GetAuthorizationInfo(Request);

                var authenticatedUser = _userManager.GetUserById(auth.UserId);

                var items = request.ItemIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                            .Select(_libraryManager.GetItemById)
                            .Where(i => i != null);

                var dtos = _dtoService.GetBaseItemDtos(items, dtoOptions, authenticatedUser)
                           .ToList();

                result.Options = SyncHelper.GetSyncOptions(dtos);
            }

            return(ToOptimizedResult(result));
        }