예제 #1
0
        private void CreateItemsFromList(
            List <Tuple <string, string> > ItemsAndOwners, List <Publisher> publishers, Type itemType)
        {
            var rand = new Random();

            foreach (var tuple in ItemsAndOwners)
            {
                ISBN isbn     = GUIUtils.GenerateISBN();
                var  category = GUIUtils.GetRandomCategory();

                LibraryItem item;

                if (itemType == typeof(Book))
                {
                    item = EntitiesManager.Add(new Book(isbn, tuple.Item1, category, tuple.Item2));
                }
                else
                {
                    item = EntitiesManager.Add(new Journal(isbn, tuple.Item1, category, tuple.Item2));
                }

                int numberofCopies = rand.Next(1, 10);
                for (int j = 0; j < numberofCopies; j++)
                {
                    item.AddCopy();
                }

                item.SubCategory     = GUIUtils.GetRandomSubCategory(category);
                item.Publisher       = publishers[rand.Next(0, publishers.Count)];
                item.PrintDate       = GUIUtils.GetRandomDate(5);
                item.GraphicDesigner = $"{GUIUtils.GetRandomFirstName()} {GUIUtils.GetRandomLastName()}";

                // Update storage
                item.Update();
            }
        }
예제 #2
0
 public void Add(Entity entity)
 {
     _entities.Add(entity);
 }