public void SaveConversation() { try { var options = CreateNewContextOptions(); using (var db = new ConversationContext(options)) { ConversationTestHelper.PopulateDefaultDataCtx(db); } using (var db = new ConversationContext(options)) { var repository = new ConversationRepository(db);; var item = GenerateModel(); Assert.DoesNotThrow(() => repository.Save(item)); Assert.DoesNotThrow(() => repository.Delete(item)); Assert.Greater(item.Id, 0); } } catch (Exception ex) { LogEventManager.Logger.Error(ex); throw; } }
public void Delete2() { try { var options = CreateNewContextOptions(); using (var db = new ConversationContext(options)) { ConversationTestHelper.PopulateDefaultDataCtx(db); } using (var db = new ConversationContext(options)) { var repository = new ConversationRepository(db); var item = GenerateModel(); var mess = GenerateMessage(); var members = new List <User> { new User { Id = 1 }, new User { Id = 2 } }; Assert.DoesNotThrow(() => repository.StartConversation(item, members, mess, members.First().Id)); Assert.DoesNotThrow(() => repository.Delete(item)); } } catch (Exception ex) { LogEventManager.Logger.Error(ex); throw; } }
/// <summary> /// Deletes an object with the specified resref from the database. /// </summary> /// <param name="resref">The resource reference to search for.</param> /// <param name="resourceType">The type of resource to remove.</param> /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param> public void DeleteFromDatabase(int resourceID, GameObjectTypeEnum resourceType, string connectionString = "") { if (resourceType == GameObjectTypeEnum.Area) { using (AreaRepository repo = new AreaRepository(connectionString)) { repo.Delete(resourceID); } } else if (resourceType == GameObjectTypeEnum.Conversation) { using (ConversationRepository repo = new ConversationRepository(connectionString)) { repo.Delete(resourceID); } } else if (resourceType == GameObjectTypeEnum.Creature) { using (CreatureRepository repo = new CreatureRepository(connectionString)) { repo.Delete(resourceID); } } else if (resourceType == GameObjectTypeEnum.Item) { using (ItemRepository repo = new ItemRepository(connectionString)) { repo.Delete(resourceID); } } else if (resourceType == GameObjectTypeEnum.Placeable) { using (PlaceableRepository repo = new PlaceableRepository(connectionString)) { repo.Delete(resourceID); } } else if (resourceType == GameObjectTypeEnum.Script) { using (ScriptRepository repo = new ScriptRepository(connectionString)) { repo.Delete(resourceID); } } else if (resourceType == GameObjectTypeEnum.Tileset) { using (TilesetRepository repo = new TilesetRepository(connectionString)) { repo.Delete(resourceID); } } else if (resourceType == GameObjectTypeEnum.GameModule) { using (GameModuleRepository repo = new GameModuleRepository()) { repo.Delete(resourceID); } } else { throw new NotSupportedException(); } }