public ActionResult Index() { List <Prescription> PrescriptionsList; using (DataDoctorEntities2 entity = new DataDoctorEntities2()) { var doctorsCount = entity.Database.SqlQuery <int>("Select Count(*) from dbo.AspNetUsers where Licence is not null").ToList(); ViewBag.doctors = doctorsCount[0]; var presCount = entity.Database.SqlQuery <int>("Select Count(*) from dbo.Prescription inner join dbo.AspNetUsers On dbo.AspNetUsers.Id=dbo.Prescription.Doctor_Id where Licence is not null").ToList(); ViewBag.Prescriptions = presCount[0]; var users = entity.Database.SqlQuery <string>(string.Format("Select Id from dbo.AspNetUsers where UserName='******'", User.Identity.Name)).ToList(); string user = users[0]; //var ListOfPrescriptions = entity.Database.SqlQuery<int>("Select Count(*) from dbo.AspNetUsers where Licence is not null").ToList(); //var innerGroupJoinQuery =from pres in Prescription // join users in AspNetUser on pres.Doctor_Id equals users.Id // select pres; //var PrescriptionsList = from pres in Prescription // where pres.Doctor_ID == "2f9f3535-5d63-460c-a2fd-6bc5e21e9814" // select pres; //var user = entity.AspNetUsers.Where(u => u.UserName == User.Identity.Name); PrescriptionsList = entity.Prescriptions.Where(e => e.Doctor_Id == user).ToList(); } //check the changes return(View(PrescriptionsList)); }
public ActionResult GeneralIndex() { List <Prescription> PrescriptionsList; using (DataDoctorEntities2 entity = new DataDoctorEntities2()) { var doctorsCount = entity.Database.SqlQuery <int>("Select Count(*) from dbo.AspNetUsers where Licence is not null").ToList(); ViewBag.doctors = doctorsCount[0]; var presCount = entity.Database.SqlQuery <int>("Select Count(*) from dbo.Prescription inner join dbo.AspNetUsers On dbo.AspNetUsers.Id=dbo.Prescription.Doctor_Id where Licence is not null").ToList(); ViewBag.Prescriptions = presCount[0]; var users = entity.Database.SqlQuery <string>(string.Format("Select Id from dbo.AspNetUsers where UserName='******'", User.Identity.Name)).ToList(); string user = users[0]; PrescriptionsList = entity.Prescriptions.ToList(); } //check the changes return(View(PrescriptionsList)); }