//
        // GET: /Doctor/
        public ActionResult Index()
        {
            if (Session["UserEmail"].ToString().Contains("@dentappsys.com"))
            {
                string Email = (string)Session["UserEmail"];

                using (var db = new MaindbModelDataContext())
                {
                    var Doctor = db.Doctors.FirstOrDefault(u => u.Email == (String)Session["UserEmail"]);
                    if (Doctor != null)
                    {
                        ViewBag.FirstName = Doctor.Name;
                        ViewBag.LastName = Doctor.Surname;
                        ViewBag.BirthDate = Doctor.BirthDate;
                        ViewBag.Email = Doctor.Email;

                        return View();
                    }
                    else
                    {
                        return RedirectToAction("RegAndLogin", "User");
                    }
                }
            }
            else
            {
                return RedirectToAction("RegAndLogin", "User");
            }
        }
        public ActionResult Make(Models.AppModel User)
        {
            if (Session["UserEmail"] != null)
            {
                using (var db = new MaindbModelDataContext())
                {
                    var patient = db.Patients.FirstOrDefault(u => u.Email == (String)Session["UserEmail"]);

                    var app = new Appointment();
                    app.Date = (DateTime)User.Date;
                    app.Description = User.Description;
                    app.Status = "isPending";
                    app.PatientNo = patient.PatientNo;
                    app.AppNo = Guid.NewGuid().GetHashCode();
                    db.Appointments.InsertOnSubmit(app);
                    db.SubmitChanges();
                }
            }
            else
            {
                return RedirectToAction("Index", "User");
            }
            return RedirectToAction("Make", "Appointment");
        }
        //
        // GET: /Patient/
        public ActionResult Index()
        {
            if (Session["UserEmail"] != null)
            {
                string Email = (string)Session["UserEmail"];

                using (var db = new MaindbModelDataContext())
                {
                    var patient = db.Patients.FirstOrDefault(u => u.Email == (String)Session["UserEmail"]);
                    if (patient != null)
                    {
                    ViewBag.FirstName = patient.Name;
                    ViewBag.LastName = patient.Surname;
                    ViewBag.BirthDate = patient.Birthday;
                    ViewBag.Email = patient.Email;
                    }
                    else
                    {
                        return RedirectToAction("RegAndLogin", "User");
                    }

                }

                using (var db = new MaindbModelDataContext())
                {
                    var patient = db.Patients.FirstOrDefault(u => u.Email == (String)Session["UserEmail"]);
                    var listincoming = (from y in db.Appointments
                                        where y.PatientNo == patient.PatientNo
                                        where y.Date > DateTime.Today
                                        where y.Status == "isConfirmed"
                                        orderby y.Date descending
                                        select y).Take(5);

                    var TempIncoming = new List<Models.AppModel>();
                    foreach (var item in listincoming)
                    {
                        var Temp1 = new Models.AppModel();
                        Temp1.AppNo = item.AppNo;
                        Temp1.PatientNo = (Int32)item.PatientNo;
                        Temp1.Date = (DateTime)item.Date;
                        Temp1.Status = item.Status;
                        Temp1.Description = item.Description;
                        TempIncoming.Add(Temp1);

                    }

                    var p = db.Patients.FirstOrDefault(u => u.Email == (String)Session["UserEmail"]);
                    var listrecent = (from y in db.Appointments
                                      where y.PatientNo == p.PatientNo
                                      where y.Date < DateTime.Today
                                      orderby y.Date ascending
                                      select y).Take(5);

                    var TempRecent = new List<Models.AppModel>();
                    foreach (var item in listrecent)
                    {
                        var Temp2 = new Models.AppModel();
                        Temp2.AppNo = item.AppNo;
                        Temp2.PatientNo = (Int32)item.PatientNo;
                        Temp2.Date = (DateTime)item.Date;
                        Temp2.Status = item.Status;
                        Temp2.Description = item.Description;
                        TempRecent.Add(Temp2);

                    }
                    return View(new DentAppSys.Models.RecentIncoming() { RecentAppts = TempRecent, IncomingAppts = TempIncoming });
                }
            }
                else
            {
                return RedirectToAction("RegAndLogin", "User");
            }
        }
