Esempio n. 1
0
 public IEnumerable <OrganizationSummaryModel> Handle(OrganizationListQuery message)
 {
     return(_context.Organizations.Select(t => new OrganizationSummaryModel {
         Id = t.Id,
         LogoUrl = t.LogoUrl,
         Name = t.Name,
         WebUrl = t.WebUrl
     }));
 }
Esempio n. 2
0
 public async Task <List <OrganizationSummaryViewModel> > Handle(OrganizationListQuery message)
 {
     return(await _context.Organizations.Select(t => new OrganizationSummaryViewModel
     {
         Id = t.Id,
         LogoUrl = t.LogoUrl,
         Name = t.Name,
         WebUrl = t.WebUrl
     })
            .ToListAsync());
 }
        public async Task ReturnAllOrganizationsAsOrganizationSummaryModels()
        {
            var message = new OrganizationListQuery();

            var organizations = new[]
            {
                new Organization { Id = 1, LogoUrl = "LogoUrl1", Name = "Organization1", WebUrl = "WebUrl1" },
                new Organization { Id = 2, LogoUrl = "LogoUrl2", Name = "Organization2", WebUrl = "WebUrl2" }
            };

            var context = Context;
            context.Organizations.AddRange(organizations);
            context.SaveChanges();

            var sut = new OrganizationListQueryHandler(context);
            var result = await sut.Handle(message);

            Assert.IsType<List<OrganizationSummaryViewModel>>(result);
        }
        public async Task ReturnAllOrganizationsAsOrganizationSummaryModels()
        {
            var message = new OrganizationListQuery();

            var organizations = new[]
            {
                new Organization {
                    Id = 1, LogoUrl = "LogoUrl1", Name = "Organization1", WebUrl = "WebUrl1"
                },
                new Organization {
                    Id = 2, LogoUrl = "LogoUrl2", Name = "Organization2", WebUrl = "WebUrl2"
                }
            };

            var context = Context;

            context.Organizations.AddRange(organizations);
            context.SaveChanges();

            var sut    = new OrganizationListQueryHandler(context);
            var result = await sut.Handle(message);

            Assert.IsType <List <OrganizationSummaryViewModel> >(result);
        }