// GET: Appointments/Create/d_id public ActionResult Create(int?id) { var d_id = db.Dieticians.Where(x => x.id == id).ToList()[0].id; var alist = db.Appointments.Where(x => x.d_id == d_id.ToString() && x.status != "cancelled").ToList(); List <AppointmentJson> ajl = new List <AppointmentJson>(); foreach (Appointment app in alist) { AppointmentJson aj = new AppointmentJson { title = "Slot Booked", start = app.datetime.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"), url = "#" }; ajl.Add(aj); } string output = JsonConvert.SerializeObject(ajl); ViewData["Message"] = output; ViewData["d_id"] = id; return(View()); }
// GET: Appointments public ActionResult Index() { if (User.IsInRole("Client")) { var userId = User.Identity.GetUserId(); var alist = db.Appointments.Where(x => x.c_id == userId).ToList(); List <AppointmentJson> ajl = new List <AppointmentJson>(); foreach (Appointment app in alist) { AppointmentJson aj = new AppointmentJson { title = app.status + " booking", start = app.datetime.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"), url = "/Appointments/Details/" + app.Id }; ajl.Add(aj); } string output = JsonConvert.SerializeObject(ajl); ViewData["Message"] = output; return(View(alist)); } if (User.IsInRole("Dietician")) { var userId = User.Identity.GetUserId(); var d_id = db.Dieticians.Where(x => x.d_id == userId).ToList()[0].id; var alist = db.Appointments.Where(x => x.d_id == d_id.ToString() && x.status != "cancelled").ToList(); List <AppointmentJson> ajl = new List <AppointmentJson>(); foreach (Appointment app in alist) { AppointmentJson aj = new AppointmentJson { title = app.status + " booking", start = app.datetime.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"), url = "/Appointments/Details/" + app.Id }; ajl.Add(aj); } string output = JsonConvert.SerializeObject(ajl); ViewData["Message"] = output; return(View(alist)); } return(View(db.Appointments.ToList())); }