Ejemplo 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);
            }
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
 public void InsertOne()
 {
     _collection.InsertOne(new User {
         Name = "Teddy"
     });
 }
Ejemplo n.º 4
0
 public void Create(T item)
 {
     _collection.InsertOne(item);
 }
Ejemplo n.º 5
0
 public void AddNewUser(User user)
 {
     _collection.InsertOne(user);
 }
Ejemplo 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);
 }