public IActionResult Edit(Guid id, [Bind("id,last_name,first_name,phone,email,preferred_name,address,city,state,country,dob,user_id,profile_type,education_level,status,marital_status")] mp_profile mp_profile)
        {
            if (id != mp_profile.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _profileService.Update(mp_profile);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_profileService.ProfileExists(mp_profile.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mp_profile));
        }
Ejemplo n.º 2
0
 public MemberModel(mp_profile profile)
 {
     id       = profile.id;
     fullName = string.Format("{0} {1}", profile.first_name, profile.last_name);
     title    = profile.unique_id.ToString("D10");
     imageUrl = FileUtil.GetImageLocation(profile.user_id);
     about    = profile.about;
 }
        public void Update(mp_profile profile)
        {
            var old = _context.mp_profile.FirstOrDefault(e => e.id == profile.id);

            profile.created_at = old.created_at;

            _context.Entry(old).CurrentValues.SetValues(profile);
            _context.SaveChanges();
        }
        public Guid Add(mp_profile profile)
        {
            profile.id         = Guid.NewGuid();
            profile.created_at = DateTime.Now;
            _context.mp_profile.Add(profile);
            _context.SaveChanges();

            return(profile.id);
        }
 public IActionResult Create([Bind("last_name,first_name,phone,email,preferred_name,address,city,state,country,dob,user_id,profile_type,education_level,status,marital_status")] mp_profile mp_profile)
 {
     if (ModelState.IsValid)
     {
         _profileService.Add(mp_profile);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(mp_profile));
 }
Ejemplo n.º 6
0
        public ActionResult NewAppointment(mp_appointment appointment)
        {
            var service    = DAL.Utils.Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service);
            var collection = Request.Form;
            var date       = collection["date"] + " " + collection["time"];
            var start_date = DateTime.Parse(date);

            appointment.start_date = start_date;
            appointment.end_date   = start_date.AddMinutes(service.time_minutes);


            Guid       logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User));
            mp_profile user_profile   = _profileService.GetByUserId(logged_user_id);

            appointment.client_id = user_profile.id;
            Guid appointment_id;

            var day_available = _clinicianAvailabilityService.Get().FirstOrDefault(e => e.day_name == start_date.DayOfWeek.ToString() && e.clinician_id == appointment.clinician_id);

            if (day_available != null)
            {
                // var clinician_available = _clinicianAvailabilityService.GetClinicianAvailabilityByDateRange(appointment);
                if (1 == 1)//if (AppointmentBL.IsClinicianAvailable(day_available.start_time,day_available.end_time,appointment.start_date,appointment.end_date))
                {
                    //clinician is available by settings
                    //now check if clinician already has appointment fixed
                    // var clinician_appointments = _appointmentService.GetClinicianAppointmentsByDateRange(appointment);
                    if (1 == 1)//if (AppointmentBL.IsAppointmentClashing(appointment.clinician_id,appointment))
                    {
                        //clinician does not have appointments set for that time
                        //fix appointment
                        appointment.status         = 169;
                        appointment_id             = _appointmentService.Add(appointment);
                        TempData["appointment_id"] = appointment_id;
                        TempData["AlertType"]      = "alert-success";
                        TempData["AlertMessage"]   = "We have found an available clinician for you. Please make payment to confirm your booking";
                        return(RedirectToAction(nameof(ConfirmAppointment)));
                    }
                }
            }
            //if we got here, then no clinician was available
            TempData["AlertType"]    = "alert-warning";
            TempData["AlertMessage"] = "Sorry, the clinician will not be available at the time you chose. Please can you review their availability and adjust.";
            return(RedirectToAction("NewAppointment", "Appointment", new { id = collection["profile_match"] }));
        }
