-1

私はasp.net mvc 5でスケジューラを開発しています。

私はそれに慣れていない、

私の質問は、SQL Server データベースからテーブル ヘッダーにデータを表示する方法です。

ここに私のデータベースがあります ここに画像の説明を入力

ユーザー 6a がログインするときに、表のヘッダーに「青手術」「灰色手術」を表示したい

ユーザー 22b がログインすると、表のヘッダーに「Surgery One」「surgery Two」が表示されます

これが私のテーブルです ここに画像の説明を入力

ここに私のビューコードがあります

 <tr>
                    <th style="width:50px;"></th>

                    <th id="header1">Surgery 1</th>

                    <th id="header2">Surgery 2</th>

                    <th id="header3"></th>

                    <th id="header4"></th>

                    <th id="header5"></th>

                    <th id="header6"></th>

                </tr>

ここに私のコントローラーコードがあります

  // GET: Schedules/Create
    public ActionResult Create()
    {
        var currentUser = User.Identity.GetUserId();
        var schedule = db.AspNetUsers.Where(x => x.ClinicName == currentUser);
        ViewBag.CurrentUser = currentUser;

        //ViewBag.ClinicName = new SelectList(db.AspNetUsers, "Id", "FirstName");

        var doctor = db.Doctors.ToList().Where(d => d.ClinicName == currentUser);
        ViewBag.DoctorID = new SelectList(doctor, "DoctorID", "DoctorName");

        var surgery = db.Surgeries.ToList().Where(d => d.ClinicName == currentUser);
        ViewBag.SurgeryID = new SelectList(surgery, "SurgeryID", "SurgeryName");


        var patient = db.Patients.ToList().Where(p => p.ClinicName == currentUser);
        ViewBag.PatientID = new SelectList(patient, "PatientID", "PatientName");

        return View();
    }

コントローラーの私のインデックス

// GET: Schedules
    public ActionResult Index()
    {

        //var schedules = db.Schedules.Include(s => s.AspNetUser).Include(s => s.Doctor).Include(s => s.Surgery).Include(s => s.Patient);
        //return View(schedules.ToList());
        var currentUser = User.Identity.GetUserId();
        var schedule = db.Schedules.Where(x => x.ClinicName == currentUser);


        return View(schedule);

        var surgery = db.Surgeries.Where(x => x.ClinicName == currentUser);
        ViewBag.Headers = surgery.Select(s => s.SurgeryName).ToList();

    }
4

1 に答える 1