public ActionResult GetAppointmentsAnyone(string stylist) { List <bookingview> daycal = new List <bookingview>(); if (stylist == null) { return(RedirectToAction("Index")); } ViewBag.Stylist = stylist; Bookings myBookings = new Bookings(); List <Booking> thebook = myBookings.GetBookings(); List <string> myDates = new List <string>(); List <string> myDays = new List <string>(); // myDates.Add(DateTime.Today.ToShortDateString()); int i = 0; while (i <= 6) { int j = 9; while (j <= 17) { bookingview calEntry = new bookingview(); calEntry.date = DateTime.Today.AddDays(i).ToShortDateString(); if (i == 0) { calEntry.datedetail = "Today"; } else { calEntry.datedetail = DateTime.Today.AddDays(i).DayOfWeek.ToString(); } var timeStr = j.ToString() + ":00"; if (j == 9) { timeStr = "0" + timeStr; } calEntry.time = timeStr; calEntry.stylist = stylist; calEntry.customer = ""; // var result = thebook.Find(x => x.date == DateTime.Today.AddDays(i).ToShortDateString() && x.time == timeStr && x.stylist == stylist); List <string> freestylists = myBookings.GetAvailableStylists(calEntry.date, timeStr); if (freestylists != null && freestylists.Count > 0) { if (j % 2 == 1) { calEntry.customer = freestylists.First(); } else { calEntry.customer = freestylists.Last(); } // calEntry.phone = result.phone; // calEntry.style = result.style; // calEntry.info = result.info; } daycal.Add(calEntry); j++; } myDates.Add(DateTime.Today.AddDays(i).ToShortDateString()); i++; } ViewBag.BookingDates = myDates; myDays.Add("Today"); i = 1; while (i <= 6) { myDays.Add(DateTime.Today.AddDays(i).DayOfWeek.ToString()); i++; } ViewBag.BookingDays = myDays; return(Json(daycal, JsonRequestBehavior.AllowGet)); }
public ActionResult Appointment(string stylist) { List <bookingview> daycal = new List <bookingview>(); if (stylist == null) { return(RedirectToAction("Index")); } ViewBag.Stylist = stylist; Bookings myBookings = new Bookings(); List <Booking> thebook = myBookings.GetBookings(); List <string> myDates = new List <string>(); List <string> myDays = new List <string>(); // myDates.Add(DateTime.Today.ToShortDateString()); int i = 0; while (i <= 6) { int j = 9; while (j <= 17) { bookingview calEntry = new bookingview(); calEntry.date = DateTime.Today.AddDays(i).ToShortDateString(); if (i == 0) { calEntry.datedetail = "Today"; } else { calEntry.datedetail = DateTime.Today.AddDays(i).DayOfWeek.ToString(); } var timeStr = j.ToString() + ":00"; if (j == 9) { timeStr = "0" + timeStr; } calEntry.time = timeStr; calEntry.stylist = stylist; calEntry.customer = ""; var result = thebook.Find(x => x.date == DateTime.Today.AddDays(i).ToShortDateString() && x.time == timeStr && x.stylist == stylist); if (result != null) { calEntry.customer = result.name; calEntry.phone = result.phone; calEntry.style = result.style; calEntry.info = result.info; } daycal.Add(calEntry); j++; } myDates.Add(DateTime.Today.AddDays(i).ToShortDateString()); i++; } ViewBag.BookingDates = myDates; myDays.Add("Today"); i = 1; while (i <= 6) { myDays.Add(DateTime.Today.AddDays(i).DayOfWeek.ToString()); i++; } ViewBag.BookingDays = myDays; return(View("Appointment")); }
public ActionResult Appointment(string stylist) { List <bookingview> daycal = new List <bookingview>(); if (stylist == null) { return(RedirectToAction("Index")); } ViewBag.Stylist = stylist; Bookings myBookings = new Bookings(); List <Booking> thebook = myBookings.GetBookings(); List <string> myDates = new List <string>(); List <string> myDays = new List <string>(); // myDates.Add(DateTime.Today.ToShortDateString()); int i = 0; while (i <= 6) { int j = 9; TheListeningHand.Models.TheListeningHandEntities context = new TheListeningHandEntities(); List <availability> slots = context.availabilities.Where(s => s.stylistId.ToString() == stylist && s.dayId == 1).ToList(); foreach (availability slot in slots) { bookingview calEntry = new bookingview(); calEntry.date = DateTime.Today.AddDays(i).ToShortDateString(); if (i == 0) { calEntry.datedetail = "Today"; } else { calEntry.datedetail = DateTime.Today.AddDays(i).DayOfWeek.ToString(); } var timeStr = slot.time.ToString() + ":00"; if (j < 10) { timeStr = "0" + timeStr; } calEntry.time = timeStr; calEntry.stylist = stylist; calEntry.customer = ""; var result = thebook.Find(x => x.date == DateTime.Today.AddDays(i).ToShortDateString() && x.time == timeStr && x.stylist == stylist); if (result != null) { calEntry.customer = result.name; calEntry.phone = result.phone; calEntry.style = result.style == null ? "n/a" : result.style; calEntry.info = result.info == null ? "n/a" : result.info; } daycal.Add(calEntry); j++; } myDates.Add(DateTime.Today.AddDays(i).ToShortDateString()); i++; } ViewBag.BookingDates = myDates; myDays.Add("Today"); i = 1; while (i <= 6) { myDays.Add(DateTime.Today.AddDays(i).DayOfWeek.ToString()); i++; } ViewBag.BookingDays = myDays; return(View("Appointment")); }