public ActionResult GraphicFiles(int id)
        {
            this._currentDoctor = _doctors.GetDoctorFromUser(User.Identity.GetUserId());
            //var doctorFromLabDoc = this._doctors.GetDoctorForLabDetailDoc(id);

            //if ((doctorFromLabDoc == null) || (doctorFromLabDoc.Id != _currentDoctor.Id))
            //{
            //    return RedirectToAction("LabDocs");
            //}

            //this._currentPacient = _pacients.GetPacientFromUser(User.Identity.GetUserId());

            var doctorForExam = this._doctors.GetDoctorForExam(id);

            var currentPacient = this._pacients.GetPacientForExam(id);

            if ((doctorForExam == null) || (doctorForExam.Id != _currentDoctor.Id))
            {
                return RedirectToAction("Exams");
            }

            if (currentPacient != null)
            {
                TempData["PacientEgn"] = currentPacient.EGN;
                TempData["PacientName"] = currentPacient.Name;
            }

            var examList = this._doctors
                .GetGraphicsFileForExam(id)
                .ProjectTo<GraphicFilesViewModel>()
                .AsQueryable();

            return View(examList);
        }
        public ActionResult Exams(int id)
        {
            IEnumerable<ExamsViewModel> examList;

            if (this.HttpContext.Cache["Exams_Page_" + id] != null)
            {
                examList = (IEnumerable<ExamsViewModel>)this.HttpContext.Cache["Exams_Page_" + id];
            }
            else
            {
                this._currentDoctor = _doctors.GetDoctorFromUser(User.Identity.GetUserId());

                var curPacient = this._pacients.GetPacientById(id);
                if (curPacient != null)
                {
                    TempData["PacientEgn"] = curPacient.EGN;
                    TempData["PacientName"] = curPacient.Name;
                }

                examList = this._doctors
                    .GetExamsForPacient(this._currentDoctor.Id, id)
                    .OrderByDescending(x => x.DateReg)
                    .ProjectTo<ExamsViewModel>()
                    .AsQueryable();
            }

            return View(examList);
        }
        public ActionResult LabDocsDetails(int id)
        {
            this._currentDoctor = _doctors.GetDoctorFromUser(User.Identity.GetUserId());
            var doctorFromLabDoc = this._doctors.GetDoctorForLabDetailDoc(id);

            if ((doctorFromLabDoc == null) || (doctorFromLabDoc.Id != _currentDoctor.Id))
            {
                return RedirectToAction("LabDocs");
            }

            if (_currentDoctor != null)
            {
                TempData["PacientEgn"] = this._pacients.GetPacientForLabDetailDoc(id).EGN;
                TempData["PacientName"] = this._pacients.GetPacientForLabDetailDoc(id).Name;
            }

            var mainInfo = this._pacients
                .GetLabMainDocHeader(id);

            TempData["DocNumber"] = mainInfo.DocNumber ?? "Няма";
            TempData["DoctorPerf"] = mainInfo.DoctorPerf.Name ?? "Няма";
            TempData["DataReg"] = mainInfo.DateReg.ToShortDateString();

            var mainDocsDetails = this._doctors
                .GetLabDocDetails(id)
                .ProjectTo<LabDocDetailsViewModel>()
                .AsQueryable();

            return View(mainDocsDetails);
        }
        public ActionResult PacientsList()
        {
            this._currentDoctor = _doctors.GetDoctorFromUser(User.Identity.GetUserId());

            if (_currentDoctor != null)
            {
                TempData["DoctorUin"] = this._currentDoctor.UIN;
                TempData["DoctorName"] = this._currentDoctor.Name;
            }

            var allPacientsExams = this._doctors
                .GetPacientsList(this._currentDoctor.Id);

            return View(allPacientsExams);
        }
        public ActionResult LabDocs(int id)
        {
            this._currentDoctor = _doctors.GetDoctorFromUser(User.Identity.GetUserId());

            var mainDocs = this._doctors
                .GetLabDocsForPacient(id, this._currentDoctor.Id)
                .ProjectTo<LabDocsViewModel>()
                .ToList();

            return View(mainDocs);
        }