public void CreateItems() { int COUNT = 50; CatfishDbContext db = new CatfishDbContext(); List <CFEntityType> itemTypes = db.EntityTypes.Where(t => t.TargetTypes.Contains(CFEntityType.eTarget.Items.ToString())).ToList(); //db.EntityTypes.Where(t => t.TargetType == EntityType.eTarget.Items).ToList(); if (itemTypes.Count == 0) { throw new Exception("No entity types have been defined for collections."); } var rand = new Random(); ItemService srv = new ItemService(db); for (int i = 0; i < COUNT; ++i) { CFEntityType cType = itemTypes[rand.Next(0, itemTypes.Count)]; CFItem c = srv.CreateEntity <CFItem>(cType.Id); string name = TestData.LoremIpsum(5, 10); c.SetDescription(TestData.LoremIpsum(20, 100, 1, 10)); c.SetName("Item: " + name); c.Serialize(); db.Items.Add(c); } db.SaveChanges(); }
private CFItem CreateItem(ItemService itemSrv, int entityTypeId, string name, string description, bool store = false) { CFItem i = itemSrv.CreateItem(entityTypeId); i.SetName(name); i.SetDescription(description); if (store) { i = itemSrv.UpdateStoredItem(i); } return(i); }
private void CreateItems() { List <int> ets = Ets.GetEntityTypes().ToArray().Where(et => et.TargetTypesList.Contains(eTarget.Items)).Select(et => et.Id).ToList(); for (int i = 0; i < TOTAL_ITEMS; ++i) { int index = i % ets.Count; CFItem e = Is.CreateEntity <CFItem>(ets[index]); e.SetName("Item " + (i + 1)); e.SetDescription("Description for Item " + (i + 1)); Is.UpdateStoredItem(e); } Db.SaveChanges(); }