Exemple #1
0
        private static void HardCodeDelete()
        {
            AerospikeWriteClient c = new AerospikeWriteClient();

            c.Delete(Entities.Card, 4);
            c.Delete(Entities.Collection, 4444);
        }
Exemple #2
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
                }
            });
        }
Exemple #3
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);
     }
 }
Exemple #4
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);
     }
 }
Exemple #5
0
 public Collection DeleteCollection(int id)
 {
     try
     {
         using var queryClient = new AerospikeQueryClient();
         using var writeClient = new AerospikeWriteClient();
         var collection = queryClient.GetCollectionInfo(id);
         writeClient.Delete(Entities.Collection, id);
         return(collection);
     }
     catch (DatabaseException e)
     {
         throw new GraphQlException(e.Message);
     }
 }
Exemple #6
0
 public Card DeleteCard(int id)
 {
     try
     {
         using var queryClient = new AerospikeQueryClient();
         using var writeClient = new AerospikeWriteClient();
         var card = queryClient.GetCard(id);
         writeClient.Delete(Entities.Card, id);
         return(card);
     }
     catch (DatabaseException e)
     {
         throw new GraphQlException(e.Message);
     }
 }
Exemple #7
0
 public User DeleteUser(int id)
 {
     try
     {
         using var queryClient = new AerospikeQueryClient();
         using var writeClient = new AerospikeWriteClient();
         var user = queryClient.GetUserInfo(id);
         writeClient.Delete(Entities.User, id);
         return(user);
     }
     catch (DatabaseException e)
     {
         throw new GraphQlException(e.Message);
     }
 }
Exemple #8
0
        private static void HardCodeUpdate()
        {
            AerospikeWriteClient w = new AerospikeWriteClient();
            Card r = new Card()
            {
                BackSide = "Американский полицейский"
            };

            w.Update(r, 4);
            User u = new User()
            {
                Email = "[email protected]"
            };

            w.Update(u, 1);
        }
Exemple #9
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);
     }
 }
Exemple #10
0
 public CollectionInfo UpdateCollection(CollectionInfo collection, int id)
 {
     try
     {
         using var writeClient = new AerospikeWriteClient();
         Collection u = new Collection()
         {
             Name        = collection.Name,
             Description = collection.Description
         };
         writeClient.Update(u, id);
         return(collection);
     }
     catch (DatabaseException e)
     {
         throw new GraphQlException(e.Message);
     }
 }
Exemple #11
0
 public CardInfo UpdateCard(CardInfo card, int id)
 {
     try
     {
         using var writeClient = new AerospikeWriteClient();
         Card u = new Card()
         {
             FrontSide = card.FrontSide,
             BackSide  = card.BackSide
         };
         writeClient.Update(u, id);
         return(card);
     }
     catch (DatabaseException e)
     {
         throw new GraphQlException(e.Message);
     }
 }
Exemple #12
0
 public UserInfo UpdateUser(UserInfo user, int id)
 {
     try
     {
         using var writeClient = new AerospikeWriteClient();
         User u = new User()
         {
             Login = user.Login,
             Email = user.Email
         };
         writeClient.Update(u, id);
         return(user);
     }
     catch (DatabaseException e)
     {
         throw new GraphQlException(e.Message);
     }
 }