Пример #4
0
        public ActionResult RegAndLogin(Models.RegAndLog User)
        {
            if (User.RegisterModel != null)
            {
                if (ModelState.IsValid && !User.RegisterModel.Email.Contains("@dentappsys.com"))
                {
                    using (var db = new MaindbModelDataContext())
                    {
                        var Person = db.Patients.FirstOrDefault(u => u.Email == User.RegisterModel.Email);
                        if (Person == null)
                        {
                            string Hash = BCrypt.Net.BCrypt.HashPassword(User.RegisterModel.Password);
                            var MyUser = new Patient();
                            MyUser.Name = User.RegisterModel.Firstname;
                            MyUser.Surname = User.RegisterModel.Lastname;
                            MyUser.Birthday = User.RegisterModel.Birthday;
                            MyUser.Email = User.RegisterModel.Email;
                            MyUser.Password = Hash;
                            MyUser.PatientNo = Guid.NewGuid().GetHashCode();
                            db.Patients.InsertOnSubmit(MyUser);
                            db.SubmitChanges();

                            Session["UserEmail"] = User.RegisterModel.Email;
                            return RedirectToAction("Index", "Patient", User.RegisterModel);
                        }
                        else
                        {
                            ModelState.AddModelError("", "There is a user with this Email. Please enter another Email !!!");
                            return View();
                        }

                    }
                }
                else
                {
                    ModelState.AddModelError("", "Data is incorrect !!!");
                }
            }
            else
            {
                if (ModelState.IsValid && IsValid(User.LoginModel.Email, User.LoginModel.Password))
                {

                    if (User.LoginModel.Email.Contains("@dentappsys.com"))
                    {
                    var TempUser = new Models.RegisterModel();
                    Session["UserEmail"] = User.LoginModel.Email;
                    using (var db = new MaindbModelDataContext())
                    {
                            var person = db.Doctors.FirstOrDefault(u => u.Email == User.LoginModel.Email);
                            TempUser.Firstname = person.Name;
                            TempUser.Lastname = person.Surname;
                            //TempUser.RegisterModel.Birthday = (DateTime)person.BirthDate;
                            TempUser.Email = person.Email;

                        }
                        return RedirectToAction("Index", "Doctor", TempUser);

                    }
                    else
                    {
                        var TempUser = new Models.RegisterModel();
                        Session["UserEmail"] = User.LoginModel.Email;
                        using (var db = new MaindbModelDataContext())
                        {
                        var person = db.Patients.FirstOrDefault(u => u.Email == User.LoginModel.Email);
                        TempUser.Firstname = person.Name;
                        TempUser.Lastname = person.Surname;
                        //TempUser.RegisterModel.Birthday = (DateTime)person.BirthDate;
                        TempUser.Email = person.Email;

                    }
                    return RedirectToAction("Index", "Patient", TempUser);
                 }
                }
                else
                {
                    ModelState.AddModelError("", "Check your E-mail or Password then try again !!!");
                }
            }
            return View();
        }
