Exemplo n.º 1
0
            public async Task <Response> Handle(Request request)
            {
                var digitalAsset = await _context.DigitalAssets
                                   .Include(x => x.Tenant)
                                   .SingleAsync(x => x.Id == request.Id && x.Tenant.UniqueId == request.TenantUniqueId);

                digitalAsset.IsDeleted = true;

                await _context.SaveChangesAsync(request.Username);

                _cache.Remove(DigitalAssetsCacheKeyFactory.Get(request.TenantUniqueId));
                _cache.Remove(DigitalAssetsCacheKeyFactory.GetByUniqueId(request.TenantUniqueId, $"{digitalAsset.UniqueId}"));

                return(new Response());
            }
            public async Task <Response> Handle(Request request)
            {
                if (string.IsNullOrEmpty(request.OAuthToken))
                {
                    return new Response()
                           {
                               DigitalAsset = DigitalAssetApiModel.FromDigitalAsset(await _cache.FromCacheOrServiceAsync <DigitalAsset>(() => _context
                                                                                                                                        .DigitalAssets
                                                                                                                                        .Include(x => x.Tenant)
                                                                                                                                        .SingleAsync(x => x.UniqueId.ToString() == request.UniqueId && x.IsSecure == false), DigitalAssetsCacheKeyFactory.GetByUniqueId(request.TenantUniqueId, request.UniqueId)))
                           }
                }
                ;

                return(new Response()
                {
                    DigitalAsset = DigitalAssetApiModel.FromDigitalAsset(await _context
                                                                         .DigitalAssets
                                                                         .Include(x => x.Tenant)
                                                                         .SingleAsync(x => x.UniqueId.ToString() == request.UniqueId && x.Tenant.UniqueId == request.TenantUniqueId))
                });
            }