public ActionResult EditInvestigator(EditInvestigatorViewModel m)
        {
            var investigator = _db.Investigators.FirstOrDefault(i => i.Id == m.Id);

            if (investigator != null)
            {
                investigator.Institution = m.Institution;
                investigator.Person.Email = m.Email;
                investigator.Person.First_Name = m.FirstName;
                investigator.Person.Last_Name = m.LastName;
                investigator.Person.Phone_Number = m.PhoneNumber;
                investigator.Person.Postcode = m.Postcode;
                investigator.Person.State = m.State;
                investigator.Person.Street = m.Street;
                investigator.Person.Suburb = m.Suburb;

                _db.SaveChanges();
            }

            return View("Index");
        }
        public ActionResult EditInvestigator(EditInvestigatorViewModel m)
        {
            //Get the investigator we're trying to edit
            var investigator = _db.Investigators.FirstOrDefault(i => i.Id == m.Id);

            //If investigator exists in the database
            if (investigator != null)
            {
                //Edit the investigator details in the database
                investigator.Institution = m.Institution;
                investigator.Person.Email = m.Email;
                investigator.Person.First_Name = m.FirstName;
                investigator.Person.Last_Name = m.LastName;
                investigator.Person.Phone_Number = m.PhoneNumber;
                investigator.Person.Postcode = m.Postcode;
                investigator.Person.State = m.State;
                investigator.Person.Street = m.Street;
                investigator.Person.Suburb = m.Suburb;

                _db.SaveChanges();
            }

            //Show the admin dashboard
            return View("Index");
        }
        public ActionResult EditInvestigator(int id)
        {
            var investigator = _db.Investigators.FirstOrDefault(i => i.Id == id);

            if (investigator == null)
            {
                return View("Index");
            }

            var m = new EditInvestigatorViewModel();
            
            m.Id = id;
            m.Email = investigator.Person.Email;
            m.FirstName = investigator.Person.First_Name;
            m.Institution = investigator.Institution;
            m.LastName = investigator.Person.Last_Name;
            m.PhoneNumber = investigator.Person.Phone_Number;
            m.Postcode = investigator.Person.Postcode;
            m.State = investigator.Person.State;
            m.Street = investigator.Person.Street;
            m.Suburb = investigator.Person.Suburb;
            
            return View(m);
        }
        //Show a form to edit investigator
        public ActionResult EditInvestigator(int id)
        {
            //Get the id of the investigator we're trying to edit
            var investigator = _db.Investigators.FirstOrDefault(i => i.Id == id);

            //If there is no investigator with that id, just go back to the dashboard
            if (investigator == null)
            {
                return View("Index");
            }

            //Get the information about the investigator we're trying to edit
            var m = new EditInvestigatorViewModel();
            
            m.Id = id;
            m.Email = investigator.Person.Email;
            m.FirstName = investigator.Person.First_Name;
            m.Institution = investigator.Institution;
            m.LastName = investigator.Person.Last_Name;
            m.PhoneNumber = investigator.Person.Phone_Number;
            m.Postcode = investigator.Person.Postcode;
            m.State = investigator.Person.State;
            m.Street = investigator.Person.Street;
            m.Suburb = investigator.Person.Suburb;
            
            //Pass those information to the view
            return View(m);
        }