async public Task <IActionResult> Get(string id)
        {
            try
            {
                var result = await MongoCRUD.LoadRecordById <TodoModel>("todos", new ObjectId(id));

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Exemple #2
0
 public ActionResult Profile(LoginModel model)
 {
     try
     {
         MongoCRUD  db      = new MongoCRUD("BZBugs");
         LoginModel details = db.LoadRecordById <LoginModel>("Users", model.Id);
         return(View(details));
     }
     catch
     {
         return(View());
     }
 }
Exemple #3
0
 public ActionResult BugDetails(Guid id)
 {
     try
     {
         MongoCRUD db = new MongoCRUD("BZBugs");
         BugsModel details = db.LoadRecordById<BugsModel>("Bugs", id);
         return View(details);             
     }
     catch
     {
         return RedirectToAction(nameof(ListBugs));
     }         
 }
Exemple #4
0
        public void getUserName(string userId)
        {
            var rec = _db.LoadRecordById <User>("User", new string(userId));

            Console.WriteLine(rec.Name);
        }
 public IHttpActionResult GetSubmission(string Id)
 {
     System.Diagnostics.Debug.WriteLine("loading: ", Id);
     return(Ok(db.LoadRecordById <Submission>("Submissions", Id)));
 }
 public User LoadUserById(Guid id)
 {
     return(db.LoadRecordById <User>(userTableName, id));
 }
 public Detail LoadDetailById(Guid id)
 {
     return(db.LoadRecordById <Detail>(DetailTableName, id));
 }
Exemple #8
0
        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 ShowRecipe(RecipesModel recipesModel)
 {
     db.LoadRecordById <RecipesModel>("Recipes", recipesModel.RecipeId);
     return(View());
 }
Exemple #10
0
        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();
        }