// GET: Appointment public ActionResult Index(AppointmentMessageId?message) { ViewBag.StatusMessage = message == AppointmentMessageId.ScheduleAppointmentSuccess ? "Your appointment has been scheduled." : message == AppointmentMessageId.DeleteAppointmentSuccess ? "Your appointment has been canceled." : message == AppointmentMessageId.AddResponseSuccess ? "Your response has been recorded." : ""; var db = new ApplicationDbContext(); var userId = User.Identity.GetUserId(); var apts = db.Appointments.Where(u => u.PatientID == userId && DateTime.Compare(u.TimeDate, DateTime.Today) >= 0).OrderBy(u => u.TimeDate).ToList(); Appointments = apts; Appointments apt = null; if (User.IsInRole("Doctor")) { apt = db.Appointments.Where(u => u.PhysicianID == userId && DateTime.Compare(u.TimeDate, DateTime.Today) >= 0).OrderBy(u => u.TimeDate).FirstOrDefault(); } var model = new AppointmentIndexViewModel { Appointment = Appointments.FirstOrDefault(), PatientAppointment = apt }; return(View(model)); }
// // GET: /Time/ public ViewResult Index(int Step = 1) { var appointments = appDb.Appointments.ToList(); var hobbies = hdDb.Hobbies.ToList(); var appviewmodels = new List <AppointmentViewModel>(); var calData = new AppointmentViewModel[7, 24]; foreach (var appointment in appointments) { var a = new AppointmentViewModel(); a.Day = appointment.Day; a.Time = appointment.Time; if (appointment.AppointmentValue.Length > 6) { a.AppointmentValue = appointment.AppointmentValue.Substring(0, 7) + "..."; } else { a.AppointmentValue = appointment.AppointmentValue; } a.ID = appointment.ID; a.DayName = new DatePretty().Prettify(a.Day); appviewmodels.Add(a); calData[a.Day, a.Time] = a; } var vms = new AppointmentIndexViewModel(); vms.appointments = appviewmodels; vms.hobbies = hobbies; vms.calendarTableData = calData; vms.Step = Step; return(View(vms)); }
public ActionResult LoadData() { IEnumerable <Appointment> appointments = Authentication.AuthenticationManager.LoggedUser.IsAdmin ? service.GetAll() : service.GetAll(ap => ap.UserId == Authentication.AuthenticationManager.LoggedUser.Id); List <AppointmentIndexViewModel> model = new List <AppointmentIndexViewModel>(); foreach (var appointment in appointments) { AppointmentIndexViewModel viewModel = new AppointmentIndexViewModel(); Mapper.Map(appointment, viewModel); model.Add(viewModel); } return(Json(new { data = model }, JsonRequestBehavior.AllowGet)); }
public ActionResult LoadCalendar() { IEnumerable <Appointment> appointments = Authentication.AuthenticationManager.LoggedUser.IsAdmin ? service.GetAll() : service.GetAll(ap => ap.UserId == Authentication.AuthenticationManager.LoggedUser.Id); List <AppointmentIndexViewModel> model = new List <AppointmentIndexViewModel>(); var rows = new object(); foreach (var appointment in appointments) { List <string> activityName = new List <string>(); AppointmentIndexViewModel viewModel = new AppointmentIndexViewModel() { Id = appointment.Id, UserId = appointment.UserId, UserName = appointment.User.Name, StartDateTime = appointment.StartDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ"), EndDateTime = appointment.EndDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ"), ActivitiesNames = activityName, }; foreach (var activity in appointment.Activities) { activityName.Add(activity.Name); } model.Add(viewModel); } var AppointmentsList = from e in model select new { id = e.Id, title = e.ActivitiesNames, start = e.StartDateTime, end = e.EndDateTime, color = String.Format("#{0:X6}", e.UserId * 1000000), allDay = false }; rows = AppointmentsList.ToArray(); return(Json(rows, JsonRequestBehavior.AllowGet)); }