Ejemplo n.º 7
0
        public ActionResult Cancel(Guid id)
        {
            var appointment = _appointmentService.Get().Include(e => e.client_).Include(e => e.clinician_).Include(e => e.mp_credit).FirstOrDefault(e => e.id == id);

            if (User.IsInRole("client"))
            {
                Guid       logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User));
                mp_profile user_profile   = _profileService.GetByUserId(logged_user_id);
                //check if the user currently has a bank information
                var profile_bank = _profileBankService.GetProfileBank(user_profile.id);
                if (profile_bank == null)
                {
                    profile_bank = new mp_profile_bank();
                }
                ViewBag.bank = profile_bank;
            }

            return(View(appointment));
        }
 public PersonModel(mp_profile profile)
 {
     id              = profile.id;
     first_name      = profile.first_name;
     last_name       = profile.last_name;
     fullName        = string.Format("{0} {1}", profile.first_name, profile.last_name);
     preferred_name  = profile.preferred_name;
     title           = profile.unique_id.ToString("D10");
     imageUrl        = FileUtil.GetImageLocation(profile.user_id);
     about           = profile.about;
     role            = "client";
     email           = profile.email;
     dob             = profile.dob;
     address         = profile.address;
     phone           = profile.phone;
     country         = profile.country;
     state           = profile.state;
     city            = profile.city;
     marital_status  = profile.marital_status;
     education_level = profile.education_level;
 }
        public IActionResult EditQ(mp_profile mp_profile)
        {
            var collection = Request.Form;

            var user_id = _userManager.GetUserId(HttpContext.User);
            var profile = _profileService.GetProfileByUserId(user_id);

            var appointment_type         = collection["appointment_type"];
            var appointment_category     = collection["appointment_category"];
            var appointment_category_sub = collection["appointment_category_sub"];

            profile.gender = mp_profile.gender;
            profile.tribe  = mp_profile.tribe;

            if (appointment_type == 2)
            {
                profile.years_of_experience  = mp_profile.years_of_experience;
                profile.counselor_preference = mp_profile.counselor_preference;
            }

            _profileService.Update(profile);

            return(RedirectToAction("Clinicians", "Clinician", new { appointment_type, appointment_category, appointment_category_sub }));
        }
 public void Post(mp_profile profile)
 {
     _profileService.Add(profile);
 }
