public IActionResult Get() { var recs = db.LoadRecords <Productor>("Productores"); var productores2 = new List <Productor2> { }; foreach (var productor in recs) { var productor2 = new Productor2 { cedula = productor.Cedula.ToString(), usuario = productor.Usuario, nombre = productor.Nombre, direccion = productor.direccion, dob = productor.dob, telefono = productor.telefono.ToString(), SINPE = productor.SINPE.ToString(), pass = productor.pass, aceptado = productor.aceptado, productos = productor.productos, pedidos = productor.pedidos }; productores2.Add(productor2); } return(Ok(productores2)); }
public vorhandeneNachbestellungenViewModel(string hv) { try { //connecting to database var crud = new MongoCRUD("avdb"); //get filtered records (filtered by Id which is "Hv": hv) var erg = crud.LoadRecords <Nachbestellung>("nachbestellungen", hv); //filtered List is an ObservableCollection which is updated with OnPropertyChanged method CollTop = new ObservableCollection <Nachbestellung>(erg); //same procedure for the articles collection.... //var arterg = crud.LoadRecords<Artikel>("bestellteArtikel", hv); CollBot = new ObservableCollection <Artikel>(); for (int i = 0; i < CollTop.Count; i++) { foreach (var a in CollTop[i].artikelliste) { CollBot.Add(a); } } //wenn Abfrageergebnis null ist, dann Messagebox-Info (Zu dieser Hv wurde keine Nachbestellung gefunden!) if (CollBot.Count <= 0) { MessageBox.Show("Zu dieser Hv wurde keine Nachbestellung gefunden!", "Keine Daten vorhanden!", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception e) { MessageBox.Show(e.Message); } }
public IActionResult Get() { var recs = db.LoadRecords <Cliente>("Clientes"); var clientes2 = new List <Cliente2> { }; foreach (var cliente in recs) { var cliente2 = new Cliente2 { Cedula = cliente.Cedula.ToString(), Usuario = cliente.Usuario, Nombre = cliente.Nombre, direccion = cliente.direccion, dob = cliente.dob, telefono = cliente.telefono.ToString(), SINPE = cliente.SINPE.ToString(), pass = cliente.pass, aceptado = cliente.aceptado, pedidos = cliente.pedidos }; clientes2.Add(cliente2); } return(Ok(clientes2)); }
public ActionResult Get() { MongoCRUD db = new MongoCRUD("Blog"); var results = db.LoadRecords <PostsModel>("Posts"); foreach (var rec in results) { Console.WriteLine(rec.Id + " " + rec.Name); } Console.ReadLine(); return(results); }
private void LoadPersonData() { MongoCRUD db = new MongoCRUD(dbName); people = db.LoadRecords <PersonModel>(personTable); people.Insert(0, new PersonModel { FirstName = "<add new person>" }); existingRecordDropDown.DataSource = people; }
async public Task <IActionResult> Get() { try { var result = await MongoCRUD.LoadRecords <TodoModel>("todos"); return(Ok(result)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public void CheckForDelistedOffers() { MongoCRUD db = new MongoCRUD(DatabaseSecret, "FlatScraper"); List <FlatOffer> flatOffers = db.LoadRecords <FlatOffer>(CollectionName); foreach (FlatOffer flatOffer in flatOffers) { if (flatOffer.State.Delisted == null && !offerLinks.Contains(flatOffer.Link)) { // Console.WriteLine($"{offerLinks.Contains(flatOffer.Link)}"); var timeStamp = DateTime.UtcNow; flatOffer.State.Delisted = timeStamp; flatOffer.State.LastChecked = timeStamp; db.UpsertRecord <FlatOffer>(CollectionName, flatOffer.Link, flatOffer); } } }
static void Main(string[] args) { MongoCRUD db = new MongoCRUD("AddressBook"); //PersonModel person = new PersonModel //{ // FirstName = "Agus", // LastName = "Gerhart", // PrimaryAddress = new AddressModel // { // StreetAddress = "Calle 404", // City = "Urdilandia", // Province = "ER", // ZipCode = "2826" // } //}; //db.InsertRecord("Users", person); var records = db.LoadRecords <NameModel>("Users"); foreach (var item in records) { Console.WriteLine($"{item.FirstName}, {item.LastName}"); //if (item.PrimaryAddress != null) //{ // Console.WriteLine(item.PrimaryAddress.City); //} Console.WriteLine(); } //var user = db.LoadRecordById<PersonModel>("Users", new Guid("278ec935-0ffb-4623-8baa-e9f12e7abcdd")); //user.DateOfBirth = new DateTime(2004, 12, 4, 0, 0, 0, DateTimeKind.Utc); //db.UpsertRecord("Users", user.Id, user); //db.DeleteRecord<PersonModel>("Users", user.Id); Console.ReadLine(); }
public List <User> LoadUsers() { return(db.LoadRecords <User>(userTableName)); }
static void Main(string[] args) { MongoCRUD db = new MongoCRUD("Addresses"); Person person = new Person { FirstName = "Bob Arnold", LastName = "Johnson", DateOfBirth = new DateTime(1982, 10, 31, 0, 0, 0, DateTimeKind.Utc), PrimaryAddress = new AddressModel { StreetAddress = "111 2nd street", City = "New York", State = "NJ", Zip = "111111" }, SecondaryAddress = new AddressModel { StreetAddress = "1112 2nd street", City = "New York", State = "AA", Zip = "line" } }; db.InsertRecord("Users", person); person = new Person { FirstName = "Natalie", LastName = "Jones", DateOfBirth = new DateTime(1983, 10, 31, 0, 0, 0, DateTimeKind.Utc), PrimaryAddress = new AddressModel { StreetAddress = "2222 B street", City = "New York", State = "NJ", Zip = "111111" }, }; db.InsertRecord("Users", person); person = new Person { FirstName = "Seth", LastName = "Jones", DateOfBirth = new DateTime(1987, 10, 31, 0, 0, 0, DateTimeKind.Utc), PrimaryAddress = new AddressModel { StreetAddress = "3333 L street", City = "Town", State = "NJ", Zip = "111111" }, }; db.InsertRecord("Users", person); Console.WriteLine(); Console.WriteLine("Records one **"); Console.WriteLine(); var records = db.LoadRecords <Person>("Users"); foreach (var rec in records) { Console.WriteLine($"{rec.Id}: {rec.FirstName} {rec.LastName}"); if (rec.PrimaryAddress != null) { Console.WriteLine(rec.PrimaryAddress.StreetAddress); Console.WriteLine(rec.PrimaryAddress.State); Console.WriteLine(rec.PrimaryAddress.Zip); } Console.WriteLine(); if (rec.SecondaryAddress != null) { Console.WriteLine(rec.SecondaryAddress.StreetAddress); Console.WriteLine(rec.SecondaryAddress.State); Console.WriteLine(rec.SecondaryAddress.Zip); } Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("Records two **"); Console.WriteLine(); var records2 = db.LoadRecordByField <Person>("Users", "LastName", "Jones"); foreach (var rec in records2) { Console.WriteLine($"{rec.Id}: {rec.FirstName} {rec.LastName}"); if (rec.PrimaryAddress != null) { Console.WriteLine(rec.PrimaryAddress.StreetAddress); Console.WriteLine(rec.PrimaryAddress.State); Console.WriteLine(rec.PrimaryAddress.Zip); } Console.WriteLine(); if (rec.SecondaryAddress != null) { Console.WriteLine(rec.SecondaryAddress.StreetAddress); Console.WriteLine(rec.SecondaryAddress.State); Console.WriteLine(rec.SecondaryAddress.Zip); } Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("Records by last name **"); Console.WriteLine(); var record = db.LoadRecordByLastName <Person>("Users", "Jones"); Console.WriteLine($"{record.Id}: {record.FirstName} {record.LastName}"); Console.WriteLine(); record.FirstName = "Timothy"; db.UpsertRecord <Person>("Users", record.Id, record); Console.WriteLine(); Console.WriteLine("Records by last name after change **"); Console.WriteLine(); var record2b = db.LoadRecordByLastName <Person>("Users", "Jones"); Console.WriteLine($"{record2b.Id}: {record2b.FirstName} {record2b.LastName}"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Records from address **"); Console.WriteLine(); // It doesn't seem to work to try pulling data from a child model: var records3 = db.LoadRecordByField <AddressModel>("Users", "Zip", "111111"); foreach (var rec in records3) { Console.WriteLine("Address: " + rec.StreetAddress); } Console.WriteLine(); Console.WriteLine("Records deletion **"); Console.WriteLine(); var records4 = db.LoadRecords <Person>("Users"); foreach (var rec in records4) { db.DeleteRecord <Person>("Users", rec.Id); } Console.ReadLine(); }
public List <Detail> LoadDetails() { return(db.LoadRecords <Detail>(DetailTableName)); }
public string List(int id = -1) { Output = ""; MongoCRUD _db = new MongoCRUD("AddressBook"); Output += "Deleting existing records.<br /><br />"; var _personRecs = _db.LoadRecords <PersonModel>("Users"); Guid _guid = new Guid("20A9A798-FE9D-4D00-836B-2186A01A6691"); foreach (var _rec in _personRecs) { _guid = _rec.Id; _db.DeleteRecord <PersonModel>("Users", _guid); } Output += "All are deleted.<br /><br />"; #region //commented out //_db.InsertRecord("Users" , new PersonModel { FirstName = "Doğan", LastName = "Kartaltepe" }); //_db.InsertRecord("Users", new PersonModel { FirstName = "Terrence", LastName = "Ritzman" }); //PersonModel _personNew = new PersonModel //{ // FirstName = "Justin", // LastName = "Kloetzer", // Address = new AddressModel // { // StreetAddress = "123 Main Street" , // City = "Austin" , // State = "Texas" , // ZipCode = "76055", // AddressType = "Primary" // } //}; //_db.InsertRecord("Users", _personNew); #endregion for (int i = 0; i <= 15; i++) { var _p = new PersonModel() { FirstName = Generate.RandomFirstName(), LastName = Generate.RandomLastName(), Address = new AddressModel() { StreetAddress = Generate.RandomAddress(), City = Generate.RandomCityName(), State = Generate.RandomStateName(), ZipCode = Generate.RandomZip(), AddressType = "Primary" }, // DateOfBirth = new DateTime(Generate.RandomInteger(1950, 2012), Generate.RandomInteger(1, 2), Generate.RandomInteger(1, 30), 0, 0, 0, DateTimeKind.Utc) DateOfBirth = Generate.RandomDate(1950, 2012) }; _db.InsertRecord("Users", _p); } #region //PERSONMODEL _personRecs = _db.LoadRecords <PersonModel>("Users"); foreach (var _rec in _personRecs) { _guid = _rec.Id; OutputPerson(_rec); Output += "<br />"; } var _person = _db.LoadRecordById <PersonModel>("Users", _guid); OutputPerson(_person); Output += "<br />"; _person.DateOfBirth = Generate.RandomDate(1950, 2012); // new DateTime(Generate.RandomInteger(1950,2012), 1, 1, 0, 0, 0, DateTimeKind.Utc); _db.UpsertRecord("Users", _person.Id, _person); OutputPerson(_person); #endregion //PERSONMODEL #region //NAMEMODEL //var _recsName = _db.LoadRecords<NameModel>("Users"); //foreach (var _rec in _recsName) //{ // _guid = _rec.Id; // OutputName(_rec); // Console.WriteLine("\n"); //} //var _name = _db.LoadRecordById<NameModel>("Users", _guid); #endregion //NAMEMODEL return(Output); }
public IActionResult RecipesList() { var items = db.LoadRecords <RecipesModel>("Recipes").ToArray <RecipesModel>(); return(View("RecipesList", items)); }
public async Task <User[]> GetAll() { return((await _db.LoadRecords <User>(table)).ToArray()); }
static void Main(string[] args) { MongoCRUD _db = new MongoCRUD("AddressBook"); Console.WriteLine("Deleting existing records.\n\n"); var _personRecs = _db.LoadRecords <PersonModel>("Users"); Guid _guid = new Guid("20A9A798-FE9D-4D00-836B-2186A01A6691"); foreach (var _rec in _personRecs) { _guid = _rec.Id; _db.DeleteRecord <PersonModel>("Users", _guid); } Console.WriteLine("All are deleted.\n\n"); #region //commented out //_db.InsertRecord("Users" , new PersonModel { FirstName = "Doğan", LastName = "Kartaltepe" }); //_db.InsertRecord("Users", new PersonModel { FirstName = "Terrence", LastName = "Ritzman" }); //PersonModel _personNew = new PersonModel //{ // FirstName = "Justin", // LastName = "Kloetzer", // Address = new AddressModel // { // StreetAddress = "123 Main Street" , // City = "Austin" , // State = "Texas" , // ZipCode = "76055", // AddressType = "Primary" // } //}; //_db.InsertRecord("Users", _personNew); #endregion for (int i = 0; i <= 15; i++) { var _p = new PersonModel() { FirstName = Generate.RandomFirstName(), LastName = Generate.RandomLastName(), Address = new AddressModel() { StreetAddress = Generate.RandomAddress(), City = Generate.RandomCityName(), State = Generate.RandomStateName(), ZipCode = Generate.RandomZip(), AddressType = "Primary" }, DateOfBirth = Generate.RandomDate(1950, 2012) }; _db.InsertRecord("Users", _p); } #region //PERSONMODEL _personRecs = _db.LoadRecords <PersonModel>("Users"); foreach (var _rec in _personRecs) { _guid = _rec.Id; OutputPerson(_rec); Console.WriteLine("\n"); } var _person = _db.LoadRecordById <PersonModel>("Users", _guid); OutputPerson(_person); Console.WriteLine(""); _person.DateOfBirth = Generate.RandomDate(1950, 2012); _db.UpsertRecord("Users", _person.Id, _person); OutputPerson(_person); #endregion //PERSONMODEL #region //NAMEMODEL //var _recsName = _db.LoadRecords<NameModel>("Users"); //foreach (var _rec in _recsName) //{ // _guid = _rec.Id; // OutputName(_rec); // Console.WriteLine("\n"); //} //var _name = _db.LoadRecordById<NameModel>("Users", _guid); #endregion //NAMEMODEL Console.WriteLine("\n\nPress the any key"); Console.ReadLine(); }