示例#1
0
        public IActionResult AddDoctor(Doctor doctor)
        {
            if (!User.Identity.IsAuthenticated)
            {
                TempData["Doctor"] = JsonConvert.SerializeObject(doctor);
                return(RedirectToAction("SavedDoctors"));
            }
            AspNetUsers  thisUser        = _dbHelper.GetCurrentUser(User.Identity.Name);
            ParentDoctor newParentDoctor = new ParentDoctor();

            if (ModelState.IsValid)
            {
                Doctor newDoctor = new Doctor();
                newDoctor.DoctorId  = doctor.DoctorId;
                newDoctor.FirstName = doctor.FirstName;
                if (_dbHelper.CanAddDoctor(newDoctor))
                {
                    _dbHelper.AddNewDoctor(newDoctor);
                }
                newParentDoctor.ParentId = thisUser.Id;
                newParentDoctor.DoctorId = doctor.DoctorId;
                if (_dbHelper.CanAddParentDoctorRelationship(thisUser.Id, newDoctor.DoctorId))
                {
                    _dbHelper.AddNewParentDoctorRelationship(newParentDoctor);
                }
                return(RedirectToAction("SavedDoctors"));
            }
            return(View("Search"));
        }
示例#2
0
        // this method returns a list of saved doctors by the user based on the user's ASP Id
        public IActionResult SavedDoctors()
        {
            if (TempData["Doctor"] != null)
            {
                string stringDoctor = TempData["Doctor"].ToString();
                Doctor doctor       = JsonConvert.DeserializeObject <Doctor>(stringDoctor);
                if (_dbHelper.CanAddDoctor(doctor))
                {
                    _dbHelper.AddNewDoctor(doctor);
                }
                AspNetUsers  thisUser        = _dbHelper.GetCurrentUser(User.Identity.Name);
                ParentDoctor newParentDoctor = new ParentDoctor();
                if (_dbHelper.FindParentById(thisUser.Id) == null)
                {
                    return(RedirectToAction("RegisterUser"));
                }
                newParentDoctor.ParentId = thisUser.Id;
                newParentDoctor.DoctorId = doctor.DoctorId;
                if (_dbHelper.CanAddParentDoctorRelationship(thisUser.Id, doctor.DoctorId))
                {
                    _dbHelper.AddNewParentDoctorRelationship(newParentDoctor);
                }
            }
            List <Doctor> doctorList = _dbHelper.GetListOfCurrentUsersDoctors(User.Identity.Name);

            return(View(doctorList));
        }
示例#3
0
        public IActionResult RegisterUser(Parent newUserInfo)
        {
            if (ModelState.IsValid)
            {
                AspNetUsers thisUser = _dbHelper.GetCurrentUser(User.Identity.Name);
                Parent      newUser  = new Parent();

                newUser.HouseNumber = newUserInfo.HouseNumber;
                newUser.Street      = newUserInfo.Street;
                newUser.Street2     = newUserInfo.Street2;
                newUser.City        = newUserInfo.City;
                newUser.State       = newUserInfo.State;
                newUser.ZipCode     = newUserInfo.ZipCode;
                newUser.ParentId    = thisUser.Id;
                newUser.PhoneNumber = newUserInfo.PhoneNumber;
                newUser.Email       = thisUser.Email;

                _dbHelper.AddNewParent(newUser);
                if (TempData.Count() != 0)

                {
                    string stringDoctor = TempData["Doctor"].ToString();
                    Doctor doctor       = JsonConvert.DeserializeObject <Doctor>(stringDoctor);
                    if (_dbHelper.CanAddDoctor(doctor))
                    {
                        _dbHelper.AddNewDoctor(doctor);
                    }

                    ParentDoctor newParentDoctor = new ParentDoctor();
                    if (newParentDoctor.ParentId == null)
                    {
                        RegisterUser();
                    }
                    newParentDoctor.ParentId = thisUser.Id;
                    newParentDoctor.DoctorId = doctor.DoctorId;
                    if (_dbHelper.CanAddParentDoctorRelationship(thisUser.Id, doctor.DoctorId))
                    {
                        _dbHelper.AddNewParentDoctorRelationship(newParentDoctor);
                    }
                    List <Doctor> doctorList = _dbHelper.GetListOfCurrentUsersDoctors(User.Identity.Name);
                    return(View("SavedDoctors", doctorList));
                }
                return(View("Search"));
            }
            else
            {
                return(View(newUserInfo));
            }
        }
示例#4
0
 // this method adds a new parent doctor relationship if it hasnt been added yet
 public void AddNewParentDoctorRelationship(ParentDoctor newParentDoctor)
 {
     _context.ParentDoctor.Add(newParentDoctor);
     _context.SaveChanges();
 }
示例#5
0
 // this method deletes a doctor
 public void DeleteDoctor(ParentDoctor parentDoctor)
 {
     _context.ParentDoctor.Remove(parentDoctor);
     _context.SaveChanges();
 }