Ejemplo n.º 11
0
        public async Task <ActionResult> RegisterClientMobile(IFormCollection collection, mp_profile profile, mp_enrollment enrollment, mp_couple_screening couple_screening, mp_child_screening child_Screening)
        {
            if (!string.IsNullOrWhiteSpace(collection["religion_other"]))
            {
                enrollment.religion = Options.AddLookup(new mp_lookup {
                    category = "religion", value = collection["religion_other"]
                }).id;
            }

            if (!string.IsNullOrWhiteSpace(collection["preferred_language_other"]))
            {
                profile.language = Options.AddLookup(new mp_lookup {
                    category = "preferred_language", value = collection["preferred_language_other"]
                }).id;
            }
            var appointment_type_id         = Convert.ToInt32(collection["appointment_type"]);
            var appointment_activity_id     = Convert.ToInt32(collection["appointment_category_id"]);
            var appointment_activity_sub_id = Convert.ToInt32(collection["appointment_category_sub_id"]);
            //auth data
            var username = collection["username"];
            //var roles = collection["roles"].ToString().Split(",");
            var password = collection["password"];
            //end of auth data

            //step-1
            //int marital_status = Convert.ToInt32(collection["marital_status"]);
            //int religious = Convert.ToInt32(collection["religious"]);
            //int religion = Convert.ToInt32(collection["religion"]);
            //int help_reason = Convert.ToInt32(collection["help_reason"]);
            //int earlier_counseling = Convert.ToInt32(collection["earlier_counseling"]);
            //int physical_health = Convert.ToInt32(collection["physical_health"]);
            //int eating_habit = Convert.ToInt32(collection["eating_habit"]);
            //int sleeping = Convert.ToInt32(collection["sleeping"]);
            //int depression = Convert.ToInt32(collection["depression"]);
            //int reduced_interest = Convert.ToInt32(collection["reduced_interest"]);
            //int recent_depression = Convert.ToInt32(collection["recent_depression"]);
            //int sleeping_trouble = Convert.ToInt32(collection["sleeping_trouble"]);
            //int tiredness = Convert.ToInt32(collection["tiredness"]);
            //int appetite = Convert.ToInt32(collection["appetite"]);
            //int feeling_bad = Convert.ToInt32(collection["feeling_bad"]);
            //int concentration_issue = Convert.ToInt32(collection["concentration_issue"]);
            //int fidgety = Convert.ToInt32(collection["fidgety"]);
            //int suicidal = Convert.ToInt32(collection["suicidal"]);
            //int today_feeling = Convert.ToInt32(collection["today_feeling"]);
            //int employed = Convert.ToInt32(collection["employed"]);
            //int alcohol = Convert.ToInt32(collection["alcohol"]);
            //int anxiety = Convert.ToInt32(collection["anxiety"]);
            //end step-1

            //step-2
            //var last_name = collection["last_name"];
            //var first_name = collection["first_name"];
            //var phone = collection["phone"];
            //var email = collection["email"];
            //var preferred_name = collection["preferred_name"];
            //var address = collection["address"];
            //var city = collection["city"];
            //int state = Convert.ToInt32(collection["state"]);
            //int country = Convert.ToInt32(collection["country"]);
            //var dob = DateTime.Parse(collection["dob"]);

            //end step-2

            //var jsonMsg = FormHelper.ColletionToJSON(collection);


            var UserManager = _userManager;


            var user = new ApplicationUser {
                UserName = username, Email = username, PhoneNumber = profile.phone, UserType = 1, RegistrationDate = DateTime.Now
            };

            var result = await UserManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                await UserManager.AddToRoleAsync(user, "client");

                //jsonMsg["user_id"] = user.Id;

                try
                {
                    profile.status       = 0;
                    profile.profile_type = 1;
                    profile.user_id      = user.Id;
                    Guid profile_id = _profileService.Add(profile);
                    //    _profileService.Add(new mp_profile
                    //{
                    //    last_name = last_name,
                    //    first_name = first_name,
                    //    phone = phone,
                    //    email = email,
                    //    preferred_name = preferred_name,
                    //    address = address,
                    //    city = city,
                    //    state = state,
                    //    country = country,
                    //    dob = dob,
                    //    user_id = user.Id,
                    //    profile_type = 1,
                    //    education_level = 0,
                    //    status = 0,
                    //    marital_status = marital_status
                    //});

                    //_enrollmentService.Add(new mp_enrollment
                    //{
                    //    profile_id = profile_id,
                    //    religious = religious,
                    //    religion = religion,
                    //    help_reason = help_reason,
                    //    earlier_counseling = earlier_counseling,
                    //    physical_health = physical_health,
                    //    eating_habit = eating_habit,
                    //    sleeping = sleeping,
                    //    depression = depression,
                    //    reduced_interest = reduced_interest,
                    //    recent_depression = recent_depression,
                    //    sleeping_trouble = sleeping_trouble,
                    //    tiredness = tiredness,
                    //    appetite = appetite,
                    //    feeling_bad = feeling_bad,
                    //    concentration_issue = concentration_issue,
                    //    fidgety = fidgety,
                    //    suicidal = suicidal,
                    //    today_feeling = today_feeling,
                    //    employed = employed,
                    //    alcohol = alcohol,
                    //    anxiety = anxiety,
                    //    created_by = username
                    //});
                    if (appointment_type_id == 1 && appointment_activity_sub_id == 1)
                    {
                        //individual counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);
                    }
                    else if (appointment_type_id == 1 && appointment_activity_sub_id == 2)
                    {
                        //couples counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);

                        couple_screening.profile_id = profile_id;
                        _coupleScreeningService.Add(couple_screening);
                    }
                    else if (appointment_type_id == 1 && appointment_activity_sub_id == 3)
                    {
                        //child counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);

                        child_Screening.profile_id = profile_id;
                        _evaluationService.AddChildScreening(child_Screening);
                    }
                    else if (appointment_type_id == 1 && appointment_activity_sub_id == 4)
                    {
                        //familiy counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);
                    }

                    //var profile_match = new mp_profile_match
                    //{
                    //    appointment_type_id = appointment_type_id,
                    //    appointment_activity_id = appointment_activity_id,
                    //    appointment_activity_sub_id = appointment_activity_sub_id,
                    //    clinician_id = Guid.Parse(collection["clinician_id"]),
                    //    profile_id = profile_id
                    //};


                    //_profileMatchService.Add(profile_match);
                }
                catch (Exception ex)
                {
                    //error message handling
                }

                var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                var callbackUrl = Url.Page(
                    "/Account/ConfirmEmail",
                    pageHandler: null,
                    values: new { area = "Identity", userId = user.Id, code = code },
                    protocol: Request.Scheme);

                await _emailSender.SendEmailAsync(user.Email, "Your account has successfully being created. <br>",
                                                  $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                return(RedirectToAction("MemberCompletedMobile"));
                //return Ok(200);
            }

            // If we got this far, something failed, redisplay form

            return(Redirect(Request.Headers["Referer"].ToString()));// return RedirectToAction("Create");
            //return Ok(400);
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> RegisterClient(IFormCollection collection, mp_profile profile, mp_enrollment enrollment, mp_couple_screening couple_screening, mp_child_screening child_Screening)
        {
            if (!string.IsNullOrWhiteSpace(collection["religion_other"]))
            {
                enrollment.religion = Options.AddLookup(new mp_lookup {
                    category = "religion", value = collection["religion_other"]
                }).id;
            }
            if (!string.IsNullOrWhiteSpace(collection["preferred_language_other"]))
            {
                profile.language = Options.AddLookup(new mp_lookup {
                    category = "preferred_language", value = collection["preferred_language_other"]
                }).id;
            }
            if (!string.IsNullOrWhiteSpace(collection["tribe_other"]))
            {
                profile.tribe = Options.AddLookup(new mp_lookup {
                    category = "tribe", value = collection["tribe_other"]
                }).id;
            }
            if (!string.IsNullOrWhiteSpace(collection["child_preferred_language_other"]))
            {
                child_Screening.child_preferred_language = Options.AddLookup(new mp_lookup {
                    category = "preferred_language", value = collection["child_preferred_language_other"]
                }).id;
            }
            var appointment_type_id         = Convert.ToInt32(collection["appointment_type"]);
            var appointment_activity_id     = Convert.ToInt32(collection["appointment_category_id"]);
            var appointment_activity_sub_id = Convert.ToInt32(collection["appointment_category_sub_id"]);
            //auth data
            var username = collection["username"];
            //var roles = collection["roles"].ToString().Split(",");
            var password = collection["password"];
            //end of auth data

            //step-1
            int  marital_status       = Convert.ToInt32(collection["marital_status"]);
            int  religious            = Convert.ToInt32(collection["religious"]);
            int  religion             = Convert.ToInt32(collection["religion"]);
            int  help_reason          = Convert.ToInt32(collection["help_reason"]);
            int  earlier_counseling   = Convert.ToInt32(collection["earlier_counseling"]);
            int  physical_health      = Convert.ToInt32(collection["physical_health"]);
            int  eating_habit         = Convert.ToInt32(collection["eating_habit"]);
            int  sleeping             = Convert.ToInt32(collection["sleeping"]);
            int  depression           = Convert.ToInt32(collection["depression"]);
            int  reduced_interest     = Convert.ToInt32(collection["reduced_interest"]);
            int  recent_depression    = Convert.ToInt32(collection["recent_depression"]);
            int  sleeping_trouble     = Convert.ToInt32(collection["sleeping_trouble"]);
            int  tiredness            = Convert.ToInt32(collection["tiredness"]);
            int  appetite             = Convert.ToInt32(collection["appetite"]);
            int  feeling_bad          = Convert.ToInt32(collection["feeling_bad"]);
            int  concentration_issue  = Convert.ToInt32(collection["concentration_issue"]);
            int  fidgety              = Convert.ToInt32(collection["fidgety"]);
            int  suicidal             = Convert.ToInt32(collection["suicidal"]);
            int  today_feeling        = Convert.ToInt32(collection["today_feeling"]);
            int  employed             = Convert.ToInt32(collection["employed"]);
            int  alcohol              = Convert.ToInt32(collection["alcohol"]);
            int  anxiety              = Convert.ToInt32(collection["anxiety"]);
            bool?clinicalTherapyFaith = Convert.ToBoolean(collection["clinicalTherapyFaith"]);
            //end step-1

            //step-2
            var last_name       = collection["last_name"];
            var first_name      = collection["first_name"];
            var phone           = collection["phone"];
            var email           = collection["email"];
            var preferred_name  = collection["preferred_name"];
            var address         = collection["address"];
            var city            = collection["city"];
            var area            = collection["area"];
            var school_name     = collection["school_name"];
            int state           = Convert.ToInt32(collection["state"]);
            int country         = Convert.ToInt32(collection["country"]);
            var dob             = DateTime.Parse(collection["dob"]);
            int education_level = Convert.ToInt32(collection["education_level"]);
            //end step-2

            //emergency contact
            var emergency_last_name  = collection["emergency_last_name"];
            var emergency_first_name = collection["emergency_first_name"];
            var emergency_phone      = collection["emergency_phone"];
            var emergency_email      = collection["emergency_email"];

            //var jsonMsg = FormHelper.ColletionToJSON(collection);
            var UserManager = _userManager;
            var user        = new ApplicationUser {
                UserName = username, Email = username, PhoneNumber = profile.phone, UserType = 1, RegistrationDate = DateTime.Now
            };

            var result = await UserManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                await UserManager.AddToRoleAsync(user, "client");

                try
                {
                    Guid profile_id = _profileService.Add(new mp_profile
                    {
                        last_name       = last_name,
                        first_name      = first_name,
                        phone           = phone,
                        email           = email,
                        preferred_name  = preferred_name,
                        address         = address,
                        area            = area,
                        city            = city,
                        state           = state,
                        country         = country,
                        dob             = dob,
                        user_id         = user.Id,
                        profile_type    = 1,
                        education_level = education_level,
                        school_name     = school_name,
                        status          = 0,
                        marital_status  = marital_status
                    });
                    _emergencyContactService.Add(new mp_emergency_contact
                    {
                        first_name = emergency_first_name,
                        last_name  = emergency_last_name,
                        email      = emergency_email,
                        phone      = emergency_phone,
                        profile_id = profile_id,
                        created_by = username
                    });
                    _enrollmentService.Add(new mp_enrollment
                    {
                        profile_id           = profile_id,
                        religious            = religious,
                        religion             = religion,
                        help_reason          = help_reason,
                        earlier_counseling   = earlier_counseling,
                        physical_health      = physical_health,
                        eating_habit         = eating_habit,
                        sleeping             = sleeping,
                        depression           = depression,
                        reduced_interest     = reduced_interest,
                        recent_depression    = recent_depression,
                        sleeping_trouble     = sleeping_trouble,
                        tiredness            = tiredness,
                        appetite             = appetite,
                        feeling_bad          = feeling_bad,
                        concentration_issue  = concentration_issue,
                        fidgety              = fidgety,
                        suicidal             = suicidal,
                        today_feeling        = today_feeling,
                        employed             = employed,
                        alcohol              = alcohol,
                        anxiety              = anxiety,
                        clinicalTherapyFaith = clinicalTherapyFaith,
                        created_by           = username
                    });
                    if (appointment_type_id == 1 && appointment_activity_sub_id == 1)
                    {
                        //individual counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);
                    }
                    else if (appointment_type_id == 1 && appointment_activity_sub_id == 2)
                    {
                        //couples counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);

                        couple_screening.profile_id = profile_id;
                        _coupleScreeningService.Add(couple_screening);
                    }
                    else if (appointment_type_id == 1 && appointment_activity_sub_id == 3)
                    {
                        //child counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);

                        child_Screening.profile_id = profile_id;
                        _evaluationService.AddChildScreening(child_Screening);
                    }
                    else if (appointment_type_id == 1 && appointment_activity_sub_id == 4)
                    {
                        //familiy counselling
                        enrollment.created_by = user.Id;
                        enrollment.profile_id = profile_id;
                        _enrollmentService.Add(enrollment);
                    }

                    //var profile_match = new mp_profile_match
                    //{
                    //    appointment_type_id = appointment_type_id,
                    //    appointment_activity_id = appointment_activity_id,
                    //    appointment_activity_sub_id = appointment_activity_sub_id,
                    //    clinician_id = Guid.Parse(collection["clinician_id"]),
                    //    profile_id = profile_id
                    //};


                    //_profileMatchService.Add(profile_match);


                    await _emailSender.SendEmailAsync(user.Email, "Registration successful - MySpace MyTime",
                                                      $"Thanks you " + last_name + " " + first_name + " for creating a profile with us.");

                    //Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>

                    //return LocalRedirect("/Identity/Account/Login");
                    return(Ok(200));
                }
                catch (Exception ex)
                {
                    //error message handling
                    var errMsg = "There was an error creating your account. " + ex.Message;
                    return(Ok(errMsg));
                }


                //                var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
                //var url = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}";

                //var callbackUrl = url;

                // await _signInManager.SignInAsync(user, isPersistent: false);

                //await _emailSender.SendEmailAsync(collection["username"].ToString(), "Welcome to MySpace MyTime",
                //$"Your account has successfully being created.");

                //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
                //code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                //var callbackUrl = Url.Page(
                //    "/Account/ConfirmEmail",
                //    pageHandler: null,
                //    values: new { area = "Identity", userId = user.Id, code = code },
                //    protocol: Request.Scheme);

                //await _emailSender.SendEmailAsync(user.Email, "Your account has successfully being created. <br>",
                //    $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");
            }
            // If we got this far, something failed, redisplay form
            var errors = "There was an error creating your account. Please ensure that the you use a strong password";

            if (result.Errors != null && result.Errors.Count() > 0)
            {
                errors = string.Join(',', result.Errors.Select(x => x.Description).ToList());
            }
            return(Ok(errors));
            //return Redirect(Request.Headers["Referer"].ToString());
        }
