コード例 #1
0
 public void Add(PhoneType item)
 {
     if (item != null)
     {
         Entities.Add(item);
         _context.SaveChanges();
     }
 }
コード例 #2
0
 public void Add(PrivilegesGroup item)
 {
     if (item != null)
     {
         Entities.Add(item);
         _context.SaveChanges();
     }
 }
コード例 #3
0
 public void Add(User item)
 {
     if (item != null)
     {
         Entities.Add(item);
         _context.SaveChanges();
     }
 }
コード例 #4
0
            public static List <Privilege> SetupData(ZeraLeviContext ctx, int count)
            {
                var privilegeGroup      = GenFu.GenFu.New <PrivilegesGroup>();
                var privileges          = new List <Privilege>();
                var generatedPrivileges = GenFu.GenFu.ListOf <Privilege>(count);

                foreach (var gP in generatedPrivileges)
                {
                    if (privileges.Find(p => p.Name.Equals(gP.Name, StringComparison.CurrentCultureIgnoreCase)) == null)
                    {
                        privileges.Add(gP);
                    }
                }

                while (privileges.Count < count)
                {
                    generatedPrivileges = GenFu.GenFu.ListOf <Privilege>(count);

                    foreach (var gP in generatedPrivileges)
                    {
                        if (privileges.Find(p => p.Name.Equals(gP.Name, StringComparison.CurrentCultureIgnoreCase)) == null)
                        {
                            privileges.Add(gP);
                        }
                    }
                }

                privilegeGroup.Privileges = privileges.Take(count).ToList();
                ctx.PrivilegesGroups.Add(privilegeGroup);

                ctx.SaveChanges();

                return(privilegeGroup.Privileges.ToList());
            }
コード例 #5
0
            public static Person SetupData(ZeraLeviContext ctx)
            {
                var person = GenFuSetup(1, Enumerable.Empty <string>()).First();

                ctx.People.Add(person);
                ctx.SaveChanges();

                return(person);
            }
コード例 #6
0
            public static List <PrivilegesGroup> SetupData(ZeraLeviContext ctx, int count)
            {
                var items = GenFuSetup(count);

                ctx.PrivilegesGroups.AddRange(items);
                ctx.SaveChanges();

                return(items);
            }
コード例 #7
0
            public static PrivilegesGroup SetupData(ZeraLeviContext ctx)
            {
                var item = GenFuSetup(1).First();

                ctx.PrivilegesGroups.Add(item);
                ctx.SaveChanges();

                return(item);
            }
コード例 #8
0
            public static List <PhoneType> SetupData(ZeraLeviContext ctx, int count)
            {
                var items = GenFuSetup(count, Enumerable.Empty <string>());

                ctx.PhoneTypes.AddRange(items);
                ctx.SaveChanges();

                return(items);
            }
コード例 #9
0
            public static PhoneType SetupData(ZeraLeviContext ctx)
            {
                var phoneType = GenFuSetup(1, Enumerable.Empty <string>()).First();

                ctx.PhoneTypes.Add(phoneType);
                ctx.SaveChanges();

                return(phoneType);
            }
コード例 #10
0
            public static User SetupData(ZeraLeviContext ctx)
            {
                var user = GenFuSetup(1, Enumerable.Empty <string>(), Enumerable.Empty <Privilege>()).First();

                ctx.Users.Add(user);
                ctx.SaveChanges();

                return(user);
            }
コード例 #11
0
            public static List <User> SetupData(ZeraLeviContext ctx, int count)
            {
                var users = GenFuSetup(count, Enumerable.Empty <string>(), Enumerable.Empty <Privilege>());

                ctx.Users.AddRange(users);
                ctx.SaveChanges();

                return(users);
            }
コード例 #12
0
            public static List <Person> SetupData(ZeraLeviContext ctx, int count)
            {
                var people = GenFuSetup(count, Enumerable.Empty <string>());

                ctx.People.AddRange(people);
                ctx.SaveChanges();

                return(people);
            }
コード例 #13
0
            public static PhoneNumber SetupData(ZeraLeviContext ctx)
            {
                GenFuSetup();
                var person = GenFu.GenFu.New <Person>();

                person.PhoneNumbers = GenFu.GenFu.ListOf <PhoneNumber>(1);
                ctx.People.Add(person);

                ctx.SaveChanges();

                return(person.PhoneNumbers.First());
            }
コード例 #14
0
            public static Donation SetupData(ZeraLeviContext ctx)
            {
                var person = GenFu.GenFu.New <Person>();

                person.Account           = GenFu.GenFu.New <Account>();
                person.Account.Donations = GenFu.GenFu.ListOf <Donation>();
                ctx.People.Add(person);

                ctx.SaveChanges();

                return(person.Account.Donations.First());
            }
コード例 #15
0
            public static List <Yahrtzieht> SetupData(ZeraLeviContext ctx, int count)
            {
                var people = GenFu.GenFu.ListOf <Person>(count);
                var items  = new List <Yahrtzieht>();

                foreach (var person in people)
                {
                    var yahrtziehts = GenFu.GenFu.ListOf <Yahrtzieht>(count);
                    person.Yahrtziehts = yahrtziehts;
                    items.AddRange(yahrtziehts);
                }

                ctx.People.AddRange(people);
                ctx.SaveChanges();

                return(items);
            }
コード例 #16
0
            public static List <Account> SetupData(ZeraLeviContext ctx, int count)
            {
                var people   = GenFu.GenFu.ListOf <Person>(count);
                var accounts = new List <Account>();

                foreach (var person in people)
                {
                    var account = GenFu.GenFu.New <Account>();
                    person.Account = account;
                    accounts.Add(account);
                }

                ctx.People.AddRange(people);
                ctx.SaveChanges();

                return(accounts);
            }
コード例 #17
0
            public static List <PhoneNumber> SetupData(ZeraLeviContext ctx, int count)
            {
                GenFuSetup();
                var people       = GenFu.GenFu.ListOf <Person>(count);
                var phoneNumbers = new List <PhoneNumber>();

                foreach (var person in people)
                {
                    var phoneNumber = GenFu.GenFu.ListOf <PhoneNumber>();
                    person.PhoneNumbers = phoneNumber;
                    phoneNumbers.AddRange(phoneNumber);
                }

                ctx.People.AddRange(people);
                ctx.SaveChanges();

                return(phoneNumbers);
            }
コード例 #18
0
            public static List <Donation> SetupData(ZeraLeviContext ctx, int count)
            {
                var people       = GenFu.GenFu.ListOf <Person>(count);
                var allDonations = new List <Donation>();

                foreach (var person in people)
                {
                    person.Account = GenFu.GenFu.New <Account>();

                    var donations = GenFu.GenFu.ListOf <Donation>(count);
                    person.Account.Donations = donations;
                    allDonations.AddRange(donations);
                }

                ctx.People.AddRange(people);
                ctx.SaveChanges();

                return(allDonations);
            }