private static void HardcodePut() { AerospikeWriteClient w = new AerospikeWriteClient(); w.Put(new Card() { Id = 1, FrontSide = "Cog", BackSide = "Зубец" }); w.Put(new Card() { Id = 2, FrontSide = "Cab", BackSide = "Такси" }); w.Put(new Card() { Id = 3, FrontSide = "Can", BackSide = "Банка" }); w.Put(new Card() { Id = 4, FrontSide = "Cop", BackSide = "Полицейский" }); w.Put(new Collection() { Id = 0, Name = "Default", Description = "Basic collection", Cards = new List <int>() { 2, 4 } }); w.Put(new Collection() { Id = 1, Name = "New", Description = "Second collection", Cards = new List <int>() { 1, 3 } }); w.Put(new User() { Id = 0, Login = "******", Email = "[email protected]", PasswordHash = "fwejnf", Collections = new List <int>() { 0, 1 } }); w.Put(new User() { Id = 1, Login = "******", Email = "[email protected]", PasswordHash = "fddgf", Collections = new List <int>() { 0 } }); }
public User PutUser(User user) { try { using var writeClient = new AerospikeWriteClient(); writeClient.Put(user); return(user); } catch (DatabaseException e) { throw new GraphQlException(e.Message); } }
public Card PutCard(Card card, int collectionId) { try { using var writeClient = new AerospikeWriteClient(); writeClient.Put(card); writeClient.AddCardToCollection(collectionId, card.Id); return(card); } catch (DatabaseException e) { throw new GraphQlException(e.Message); } }
public Collection PutCollection(Collection collection, int ownerId) { try { using var writeClient = new AerospikeWriteClient(); writeClient.Put(collection); writeClient.AddCollectionToUser(ownerId, collection.Id); return(collection); } catch (DatabaseException e) { if (e.InnerException is AlreadyExistsException) { throw new GraphQlException("Collection already exists. " + e.Message); } throw new GraphQlException(e.Message); } }