Esempio n. 1
0
        public ActionResult AddDoctor(HttpPostedFileBase filename, DoctorViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (filename != null)
                {
                    string pic  = System.IO.Path.GetExtension(filename.FileName);
                    string name = Guid.NewGuid().ToString() + pic;
                    string path = System.IO.Path.Combine(
                        Server.MapPath("~/Contents/upload/Doctor"), name);
                    // file is uploaded
                    filename.SaveAs(path);
                    model.DOCTOR_IMAGE = name;
                }
                TBL_DOCTOR tbd = new TBL_DOCTOR();
                tbd.DOCTOR_NAME    = model.DOCTOR_NAME;
                tbd.EMAIL          = model.EMAIL;
                tbd.ADDRESS        = model.ADDRESS;
                tbd.DOCUMENT       = model.DOCUMENT;
                tbd.DOCTOR_IMAGE   = model.DOCTOR_IMAGE;
                tbd.SPECIALIZATION = model.SPECIALIZATION;
                tbd.WORK_HOSPITAL  = model.WORK_HOSPITAL;
                tbd.CONTACT        = model.CONTACT;
                tbd.GENDER         = model.GENDER;
                tbd.DOCTOR_IMAGE   = model.DOCTOR_IMAGE;

                tbd.DOCTOR_ID = db.TBL_DOCTOR.Add(tbd).DOCTOR_ID;
                db.SaveChanges();

                // var dtl = db.TBL_DISEASE_DETAILS.Where(X => X.DISEASE_ID == model.DISEASE_ID).FirstOrDefault();
                TBL_DOCTOR_DETAILS dlt = new TBL_DOCTOR_DETAILS();
                dlt.DETAIL_ID                     = db.TBL_DOCTOR_DETAILS.Add(dlt).DETAIL_ID;
                dlt.DOCTOR_DESCRIPTION            = model.DOCTOR_DESCRIPTION;
                dlt.DOCTOR_EDUCATION              = model.DOCTOR_EDUCATION;
                dlt.DOCTOR_ID                     = tbd.DOCTOR_ID;
                dlt.DOCTOR_SPECIALIZATION_DETAILS = model.DOCTOR_SPECIALIZATION_DETAILS;

                db.SaveChanges();


                if (tbd.DOCTOR_ID > 0)
                {
                    return(Json(new { title = "Success", successMessage = "Successfully Registered!" }));
                }
                else
                {
                    Response.StatusCode = (int)HttpStatusCode.SeeOther;
                    return(Json(new { title = "Error", errorMessage = "Something went wrong!" }));
                }
            }
            else
            {
                return(PartialView(model));
            }
        }
Esempio n. 2
0
        public ActionResult listDoctors(int?page, string type, string location, string query)
        {
            List <DoctorViewModel> dc = new List <DoctorViewModel>();
            int pageIndex             = 1;
            int pageSize = 4;

            pageIndex = page.HasValue ? Convert.ToInt16(page) : 1;
            if (!string.IsNullOrWhiteSpace(type))
            {
                return(View(db.TBL_DOCTOR.Where(X => X.SPECIALIZATION.Contains(type)).ToList().ToPagedList(pageIndex, pageSize)));
            }
            else if (location != null)
            {
                return(View(db.TBL_DOCTOR.Where(X => X.ADDRESS.Contains(location)).ToList().ToPagedList(pageIndex, pageSize)));
            }
            else if (query != null)
            {
                //(from p in db.TBL_DOCTOR
                // join q in db.TBL_DISEASE on p.SPECIALIZATION equals q.CATEGORY
                // where p.EMAIL.Equals("something") || p.DOCUMENT != ""
                // select new {
                //     p, q.DISEASE_ID,
                //     ram = q.DISEASE_NAME
                // }
                // );
                var result = (from p in db.TBL_DOCTOR
                              where p.ADDRESS.Contains(query) || p.DOCTOR_NAME.Contains(query) || p.EMAIL.Contains(query) || p.SPECIALIZATION.Contains(query) || p.WORK_HOSPITAL.Contains(query)
                              select new { p }
                              ).ToList();

                List <TBL_DOCTOR> list = new List <TBL_DOCTOR>();
                foreach (var item in result)
                {
                    TBL_DOCTOR doc = new TBL_DOCTOR();
                    doc.ADDRESS       = item.p.ADDRESS;
                    doc.DOCTOR_ID     = item.p.DOCTOR_ID;
                    doc.DOCTOR_NAME   = item.p.DOCTOR_NAME;
                    doc.DOCTOR_IMAGE  = item.p.DOCTOR_IMAGE;
                    doc.DOCUMENT      = item.p.DOCUMENT;
                    doc.WORK_HOSPITAL = item.p.WORK_HOSPITAL;
                    doc.CONTACT       = item.p.CONTACT;
                    doc.EMAIL         = item.p.EMAIL;
                    doc.GENDER        = item.p.GENDER;
                    list.Add(doc);
                }
                return(View(list.ToPagedList(pageIndex, pageSize)));


                // return View(db.TBL_DOCTOR.Where(X => X.ADDRESS.Contains(query) || ).ToList().ToPagedList(pageIndex, pageSize));
            }
            else
            {
                return(View(db.TBL_DOCTOR.ToList().ToPagedList(pageIndex, pageSize)));
            }
        }