Ejemplo n.º 13
0
        public ActionResult Create(mp_appointment appointment)
        {
            var service    = DAL.Utils.Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service);
            var collection = Request.Form;
            var date       = collection["date"] + " " + collection["time"];
            var start_date = DateTime.Parse(date);

            appointment.start_date = start_date;
            appointment.end_date   = start_date.AddMinutes(service.time_minutes);


            Guid       logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User));
            mp_profile user_profile   = _profileService.GetByUserId(logged_user_id);

            appointment.client_id = user_profile.id;
            Guid appointment_id;

            var clinician_available = _clinicianAvailabilityService.GetClinicianAvailabilityByDateRange(appointment);

            if (clinician_available != null)
            {
                //clinician is available by settings
                //now check if clinician already has appointment fixed
                var clinician_appointments = _appointmentService.GetClinicianAppointmentsByDateRange(appointment);
                if (clinician_appointments.Count() < 1)
                {
                    //clinician does not have appointments set for that time
                    //fix appointment
                    appointment_id             = _appointmentService.Add(appointment);
                    TempData["appointment_id"] = appointment_id;
                    TempData["AlertType"]      = "alert-success";
                    TempData["AlertMessage"]   = "We have found an available clinician for you. Please make payment to confirm your booking";
                    return(RedirectToAction(nameof(ConfirmAppointment)));
                }
                //else
                //{
                //    //clinician is already occupied
                //    alternative_clinician = GetAvailableClinician(appointment);
                //    if (alternative_clinician != null)
                //    {
                //        appointment.clinician_id = alternative_clinician.id;
                //        appointment_id = _appointmentService.Add(appointment);
                //        TempData["appointment_id"] = appointment_id;
                //        TempData["AlertType"] = "alert-success";
                //        TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking";
                //        return RedirectToAction(nameof(ConfirmAppointment));
                //    }
                //    //check for other available clinicians
                //}
            }
            //else
            //{
            //    alternative_clinician = GetAvailableClinician(appointment);
            //    if (alternative_clinician != null)
            //    {
            //        appointment.clinician_id = alternative_clinician.id;
            //        appointment_id = _appointmentService.Add(appointment);
            //        TempData["appointment_id"] = appointment_id;
            //        TempData["AlertType"] = "alert-success";
            //        TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking";
            //        return RedirectToAction(nameof(ConfirmAppointment));
            //    }
            //    //check for other available clinicians
            //}

            //if we got here, then no clinician was available
            TempData["AlertType"]    = "alert-warning";
            TempData["AlertMessage"] = "Sorry, we couldn't get an available clinician. Please change your dates and try again";
            return(RedirectToAction("Clinicians", "Clinician"));
        }