示例#1
0
        public ActionResult CreateUser(user_Info userInfo)
        {
            if (ModelState.IsValid) // this is check validity
            {
                using (Appoinment_Entities appoinment_Entities_db = new Appoinment_Entities())
                {
                    userLogin    userLogin     = new userLogin();
                    doctorDetail doctorDetails = new doctorDetail();
                    userRole     userRole      = new userRole();
                    appoinment_Entities_db.user_Info.Add(userInfo);
                    appoinment_Entities_db.SaveChanges();
                    userLogin.FullName = userInfo.first_Name + userInfo.last_Name;
                    userLogin.RoleID   = userInfo.role_Id;

                    var userName = appoinment_Entities_db.userRoles.Where(
                        i => i.role_Id == userLogin.RoleID).SingleOrDefault().role_Name;
                    userLogin.UserID   = userInfo.user_Id;
                    userLogin.UserName = userInfo.email_Address;
                    userLogin.Password = userInfo.first_Name + "@123";
                    appoinment_Entities_db.userLogins.Add(userLogin);
                    appoinment_Entities_db.SaveChanges();

                    if (userInfo.role_Id == 2)
                    {
                        doctorDetails.doctor_Id = userInfo.user_Id;
                        doctorDetails.startTime = userInfo.doctorDetail.startTime;
                        doctorDetails.endTime   = userInfo.doctorDetail.endTime;
                        appoinment_Entities_db.doctorDetails.Add(doctorDetails);
                        appoinment_Entities_db.SaveChanges();
                    }
                }
                ViewBag.Message = "User Created Succesfully";
                return(View("DisplayMessage"));
            }
            else
            {
                return(RedirectToAction("CreateUser", "Home"));
            }
        }
示例#2
0
        public ActionResult CreateAppointment(int doctorId, string appointmentTime)
        {
            Appoinment_Entities appoinment_Entities_db = new Appoinment_Entities();
            appointmentInfo     appointment            = new appointmentInfo();

            appointment.patient_Id = Convert.ToInt32(Session["LogedUserID"]);
            var patientAppointment = appoinment_Entities_db.appointmentInfoes.Where(
                i => i.patient_Id == appointment.patient_Id && i.appointment_Status == true).ToList();

            if (patientAppointment.Count == 0)
            {
                userLogin login = new userLogin();
                //appointment.appointment_Id = 1;
                //appointment.appointment_Id = appoinment_Entities_db.appointmentInfoes.Select(c => c.appointment_Id).Count() + 1;
                appointment.doctor_Id = doctorId;

                var doctorName = appoinment_Entities_db.userLogins.Where(
                    i => i.UserID == doctorId).Single().FullName;

                appointment.doctor_Name = doctorName;

                appointment.patient_Name = appoinment_Entities_db.userLogins.Where(
                    i => i.UserID == appointment.patient_Id).Single().FullName;
                DateTime date      = DateTime.Now;
                var      shortDate = date.Date;
                appointment.appointment_Date   = shortDate;
                appointment.appointment_Time   = TimeSpan.Parse(appointmentTime);
                appointment.appointment_Status = false;
                appoinment_Entities_db.appointmentInfoes.Add(appointment);
                appoinment_Entities_db.SaveChanges();
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("Fail", JsonRequestBehavior.AllowGet));
            }
        }
示例#3
0
        public ActionResult ShowAppointment(int?patientId, string status)
        {
            Appoinment_Entities appoinment_Entities_db = new Appoinment_Entities();
            appointmentInfo     appointmentInfo        = new appointmentInfo();

            appointmentInfo.doctor_Id = Convert.ToInt32(Session["LogedUserID"]);
            appointmentInfo           = appoinment_Entities_db.appointmentInfoes.Where(x => x.patient_Id == patientId && x.doctor_Id == appointmentInfo.doctor_Id).FirstOrDefault();
            if (appointmentInfo != null)
            {
                if (status == "Confirm")
                {
                    appointmentInfo.appointment_Status = true;
                }
                else
                {
                    appointmentInfo.appointment_Status = false;
                }
                appoinment_Entities_db.appointmentInfoes.Add(appointmentInfo);
                appoinment_Entities_db.Entry(appointmentInfo).State = System.Data.Entity.EntityState.Modified;
                appoinment_Entities_db.SaveChanges();
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            return(Json("Fail", JsonRequestBehavior.AllowGet));
        }