Esempio n. 3
0
        public ActionResult searchList(int?page, string searchKey, string searchfor)
        {
            int pageIndex = 1;
            int pageSize  = 4;

            pageIndex = page.HasValue ? Convert.ToInt16(page) : 1;
            if (searchfor == "doctor")
            {
                var result = (from p in db.TBL_DOCTOR
                              where p.ADDRESS.Contains(searchKey) || p.DOCTOR_NAME.Contains(searchKey) || p.EMAIL.Contains(searchKey) || p.SPECIALIZATION.Contains(searchKey) || p.WORK_HOSPITAL.Contains(searchKey)
                              select new { p }
                              ).ToList();

                List <TBL_DOCTOR> list = new List <TBL_DOCTOR>();
                foreach (var item in result)
                {
                    TBL_DOCTOR doc = new TBL_DOCTOR();
                    doc.ADDRESS        = item.p.ADDRESS;
                    doc.DOCTOR_ID      = item.p.DOCTOR_ID;
                    doc.SPECIALIZATION = item.p.SPECIALIZATION;
                    doc.DOCTOR_NAME    = item.p.DOCTOR_NAME;
                    doc.DOCTOR_IMAGE   = item.p.DOCTOR_IMAGE;
                    doc.DOCUMENT       = item.p.DOCUMENT;
                    doc.WORK_HOSPITAL  = item.p.WORK_HOSPITAL;
                    doc.CONTACT        = item.p.CONTACT;
                    doc.EMAIL          = item.p.EMAIL;
                    doc.GENDER         = item.p.GENDER;
                    list.Add(doc);
                }
                return(View("~/Views/User/listDoctors.cshtml", list.ToPagedList(pageIndex, pageSize)));
            }
            else if (searchfor == "Disease")
            {
                var result = (from p in db.TBL_DISEASE
                              join q in db.TBL_DISEASE_DETAILS on p.DISEASE_ID equals q.DISEASE_ID
                              where p.DISEASE_NAME.Contains(searchKey) || p.CATEGORY.Contains(searchKey) || p.SYMPTOMS.Contains(searchKey)
                              select new
                {
                    p,
                    q
                }
                              ).ToList();

                List <DiseaseViewModel> list = new List <DiseaseViewModel>();
                foreach (var item in result)
                {
                    DiseaseViewModel doc = new DiseaseViewModel();
                    doc.DISEASE_ID   = item.p.DISEASE_ID;
                    doc.DISEASE_NAME = item.p.DISEASE_NAME;
                    doc.CATEGORY     = item.p.CATEGORY;

                    doc.SYMPTOMS = item.p.SYMPTOMS;
                    //doc.WORK_HOSPITAL = item.p.WORK_HOSPITAL;
                    //doc.CONTACT = item.p.CONTACT;
                    //doc.EMAIL = item.p.EMAIL;
                    //doc.GENDER = item.p.GENDER;
                    list.Add(doc);
                }
                return(View("~/Views/DIsease/listAll.cshtml", list.ToPagedList(pageIndex, pageSize)));
            }
            else if (searchfor == "hospital")
            {
                var result = (from p in db.TBL_HOSPITAL
                              where p.HOSPITAL_ADDRESS.Contains(searchKey) || p.HOSPITAL_NAME.Contains(searchKey) || p.SPECIALIZATION.Contains(searchKey)
                              select new { p }
                              ).ToList();

                List <TBL_HOSPITAL> list = new List <TBL_HOSPITAL>();
                foreach (var item in result)
                {
                    TBL_HOSPITAL doc = new TBL_HOSPITAL();
                    doc.HOSPITAL_NAME    = item.p.HOSPITAL_NAME;
                    doc.HOSPITAL_ADDRESS = item.p.HOSPITAL_ADDRESS;
                    doc.SPECIALIZATION   = item.p.SPECIALIZATION;
                    doc.HOSPITAL_ID      = item.p.HOSPITAL_ID;
                    doc.HOSPITAL_IMAGE   = item.p.HOSPITAL_IMAGE;

                    list.Add(doc);
                }
                return(View("~/Views/User/listHospital.cshtml", list.ToPagedList(pageIndex, pageSize)));
            }
            return(View());
        }