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); } }
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); }
public void InsertOne() { _collection.InsertOne(new User { Name = "Teddy" }); }
public void Create(T item) { _collection.InsertOne(item); }
public void AddNewUser(User user) { _collection.InsertOne(user); }
/// <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); }