Esempio n. 1
0
        public void Get_students_filter_by_navigation_property_of_navigation_property()
        {
            IEnrollmentStore   store = serviceProvider.GetRequiredService <IEnrollmentStore>();
            ICollection <User> list  = Task.Run(() => store.GetAsync <User>(s => s.Residency.StatesLivedIn.Any(e => e.State == "GA"))).Result.ToList();

            Assert.True(list.Count == 1);
        }
Esempio n. 2
0
        public void Get_students_with_no_includes()
        {
            IEnrollmentStore   store = serviceProvider.GetRequiredService <IEnrollmentStore>();
            ICollection <User> list  = Task.Run(() => store.GetAsync <User>()).Result;

            Assert.Equal(2, list.Count);
            Assert.Null(list.First().Residency);
        }
Esempio n. 3
0
        public void Get_students_inlude_navigation_property_of_navigation_property()
        {
            IEnrollmentStore   store = serviceProvider.GetRequiredService <IEnrollmentStore>();
            ICollection <User> list  = Task.Run(() => store.GetAsync <User>(s => s.Residency.StatesLivedIn.Count() > 0, null,
                                                                            new Func <IQueryable <User>, IIncludableQueryable <User, object> >[]
            {
                a => a.Include(x => x.Residency).ThenInclude(e => e.StatesLivedIn)
            })).Result.ToList();

            Assert.NotNull(list.First().Residency);
            Assert.NotNull(list.First().Residency.StatesLivedIn.First().State);
        }
 public EnrollmentRepository(IEnrollmentStore store, IMapper mapper) : base(store, mapper)
 {
 }
Esempio n. 5
0
        private static async Task Seed_Database(IEnrollmentStore store)
        {
            if ((await store.CountAsync <LookUps>()) > 0)
            {
                return;//database has been seeded
            }
            XmlDocument xDoc = Path.Combine(Directory.GetCurrentDirectory(), "DropDowns.xml").LoadXmlDocument();

            IList <LookUps> lookUps = xDoc.SelectNodes("//list")
                                      .OfType <XmlElement>()
                                      .SelectMany
                                      (
                e => e.ChildNodes.OfType <XmlElement>()
                .Where(c => c.Name == "item")
                .Select
                (
                    i => new LookUps
            {
                ListName    = e.Attributes["id"].Value,
                EntityState = LogicBuilder.Data.EntityStateType.Added,
                Value       = i.Attributes["name"].Value,
                Text        = i.Attributes["value"].Value,
                Order       = 0
            }
                )
                                      ).ToList();

            await store.SaveGraphsAsync <LookUps>(lookUps);

            User[] users = new User[]
            {
                new User
                {
                    UserName  = "******",
                    Residency = new Residency
                    {
                        CitizenshipStatus      = "US",
                        CountryOfCitizenship   = "US",
                        DriversLicenseNumber   = "NC12345",
                        DriversLicenseState    = "NC",
                        EntityState            = LogicBuilder.Data.EntityStateType.Added,
                        HasValidDriversLicense = true,
                        ImmigrationStatus      = "AA",
                        ResidentState          = "AR",
                        StatesLivedIn          = new List <StateLivedIn>
                        {
                            new StateLivedIn {
                                EntityState = LogicBuilder.Data.EntityStateType.Added, State = "OH"
                            },
                            new StateLivedIn {
                                EntityState = LogicBuilder.Data.EntityStateType.Added, State = "TN"
                            }
                        }
                    },
                    EntityState = LogicBuilder.Data.EntityStateType.Added
                },
                new User
                {
                    UserName  = "******",
                    Residency = new Residency
                    {
                        CitizenshipStatus      = "RA",
                        CountryOfCitizenship   = "AA",
                        DriversLicenseNumber   = "GA12345",
                        DriversLicenseState    = "DA",
                        EntityState            = LogicBuilder.Data.EntityStateType.Added,
                        HasValidDriversLicense = true,
                        ImmigrationStatus      = "BB",
                        ResidentState          = "AR",
                        StatesLivedIn          = new List <StateLivedIn>
                        {
                            new StateLivedIn {
                                EntityState = LogicBuilder.Data.EntityStateType.Added, State = "GA"
                            },
                            new StateLivedIn {
                                EntityState = LogicBuilder.Data.EntityStateType.Added, State = "TN"
                            }
                        }
                    },
                    EntityState = LogicBuilder.Data.EntityStateType.Added
                }
            };

            await store.SaveGraphsAsync <User>(users);
        }