Exemple #1
0
        public ActionResult SetSchedule(int?id)
        {
            MTAppointViewModel viewModel = new MTAppointViewModel();

            viewModel.MassageTherapist = db.MassageTherapists.Where(t => t.Id == id).SingleOrDefault();
            if (viewModel.MassageTherapist.TimeFramePref == "Morning")
            {
                viewModel.SetTime = new SelectList(new List <string>()
                {
                    "7:00 AM", "8:00 AM", "9:00 AM", "10:00 AM", "11:00 AM", "12:00 PM", "1:00 PM"
                });
            }
            else if (viewModel.MassageTherapist.TimeFramePref == "Afternoon")
            {
                viewModel.SetTime = new SelectList(new List <string>()
                {
                    "12:00 PM", "1:00 PM", "2:00 PM", "3:00 PM", "4:00 PM", "5:00 PM", "6:00 PM"
                });
            }
            else if (viewModel.MassageTherapist.TimeFramePref == "Evening")
            {
                viewModel.SetTime = new SelectList(new List <string>()
                {
                    "4:00 PM", "5:00 PM", "6:00 PM", "7:00 PM", "8:00 PM", "9:00 PM", "10:00 PM"
                });
            }

            return(View("Schedule", viewModel));
        }
Exemple #2
0
        // GET: MassageTherapists/Create
        public ActionResult Create()
        {
            MTAppointViewModel viewModel = new MTAppointViewModel();

            ViewBag.ApplicationId = new SelectList(db.Users, "Id", "Email");
            return(View(viewModel));
        }
Exemple #3
0
        public ActionResult MakeAppointment(int?mtId, int?cpId)
        {
            MTAppointViewModel model = new MTAppointViewModel();

            model.Client           = db.Clients.Where(c => c.ApplicationId == userId).SingleOrDefault();
            model.ClientPref       = db.ClientPrefs.Where(p => p.Id == cpId).SingleOrDefault();
            model.MassageTherapist = db.MassageTherapists.Where(t => t.Id == mtId).SingleOrDefault();

            return(View("Schedule", model));
        }
Exemple #4
0
        public ActionResult SetDate(int?id)
        {
            MTAppointViewModel viewModel = new MTAppointViewModel();

            viewModel.MassageTherapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.Id == id).SingleOrDefault();
            var client = db.Clients.Where(c => c.ApplicationId == userId).SingleOrDefault();
            var pref   = db.ClientPrefs.Where(p => p.ClientId == client.Id).SingleOrDefault();

            viewModel.ClientPref = pref;
            return(View(viewModel));
        }
Exemple #5
0
        public ActionResult SetSchedule(int?id, MTAppointViewModel update)
        {
            var therapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.Id == id).SingleOrDefault();

            therapist.Schedule1 = update.MassageTherapist.Schedule1;
            therapist.Schedule2 = update.MassageTherapist.Schedule2;
            therapist.Schedule3 = update.MassageTherapist.Schedule3;
            therapist.Schedule4 = update.MassageTherapist.Schedule4;
            db.SaveChanges();
            return(View("Details", therapist));
        }
Exemple #6
0
        public ActionResult MakeAppointment(MTAppointViewModel viewModel)
        {
            var client     = db.Clients.Include(c => c.ApplicationUser).Where(c => c.ApplicationId == userId).SingleOrDefault();
            var therapist  = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.Id == viewModel.MassageTherapist.Id).SingleOrDefault();
            var clientPref = db.ClientPrefs.Include(c => c.Client).Where(c => c.ClientId == client.Id).SingleOrDefault();

            if (viewModel.MassageTherapist.IsOpen1 == true)
            {
                if (clientPref.AppointmentTime == null)
                {
                    therapist.IsOpen1          = true;
                    clientPref.AppointmentTime = therapist.Schedule1;
                    therapist.AppointmentDate  = clientPref.AppointmentDate;
                }
            }
            if (viewModel.MassageTherapist.IsOpen2 == true)
            {
                if (clientPref.AppointmentTime == null)
                {
                    therapist.IsOpen2          = true;
                    clientPref.AppointmentTime = therapist.Schedule2;
                    therapist.AppointmentDate  = clientPref.AppointmentDate;
                }
            }
            if (viewModel.MassageTherapist.IsOpen3 == true)
            {
                if (clientPref.AppointmentTime == null)
                {
                    therapist.IsOpen3          = true;
                    clientPref.AppointmentTime = therapist.Schedule3;
                    therapist.AppointmentDate  = clientPref.AppointmentDate;
                }
            }
            if (viewModel.MassageTherapist.IsOpen4 == true)
            {
                if (clientPref.AppointmentTime == null)
                {
                    therapist.IsOpen3          = true;
                    clientPref.AppointmentTime = therapist.Schedule4;
                    therapist.AppointmentDate  = clientPref.AppointmentDate;
                }
            }
            ClientTherapist clientTherapist = new ClientTherapist();

            clientTherapist.ClientId    = client.Id;
            clientTherapist.TherapistId = therapist.Id;
            db.ClientTherapists.Add(clientTherapist);
            db.SaveChanges();
            return(RedirectToAction("Details", "Clients"));
        }
Exemple #7
0
        public ActionResult Details(int?id, MTAppointViewModel model, string name)
        {
            var client = db.Clients.Where(c => c.ApplicationId == userId).SingleOrDefault();

            model.Client = client;
            var pref = db.ClientPrefs.Where(p => p.ClientId == client.Id).SingleOrDefault();

            if (model == null)
            {
                model.ClientPref = pref;
            }
            model.MassageTherapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.Id == id).SingleOrDefault();
            string   date            = model.ClientPref.AppointmentDate;
            DateTime dateFormat      = DateTime.ParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture);
            string   appointmentDate = dateFormat.ToString("MM/dd/yyyy");

            pref.AppointmentDate = appointmentDate;
            db.SaveChanges();
            return(RedirectToAction("MakeAppointment", new { mtId = model.MassageTherapist.Id, cpId = model.ClientPref.Id }));
        }
Exemple #8
0
        // GET: MassageTherapists/Details/5
        public ActionResult Details(int?id, MTAppointViewModel viewModel)
        {
            MassageTherapist therapist = null;

            if (id != null)
            {
                therapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.Id == id).SingleOrDefault();
                var client = db.Clients.Where(c => c.ApplicationId == userId).SingleOrDefault();
                ViewBag.ClientLat = client.Latitude;
                ViewBag.ClientLng = client.Longitude;
            }
            else
            {
                therapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.ApplicationId == userId).SingleOrDefault();
            }
            if (therapist == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Map = "https://maps.googleapis.com/maps/api/js?key=" + GoogleMapKey.myKey + "&callback=initMap";

            return(View(therapist));
        }