public Customers(IEnumerable <Person> persons,
                  IEnumerable <Organization> organizations)
     : this()
 {
     Persons.AddRange(persons);
     Organizations.AddRange(organizations);
 }
Esempio n. 2
0
        private void ImportPersons(ImportPayload payload)
        {
            var fileHandler    = _fileHandlerFactory.Create(payload.Filename, payload.FileType);
            var persons        = fileHandler.ReadFile();
            var newPersonItems = from person in persons select new PersonItem(person);

            Persons.AddRange(newPersonItems);
        }
Esempio n. 3
0
        public Family(IEnumerable <Person> persons, IEnumerable <SpendingStep> spendingStepInputs)
        {
            if (persons.Count(p => p.Children.Count > 0) > 1)
            {
                throw new Exception("A Family can only have 1 child benefit claim.");
            }

            SpendingStepInputs = spendingStepInputs;
            Persons.AddRange(persons);
        }
Esempio n. 4
0
 public People(People other) : base(other)
 {
     if (null == other.Persons)
     {
         Persons = null;
     }
     else
     {
         Persons.AddRange(other.Persons);
     }
 }
Esempio n. 5
0
        public Task2() : base()
        {
            var items = new Person[] {
                new Person {
                    Age = 30, Name = "Misha", PhoneNumbers = new[] { "07334532123", "07334323423", "07334532344" }
                },
                new Person {
                    Age = 57, Name = "Edik", PhoneNumbers = new[] { "05034532123", "05034323423", "05034532344" }
                }
            };

            Persons.AddRange(items);
        }
Esempio n. 6
0
        public void GetAll_SendRequest_ReplaceDatabaseContext_ShouldReturnOk()
        {
            const int expectedId    = 1;
            const int expectedCount = 3;
            WebApplicationFactory <Startup> webHost = new WebApplicationFactory <Startup>()
                                                      .WithWebHostBuilder(builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                    var descriptor = services
                                     .SingleOrDefault(_ => _.ServiceType == typeof(DbContextOptions <Application1Context>));
                    services.Remove(descriptor);
                    services.AddDbContext <Application1Context>(options =>
                    {
                        options.UseInMemoryDatabase(nameof(Application1Context));
                    });
                    var descriptorInitializer = services
                                                .SingleOrDefault(_ => _.ServiceType == typeof(WebStoreDBInitializer));
                    services.Remove(descriptorInitializer);
                    services.AddTransient(_ => Mock.Of <WebStoreDBInitializer>());
                });
            });
            var testContext = webHost
                              .Services.CreateScope().ServiceProvider.GetService <Application1Context>();

            testContext !.Persons.AddRange(
                Enumerable.Range(1, expectedCount).Select(i => new Person
            {
                LastName   = $"Ivanov_{i}",
                FirstName  = $"Ivan_{i}",
                Patronymic = $"Ivanovich_{i}",
            }));
            testContext !.SaveChanges();
            HttpClient httpClient = webHost.CreateClient();

            var response = httpClient.GetAsync("api/persons").Result;

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            var persons = response.Content.ReadFromJsonAsync(typeof(IEnumerable <Person>)).Result;

            Assert.IsInstanceOfType(persons, typeof(IEnumerable <Person>));
            var personsList = (IEnumerable <Person>)persons;

            Assert.AreEqual(expectedId, personsList.FirstOrDefault().Id);
            Assert.AreEqual(expectedCount, personsList.Count());
        }
