public ActionResult Appointments(string startTime, string endTime) { var currentUserId = Convert.ToInt32(Session["currentUserId"].ToString()); var todayDate = DateTime.Today.ToString("dd/MM/yyyy"); using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var verifyTimeSlot = db.Availabilities.Where(s => (s.DocId == currentUserId && s.Date == todayDate)).Count(); if (verifyTimeSlot >= 1) { return(new JsonResult { Data = false, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { Availability available = new Availability(); available.DocId = currentUserId; available.Date = todayDate; available.TimeStart = startTime; available.TimeEnd = endTime; db.Availabilities.Add(available); db.SaveChanges(); return(new JsonResult { Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } }
public JsonResult registerUser(User _model) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { db.Users.Add(_model); db.SaveChanges(); return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } }
public JsonResult VerifyUserbyUserName(string UserName) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var user = db.Users.Where(s => s.UserName == UserName).FirstOrDefault(); user.IsVerified = true; db.SaveChanges(); return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } }
public JsonResult VerifyUser() { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var user = db.Users.OrderByDescending(s => s.UserId).FirstOrDefault(); user.IsVerified = true; db.SaveChanges(); return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteUser(int id) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var finddata = db.Users.Find(id); finddata.IsDeleted = true; db.SaveChanges(); } return(new JsonResult { Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult isUserExist(string UserName) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var user = db.Users.Where(s => s.UserName == UserName).Count(); if (user >= 1) { return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ApproveOrRejactAppointment(int id, bool status) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var pat = db.PatientRequests.Find(id); pat.Status = status; db.SaveChanges(); return(new JsonResult { Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public static MyAppointmentsViewModel myPrescriptionDetail(int patientId) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var todaydate = DateTime.Today.ToString("dd/MM/yyyy"); var patientPrescription = new MyAppointmentsViewModel { Prescription = db.Prescriptions.Where(s => (s.Date == todaydate && s.PatientId == patientId)).Select(f => new PrescriptionModel { PrescriptionDetail = f.Description }).ToList() }; return(patientPrescription); } }
public static bool AddNewAppointment(DateTime timeStart, DateTime timeEnd, int docId, int currentUserId) { var todaydate = DateTime.Today.ToString("dd/MM/yyyy"); using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { PatientRequest newReq = new PatientRequest(); newReq.UserId = currentUserId; newReq.DocId = docId; newReq.Date = todaydate; newReq.TimeStart = timeStart; newReq.TimeEnd = timeEnd; db.PatientRequests.Add(newReq); db.SaveChanges(); return(true); } }
public ActionResult AddPrescription(int id, string perscription) { var todaydate = DateTime.Today.ToString("dd/MM/yyyy"); using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { Prescription prescriptionDetail = new Prescription(); prescriptionDetail.PatientId = id; prescriptionDetail.Description = perscription; prescriptionDetail.Date = todaydate; db.Prescriptions.Add(prescriptionDetail); db.SaveChanges(); return(new JsonResult { Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public static bool IsTimeSloatReserved(DateTime startTime, DateTime endtime, int docId) { var todaydate = DateTime.Today.ToString("dd/MM/yyyy"); using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var PatientAppointments = db.PatientRequests.Where(x => x.TimeStart == startTime && x.DocId == docId || x.TimeStart <startTime && x.TimeEnd> startTime && x.DocId == docId || x.TimeStart <endtime && x.TimeEnd> endtime && x.DocId == docId && x.Date == todaydate).Count(); if (PatientAppointments >= 1) { return(true); } } return(false); }
public static UsersViewModel GetAllUsers(int RoleId) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var doctors = new UsersViewModel { Users = db.Users.Where(s => (s.RoleId == RoleId && s.IsDeleted == false)).Select(f => new UsersModel { UserId = f.UserId, UserName = f.UserName, FirstName = f.FirstName, LastName = f.LastName, IsActive = f.IsActive }).ToList() }; return(doctors); } }
public ActionResult EnableDisable(int id) { bool status = false; using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var finddata = db.Users.Find(id); if (finddata.IsActive == true) { finddata.IsActive = false; } else { finddata.IsActive = true; status = true; } db.SaveChanges(); } return(new JsonResult { Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public static AvailableDoctorsViewModel GetAllAvailableDoctors() { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var todaydate = DateTime.Today.ToString("dd/MM/yyyy"); var patientAppointments = new AvailableDoctorsViewModel { AvailableDoctors = db.Availabilities.Join(db.Users, x => x.DocId, y => y.UserId, (x, y) => new { a = x, u = y }).Where(s => (s.a.Date.Contains(todaydate))).Select(f => new AvailableDoctors { docId = f.a.DocId, fullName = f.u.FirstName + " " + f.u.LastName, startTime = f.a.TimeStart, endTime = f.a.TimeEnd, }).ToList() }; return(patientAppointments); } }
public static DoctorViewModel getPatientAppointmentsReuquests(int docId, bool?status) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var todaydate = DateTime.Today.ToString("dd/MM/yyyy"); var patientAppointments = new DoctorViewModel { appointments = db.PatientRequests.Join(db.Users, x => x.UserId, y => y.UserId, (x, y) => new { p = x, u = y }).Where(s => (s.p.DocId == docId && s.p.Status == status && s.p.Date.Contains(todaydate))).Select(f => new DoctorModel { PatientId = f.p.PatientId, FullName = f.u.FirstName + " " + f.u.LastName, TimeStart = f.p.TimeStart, TimeEnd = f.p.TimeEnd, Status = f.p.Status }).ToList() }; return(patientAppointments); } }
public ActionResult Login(string userName, string password) { using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext()) { var isAuthenticated = db.Users.Where(s => (s.UserName == userName && s.Password == password)).Count(); if (isAuthenticated == 1) { var IsVerified = db.Users.Where(s => (s.UserName == userName)).Select(s => s.IsVerified).FirstOrDefault(); var IsDeleted = db.Users.Where(s => (s.UserName == userName)).Select(s => s.IsDeleted).FirstOrDefault(); var IsActive = db.Users.Where(s => (s.UserName == userName)).Select(s => s.IsActive).FirstOrDefault(); if (IsVerified == false) { return(Json(new { result = 2 }, JsonRequestBehavior.AllowGet)); } else if (IsDeleted == true) { return(Json(new { result = 3 }, JsonRequestBehavior.AllowGet)); } else if (IsActive == false) { return(Json(new { result = 4 }, JsonRequestBehavior.AllowGet)); } else { var currentUserId = db.Users.Where(s => s.UserName == userName).Select(s => s.UserId).FirstOrDefault(); var currentUserRole = db.Users.Join(db.Roles, x => x.RoleId, y => y.RoleId, (x, y) => new { u = x, r = y }).Where(s => s.u.UserName == userName).Select(s => s.r.RoleName).FirstOrDefault(); Session["currentUser"] = userName; Session["currentUserId"] = currentUserId; Session["currentUserRole"] = currentUserRole; return(Json(new { result = 1, UserRole = currentUserRole }, JsonRequestBehavior.AllowGet)); } } } return(Json(new { result = 5 }, JsonRequestBehavior.AllowGet)); }