Skip to content

Instantly share code, notes, and snippets.

@TRex22
Created October 3, 2015 01:28
Show Gist options
  • Save TRex22/bc006c4e3fa53780a965 to your computer and use it in GitHub Desktop.
Save TRex22/bc006c4e3fa53780a965 to your computer and use it in GitHub Desktop.
public async void DoLogic()
{
BsonDocument document;
Console.WriteLine("This program will generate some data when option A is selected.");
Console.WriteLine("Option B will find some data.");
Console.WriteLine("Option C (any other input) will display data from database.");
var input = Console.ReadLine();
Random rnd = new Random ();
double price = 0;
price = rnd.NextDouble () * (1000.00 - 0.00) + 0.00;
if (input.Equals("A"))
{
document = new BsonDocument
{
{ "name", "Hot dog"},
{ "price", price },
};
string outcome = await CreateDocument ("book", document);
Console.WriteLine(outcome);
}
else if (input.Equals("B"))
{
document = await SearchFirstDocumentResult("book", "name", "Hotdog");
Console.WriteLine(document.ToString() + "\n\n");
Console.Read();
}
else
{
List<BsonDocument> documents = await GetData("book");
foreach (var doc in documents)
{
Console.WriteLine(doc.ToString() + "\n\n");
}
Console.Read();
}
//wait
Console.ReadLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment