public ActionResult SaveOldPatientReport(OldPatientReportViewModel oldPatientReportViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("OldPatientForm", oldPatientReportViewModel));
            }
            var patient = _context.Patients.SingleOrDefault(r => r.Id == oldPatientReportViewModel.PatientId);

            if (patient == null)
            {
                return(HttpNotFound("Patient Not Found"));
            }

            if (oldPatientReportViewModel.TestTitleIds[0] == null)
            {
                return(HttpNotFound("Form Not Submitted Correctly"));
            }
            var reports = new List <Report>();

            foreach (var testTitleId in oldPatientReportViewModel.TestTitleIds)
            {
                if (!testTitleId.HasValue)
                {
                    continue;
                }
                var testTitle = _context.TestTitles.Single(t => t.Id == testTitleId);

                var report = new Report
                {
                    //PatientId = patient.Id,
                    TestTitleId = testTitle.Id,
                    //InvestigatedBy = "",
                    //ReportBy = "",
                    //ConsultingPathologistId = _context.Defaultvalues.Single(d => d.Id == 1).Id,
                    //Date=oldPatientReportViewModel.Report.Date,
                    //DateAdded=DateTime.Now,
                    Price = testTitle.Price,
                    //DoctorId=oldPatientReportViewModel.Report.DoctorId,
                    //DigitalSignature=oldPatientReportViewModel.Report.DigitalSignature
                };
                _context.Reports.Add(report);
                reports.Add(report);
            }
            var oldPatientReportBill = new OldPatientReportBillViewModel {
                Reports   = reports,
                PatientId = patient.Id,
                Patient   = patient,
                Report    = oldPatientReportViewModel.Report
                , Bill    = new Bill {
                    Discount = 0
                }
            };

            return(View("OldPatientBillForm", oldPatientReportBill));
        }
        public ActionResult OldPatientForm()
        {
            var doctors = _context.Doctors.ToList();

            var testTitles = _context.TestTitles.ToList();

            var patients = _context.Patients.ToList();
            var oldPatientReportViewModel = new OldPatientReportViewModel {
                Doctors = doctors, Report = new Report {
                    Date = DateTime.Now
                }, TestTitles = testTitles
            };

            return(View(oldPatientReportViewModel));
        }