Пример #5
0
 private bool IsValid(string email, string password)
 {
     bool isvalid = false;
     using (var db = new MaindbModelDataContext())
     {
         if (email.Contains("@dentappsys.com"))
         {
             var Doctor = db.Doctors.FirstOrDefault(u => u.Email == email);
             if (Doctor != null)
             {
                 if (BCrypt.Net.BCrypt.Verify(password, Doctor.Password))
                 {
                     isvalid = true;
                     return isvalid;
                 }
             }
             else
             {
                 return isvalid;
             }
         }
         var Person = db.Patients.FirstOrDefault(u => u.Email == email);
         if (Person != null)
         {
             if (BCrypt.Net.BCrypt.Verify(password, Person.Password))
             {
                 isvalid = true;
             }
         }
     }
     return isvalid;
 }
        public ActionResult Resultlist(Models.GetDoc doc)
        {
            if (doc.StartDate == DateTime.MinValue && doc.EndDate == DateTime.MinValue && doc.AppID == null)
            {
                using (MaindbModelDataContext db = new MaindbModelDataContext())
                {
                    var patient = db.Patients.FirstOrDefault(u => u.Email == (string)Session["UserEmail"]);
                    var listresult = from r in db.PatientFiles
                                      where r.PatientNo == patient.PatientNo
                                      select r;

                    var TempDoCs = new List<Models.Resultdoc>();
                    foreach (var item in listresult)
                    {
                        var Tempdoc = new Models.Resultdoc();
                        Tempdoc.AppID = item.AppNo;
                        Tempdoc.PatientID = item.PatientNo;
                        Tempdoc.Status = item.Status;
                        Tempdoc.Prescription = item.Prescription;
                        Tempdoc.TreatmentDis = item.TreatmentDetails;
                        //var base64 = Convert.ToBase64String(item.Image.ToArray());
                        Tempdoc.Image = item.Image.ToArray();
                        TempDoCs.Add(Tempdoc);

                    }

                    return View(TempDoCs);
                }
            }
            else
            {
                if (doc.AppID != null)
                {
                    try
                    {
                        int AppNo = Convert.ToInt32(doc.AppID);
                    }
                    catch
                    {
                        ModelState.AddModelError("", "Please Input Correct Appointment Number !!!");
                        return View();
                    }
                    using (MaindbModelDataContext db = new MaindbModelDataContext())
                    {
                        var listresult = db.PatientFiles.FirstOrDefault(u => u.AppNo == Convert.ToInt32(doc.AppID));
                        var TempDoCs = new List<Models.Resultdoc>();
                        var Tempdoc = new Models.Resultdoc();
                        Tempdoc.AppID = listresult.AppNo;
                        Tempdoc.PatientID = listresult.PatientNo;
                        Tempdoc.Status = listresult.Status;
                        Tempdoc.Prescription = listresult.Prescription;
                        Tempdoc.TreatmentDis = listresult.TreatmentDetails;
                        Tempdoc.Image = listresult.Image.ToArray();
                        TempDoCs.Add(Tempdoc);
                        //foreach (var item in listresult)
                        //{

                        //    var Tempdoc = new Models.Resultdoc();
                        //    Tempdoc.AppID = item.AppNo;
                        //    Tempdoc.PatientID = item.PatientNo;
                        //    TempDoCs.Add(Tempdoc);

                        //}
                        return View(TempDoCs);
                    }
                }
                else
                {
                    using (MaindbModelDataContext db = new MaindbModelDataContext())
                    {
                        var patient = db.Patients.FirstOrDefault(u => u.Email == (string)Session["UserEmail"]);
                        var listresult = from App in db.Appointments
                                         where App.Date >= doc.StartDate && App.Date <= doc.EndDate && App.PatientNo == patient.PatientNo
                                         join Doc in db.PatientFiles on App.AppNo equals Doc.AppNo into ResGroup
                                         from res in ResGroup
                                         select new { AppNo = res.AppNo, PatientNo = res.PatientNo, Status = res.Status, Prescription = res.Prescription , TreatmentDetails = res.TreatmentDetails , Image = res.Image};

                        var TempDoCs = new List<Models.Resultdoc>();
                        foreach (var item in listresult)
                        {
                            var Tempdoc = new Models.Resultdoc();
                            Tempdoc.AppID = item.AppNo;
                            Tempdoc.PatientID = item.PatientNo;
                            Tempdoc.Status = item.Status;
                            Tempdoc.Prescription = item.Prescription;
                            Tempdoc.TreatmentDis = item.TreatmentDetails;
                            //var base64 = Convert.ToBase64String(item.Image.ToArray());
                            Tempdoc.Image = item.Image.ToArray();
                            TempDoCs.Add(Tempdoc);

                        }

                        return View(TempDoCs);
                    }
                }
            }
        }
        public ActionResult Management(Models.Drmanagments Tempmanage)
        {
            if (Session["UserEmail"].ToString().Contains("@dentappsys.com"))
            {
                if (Tempmanage.appmodel != null)
                {
                    using (var db = new MaindbModelDataContext())
                    {
                        var app = db.Appointments.FirstOrDefault(u => u.AppNo == Tempmanage.appmodel.AppNo);
                        if (app != null)
                        {
                            app.Status = Tempmanage.appmodel.Status;
                            app.DrDescription = Tempmanage.appmodel.DrDescription;
                            db.SubmitChanges();

                            ViewBag.ChangeResultApp = "Done !";
                            return View();
                        }
                        else
                        {
                            ViewBag.ChangeResultApp = "Check your appointment number then try again !";
                            return View();
                        }
                    }
                }
                else
                {
                    if (Tempmanage.resultdoc != null)
                    {
                        using (var db = new MaindbModelDataContext())
                        {
                            var app = db.PatientFiles.FirstOrDefault(u => u.AppNo == Tempmanage.resultdoc.AppID && u.PatientNo == Tempmanage.resultdoc.PatientID);
                            if (app == null)
                            {
                                var tempapp = new PatientFile();
                                tempapp.AppNo = Tempmanage.resultdoc.AppID;
                                tempapp.PatientNo = Tempmanage.resultdoc.PatientID;
                                tempapp.Prescription = Tempmanage.resultdoc.Prescription;
                                tempapp.Status = Tempmanage.resultdoc.Status;
                                tempapp.TreatmentDetails = Tempmanage.resultdoc.TreatmentDis;
                                db.PatientFiles.InsertOnSubmit(tempapp);
                                db.SubmitChanges();

                                ViewBag.ChangeResultDoc = "Done !";
                                return View();
                            }
                            else
                            {
                                ViewBag.ChangeResultDoc = "Check your appointment number or patient number then try again !";
                                return View();
                            }

                        }

                    }
                    else
                    {
                        return View();
                    }

                }
            }
            else
            {
                return RedirectToAction("RegAndLogin", "User");
            }
        }