示例#1
0
        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
                }
            });
        }
示例#2
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);
     }
 }
示例#3
0
 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);
     }
 }
示例#4
0
 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);
     }
 }