Ejemplo n.º 1
0
        public static void Seed(Database context)
        {
            context.RoleVolunteers.AddOrUpdate(
                new RoleVolunteer
                {
                    RoleID = (int) RoleID.Volunteer,
                    VolunteerUsername = "******"
                }
            );

            context.RoleVolunteers.AddOrUpdate(
                new RoleVolunteer
                {
                    RoleID = (int)RoleID.Volunteer,
                    VolunteerUsername = "******"
                }
            );

            context.RoleVolunteers.AddOrUpdate(
                new RoleVolunteer
                {
                    RoleID = (int)RoleID.Admin,
                    VolunteerUsername = "******"
                }
            );

            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static Patron GetRandomPatron(Database context)
        {
            var namesSize = Names.Length;
            var maritalStatuses = Enums.GetMaritalStatuses(context);
            var residenceStatuses = Enums.GetResidenceStatuses(context);
            var genderStatuses = Enums.GetGenders(context);
            var ethnicityStatuses = Enums.GetEthnicities(context);

            return new Patron
            {
                FirstName = Names[Random.Next(namesSize)],
                MiddleName = Names[Random.Next(namesSize)],
                LastName = Names[Random.Next(namesSize)],
                DateOfBirth = new DateTime(Random.Next(1970, 2015), Random.Next(1, 12), Random.Next(1, 28)),
                MaritalStatus = maritalStatuses[Random.Next(maritalStatuses.Length)],
                ResidenceStatus = residenceStatuses[Random.Next(residenceStatuses.Length)],
                Gender = genderStatuses[Random.Next(genderStatuses.Length)],
                Ethnicity = ethnicityStatuses[Random.Next(ethnicityStatuses.Length)],
                Addresses = new AddressGenerator(Random.Next(1, 5), Random).ToArray(),
                HouseholdOccupants = (short) Random.Next(1, 10),
                Veteran = Random.Next(0, 2) < 0.5,
                PhoneNumbers = new PhoneNumberGenerator(Random),
                EmergencyContacts = new EmergencyContactGenerator(Random)
            };
        }
Ejemplo n.º 3
0
        public static Visit[] GetRandomVisits(int number, Database context)
        {
            var patrons = new List<Visit>();
            for (int i = 0; i < number; i++)
            {
                patrons.Add(CreateRandomVisit(context));
            }

            return patrons.ToArray();
        }
Ejemplo n.º 4
0
        public static Patron[] GetRandomPatrons(int number, Database context)
        {
            var patrons = new List<Patron>();
            for (int i = 0; i < number; i++)
            {
                patrons.Add(GetRandomPatron(context));
            }

            return patrons.ToArray();
        }
Ejemplo n.º 5
0
 public static Visit CreateRandomVisit(Database context)
 {
     var randomServiceTypeID = Random.Next(1, context.ServiceTypes.Count());
     var randomPatronID = Random.Next(1, context.Patrons.Count());
     return new Visit
     {
         Patron = context.Patrons.FirstOrDefault(p => p.ID == randomPatronID),
         Service = context.ServiceTypes.FirstOrDefault(st => st.ID == randomServiceTypeID),
         CreateVolunteer = context.Volunteers.FirstOrDefault(v => v.Username == TestVolunteers.testAdmin.Username)
     };
 }
Ejemplo n.º 6
0
 public static void Seed(Database context, int number = 1)
 {
     context.Visits.AddRange(GetRandomVisits(number, context));
     context.SaveChanges();
 }