コード例 #1
0
            public async Task <Response> Handle(Request request)
            {
                var entity = await _context.HomePages
                             .Include(x => x.Tenant)
                             .SingleOrDefaultAsync(x => x.Tenant.UniqueId == request.TenantUniqueId);

                if (entity == null)
                {
                    var tenant = await _context.Tenants.SingleAsync(x => x.UniqueId == request.TenantUniqueId);

                    _context.HomePages.Add(entity = new HomePage()
                    {
                        TenantId = tenant.Id
                    });
                }

                entity.AvatarImageUrl = request.HomePage.AvatarImageUrl;
                entity.Name           = request.HomePage.Name;
                entity.Title          = request.HomePage.Title;
                await _context.SaveChangesAsync(request.Username);

                _cache.Remove(HomePagesCacheKeyFactory.Get(request.TenantUniqueId));

                return(new Response());
            }
コード例 #2
0
            public async Task <Response> Handle(Request request)
            {
                var homePage = await _cache.FromCacheOrServiceAsync(() => _context.HomePages
                                                                    .Include(x => x.Tenant)
                                                                    .SingleOrDefaultAsync(x => x.Tenant.UniqueId == request.TenantUniqueId),
                                                                    HomePagesCacheKeyFactory.Get(request.TenantUniqueId));

                return(new Response()
                {
                    HomePage = homePage == null ? null : HomePageApiModel.FromHomePage(homePage)
                });
            }