Esempio n. 7
0
        private void OnOpenFile()
        {
            var openFileDialog = new OpenFileDialog()
            {
                Title            = "Datei öffnen",
                Filter           = "Json |*.json|Alle Dateien|*.*",
                FilterIndex      = 0,
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };

            if (openFileDialog.ShowDialog(App.Current.MainWindow) != true)
            {
                return;
            }

            fileName = openFileDialog.FileName;

            try
            {
                Persons.Clear();

                var items = JsonSerializer.Deserialize <Person[]>(File.ReadAllText(fileName, Encoding.UTF8));

                if (items != null && items.Any())
                {
                    Persons.AddRange(items);

                    if (Persons.Any())
                    {
                        SelectedPerson = Persons[0];
                    }
                }

                ApplyTitle(fileName);
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Categorize properties of page to Infobox, Citation, Geobox
        /// </summary>
        /// <param name="pages">List of pages</param>
        private static void CategorizeProperties(List <Page> pages)
        {
            foreach (var page in pages)
            {
                foreach (var item in page.Infoboxes)
                {
                    var type = item.GetType();
                    item.SetRegexAttributes();

                    if (type == typeof(Infobox))
                    {
                        var info = item as Infobox;
                        Locations.AddRange(GetNamedEntities(info, NamedEntityType.Location));
                        Persons.AddRange(GetNamedEntities(info, NamedEntityType.Person));
                        Organizations.AddRange(GetNamedEntities(info, NamedEntityType.Organization));
                        Infoboxes.Add(info);
                    }
                    else if (type == typeof(Citation))
                    {
                        var cit = item as Citation;
                        cit.AddFullNames();

                        Locations.AddRange(GetNamedEntities(cit, NamedEntityType.Location));
                        Persons.AddRange(GetNamedEntities(cit, NamedEntityType.Person));
                        Organizations.AddRange(GetNamedEntities(cit, NamedEntityType.Organization));
                        Citations.Add(cit);
                    }
                    else if (type == typeof(Geobox))
                    {
                        var geo = item as Geobox;

                        Locations.AddRange(GetNamedEntities(geo, NamedEntityType.Location));
                        Persons.AddRange(GetNamedEntities(geo, NamedEntityType.Person));
                        Geoboxes.Add(geo);
                    }
                }
            }
        }
        public PersonsContext()
        {
            // добавляем строки для первоначальной заполненности

            if (Persons.Count() != 0)
            {
                return;
            }
            Persons.AddRange(
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "Михаил Борисович",
                Email    = "*****@*****.**"
            },
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "Борис Анатольевич",
                Email    = "*****@*****.**"
            },
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "Наташа",
                Email    = "*****@*****.**"
            },
                new Person()
            {
                Login    = "******",
                Password = "******",
                Name     = "admin",
                Email    = "*****@*****.**"
            });

            Roles.AddRange(
                new Role()
            {
                Name = "Администратор"
            },
                new Role()
            {
                Name = "Заказчик"
            },
                new Role()
            {
                Name = "Специалист отдела кадров"
            },
                new Role()
            {
                Name = "Бухгалтер"
            });

            SaveChanges();

            PersonsRoles.AddRange(
                new PersonsRoles()
            {
                PersonId = 1,
                RoleId   = 1,
            },
                new PersonsRoles()
            {
                PersonId = 2,
                RoleId   = 2,
            },
                new PersonsRoles()
            {
                PersonId = 3,
                RoleId   = 3,
            },
                new PersonsRoles()
            {
                PersonId = 3,
                RoleId   = 4,
            },
                new PersonsRoles()
            {
                PersonId = 4,
                RoleId   = 1,
            });

            SaveChanges();
        }
Esempio n. 10
0
        private void BaseData()
        {
            Stats.Add(new BuildingStats()
            {
                Account        = 20,
                StartTime      = DateTime.UtcNow,
                SimulationTime = new DateTime(2016, 1, 1, 8, 0, 0),
                PlayTime       = 0d,
                Speed          = 120,
                Persons        = 0
            });

            AccountRows.Add(new AccountRow()
            {
                Subject = "Starting funds",
                Value   = 20
            });

            var wFloor = new Floor()
            {
                Level  = 0,
                Left   = 6,
                Top    = 6,
                Width  = 4,
                Height = 8
            };

            wFloor.Rooms.Add(new Room()
            {
                Left    = 0,
                Top     = 0,
                Width   = 4,
                Height  = 4,
                Name    = "Elevator",
                FloorId = 1
            });

            for (var y = 4; y < 8; y++)
            {
                for (var x = 0; x < 4; x++)
                {
                    wFloor.Rooms.Add(new Room()
                    {
                        Left    = x,
                        Top     = y,
                        Width   = 1,
                        Height  = 1,
                        Name    = "Floor",
                        FloorId = 1
                    });
                }
            }

            Floors.Add(wFloor);

            wFloor = new Floor()
            {
                Level  = 1,
                Width  = 16,
                Height = 16
            };

            wFloor.Rooms.Add(new Room()
            {
                Left    = 6,
                Top     = 6,
                Width   = 4,
                Height  = 4,
                Name    = "Elevator",
                FloorId = 2
            });

            Floors.Add(wFloor);

            var wCommon        = new CommonRepository();
            var wCommonPersons = wCommon.GetPersons();

            if (wCommonPersons.Any())
            {
                var wPersons = wCommonPersons.Select(EmitMapper.Map <Person, Person>).ToArray();

                var wAvailables = new HashSet <int>();

                var wRnd = new Random();

                for (var i = 0; i < wPersons.Length; i++)
                {
                    wPersons[i].State = PersonState.NotAvailable;
                }
                while (wAvailables.Count < 15 && wAvailables.Count < wPersons.Length)
                {
                    var wIndex = wRnd.Next(wPersons.Length);
                    if (wAvailables.Add(wIndex))
                    {
                        wPersons[wIndex].State = PersonState.Available;
                    }
                }

                Persons.AddRange(wPersons);
            }
            else
            {
                for (var i = 0; i < 15; i++)
                {
                    Persons.Add(PersonHelper.GetRandomPerson(PersonState.Available));
                }
                for (var i = 0; i < 95; i++)
                {
                    Persons.Add(PersonHelper.GetRandomPerson(PersonState.NotAvailable));
                }
            }
        }