public ActionResult Create(CreateViewAppointment viewAppointment)
        {
            if (ModelState.IsValid)
            {
                Appointment newAppointment = new Appointment();
                newAppointment.PatientID   = viewAppointment.PatientID;
                newAppointment.PhysicianID = viewAppointment.PhysicianID;
                newAppointment.ID          = 0;
                //insert the new appointment
                string url = "AppointmentsData/AddAppointment";


                newAppointment.Subject = viewAppointment.Subject;
                newAppointment.Message = viewAppointment.Message;

                newAppointment.SentOn = DateTime.Now.ToString("yyyy/MM/dd hh:mm tt");
                //newAppointment.RequestDatetime = DateTime.ParseExact(newAppointment.RequestDatetime.ToString("yyyy/MM/dd HH:mm"), "yyyy/MM/dd HH:mm", System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));
                newAppointment.Status = AppointmentStatus.Pending;
                var      cultureInfo       = new CultureInfo("en-CA");
                DateTime requestedDateTime = DateTime.Parse(viewAppointment.RequestDatetime, cultureInfo);
                newAppointment.RequestDatetime = requestedDateTime.ToString("yyyy/MM/dd hh:mm tt");
                //pass along authentication credential in http request
                GetApplicationCookie();

                HttpContent content = new StringContent(jss.Serialize(newAppointment));
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                HttpResponseMessage response = client.PostAsync(url, content).Result;
                if (response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("List", new { pageNum = 1 }));
                }
                else
                {
                    return(RedirectToAction("Error"));
                }
            }
            else
            {
                IdentityRole role = null;
                //if user's role is 'patient' fetch the users with 'Doctor' role and vice versa
                if (User.IsInRole("Patient"))
                {
                    role = new ApplicationDbContext().Roles.SingleOrDefault(m => m.Name == "Physician");
                }

                else
                {
                    role = new ApplicationDbContext().Roles.SingleOrDefault(m => m.Name == "Patient");
                }
                CreateViewAppointment viewModel = new CreateViewAppointment();
                viewModel.UsersInRole = new ApplicationDbContext().Users.Where(m => m.Roles.Any(r => r.RoleId == role.Id)).ToList();
                ViewData["user_id"]   = User.Identity.GetUserId();

                return(View(viewAppointment));
            }
        }
        // GET: Appointments/Create
        public ActionResult Create()
        {
            IdentityRole role = null;

            //if user's role is 'patient' fetch the users with 'Doctor' role and vice versa
            if (User.IsInRole("Patient"))
            {
                role = new ApplicationDbContext().Roles.SingleOrDefault(m => m.Name == "Physician");
            }

            else
            {
                role = new ApplicationDbContext().Roles.SingleOrDefault(m => m.Name == "Patient");
            }
            CreateViewAppointment viewModel = new CreateViewAppointment();

            viewModel.UsersInRole = new ApplicationDbContext().Users.Where(m => m.Roles.Any(r => r.RoleId == role.Id)).ToList();
            ViewData["user_id"]   = User.Identity.GetUserId();

            return(View(viewModel));
        }