Esempio n. 1
0
        internal static bool AddRestaurant(Restaurant resto)
        {
            var restaurant = GetRestaurantByName(resto.Name, resto.Lat, resto.Long);

            if (restaurant == null)
            {
                return(restaurantCollection.InsertOne(resto));
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public FileMetadata Add(string path, Stream data, FileType type)
        {
            var hash = data.ComputeSHA2Hash();
            var meta = new FileMetadata(Path.GetFileName(path), hash, type);

            if (!Storage.Exists(hash))
            {
                using (var stream = Storage.GetStream(hash + Path.GetExtension(path), FileAccess.Write))
                    data.CopyTo(stream);

                Context.InsertOne(meta);
            }

            data.Dispose();
            return(meta);
        }
Esempio n. 3
0
 public void InsertOne()
 {
     _collection.InsertOne(new User {
         Name = "Teddy"
     });
 }
Esempio n. 4
0
 public void Create(T item)
 {
     _collection.InsertOne(item);
 }
Esempio n. 5
0
 public void AddNewUser(User user)
 {
     _collection.InsertOne(user);
 }
Esempio n. 6
0
 /// <summary>
 /// Adds the given book and updates the data file
 /// </summary>
 /// <param name="book">Book object which will be added</param>
 public Book AddBook(Book book)
 {
     book.Id = globalLastId++;
     collection.InsertOne(book);
     return(book);
 }