Click here to Skip to main content
15,891,703 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I am trying to query my database and show two results on the same pages

C#
var datafalse = (from u in _db.aspnet_Users
                                  join d in _db.Doctors on u.UserId equals d.UserId
                                  join p in _db.Patients on d.DoctorsId equals p.DoctorsId
                                  where u.UserName == User.Identity.Name && p.reviewed == false
                                  orderby p.ClientID
                                  select
                                       new PatientsModel
                                            {
                                                 PatientsId = p.PatientsId,
                                                 ClientID = p.ClientID,
                                                 DOB = p.DOB,
                                                 Gender = p.Gender,
                                                 Handedness = p.Handedness,
                                                 RecordingDate = p.RecordingDate,
                                                 TimeRecording = p.TimeRecording
                                            }).ToList();

                       var datatrue = (from u in _db.aspnet_Users
                                  join d in _db.Doctors on u.UserId equals d.UserId
                                  join p in _db.Patients on d.DoctorsId equals p.DoctorsId
                                  where u.UserName == User.Identity.Name && p.reviewed == false
                                  orderby p.ClientID
                                  select
                                       new PatientsModel
                                       {
                                            PatientsId = p.PatientsId,
                                            ClientID = p.ClientID,
                                            DOB = p.DOB,
                                            Gender = p.Gender,
                                            Handedness = p.Handedness,
                                            RecordingDate = p.RecordingDate,
                                            TimeRecording = p.TimeRecording
                                       }).ToList();


view/html page.

HTML
h2>Doctors Submitted List Patients </h2>
<hr />
<div>
<h2>Submitted Request need to be reviewed </h2>
<p>
<table>
<tr>
<th>Client ID</th>
<th>DOB</th>
<th>Gender</th>
<th>Handedness</th>
<th>Date of Recording</th>
@*<th>Time of Recording</th>*@
<th>View Details</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.ClientID)</td>
<td>@Html.DisplayFor(modelItem => item.DOB)</td>
<td>@Html.DisplayFor(modelItem => item.Gender)</td>
<td>@Html.DisplayFor(modelItem => item.Handedness)</td>
<td>@Html.DisplayFor(modelItem => item.RecordingDate)</td>
@*<td>@Html.DisplayFor(modelItem => item.TimeRecording)</td>*@
<td>@Html.ActionLink("Details", "Details", new { id = item.PatientsId })
</td>
     </tr>
}
</table>
</p>
</div>
<hr />
<div>
    
     <h2>Reports are that was reveiwed.</h2>
          <p>
               <table>
                    <tr>
                         <th>Client ID</th>
                         <th>DOB</th>
                         <th>Gender</th>
                         <th>Handedness</th>
                         <th>Date of Recording</th>
                         <th>View Details</th>
                    </tr>
                    @foreach (var item in Model)
                    {
                         <tr>
                              <td>@Html.DisplayFor(modelItem => item.ClientID)</td>
                              <td>@Html.DisplayFor(modelItem => item.DOB)</td>
                              <td>@Html.DisplayFor(modelItem => item.Gender)</td>
                              <td>@Html.DisplayFor(modelItem => item.Handedness)</td>
                              <td>@Html.DisplayFor(modelItem => item.RecordingDate)</td>
                              @*<td>@Html.DisplayFor(modelItem => item.TimeRecording)</td>*@
                              <td>@Html.ActionLink("Details", "Details", new { id = item.PatientsId })
                              </td>
                         </tr>
                    }
               </table>

          </p>

</div>
Posted

1 solution

Hi

My suggestion is just retrieve all data and store it in viewdata or model

in design side you need to write simple if condition to check which is true or false

I hope you've "reviewd" property in "PatientsModel" Model
If you 've it then its simple to display

HTML
@foreach (var item in Model)
                    {
if(item.reviewed)
{
                         <tr>
                              <td>@Html.DisplayFor(modelItem => item.ClientID)</td>
                              <td>@Html.DisplayFor(modelItem => item.DOB)</td>
                              <td>@Html.DisplayFor(modelItem => item.Gender)</td>
                              <td>@Html.DisplayFor(modelItem => item.Handedness)</td>
                              <td>@Html.DisplayFor(modelItem => item.RecordingDate)</td>
                              @*<td>@Html.DisplayFor(modelItem => item.TimeRecording)</td>*@
                              <td>@Html.ActionLink("Details", "Details", new { id = item.PatientsId })
                              </td>
                         </tr>
                    }
}


so you can display only true in one show and false in another show

I hope you understood wht I said

All the Best
 
Share this answer
 
Comments
postonoh 16-Apr-12 9:40am    
if (item.reviewed == false)
if (item.reviewed == true)
postonoh 16-Apr-12 10:07am    
not working
postonoh 16-Apr-12 10:13am    
Made one change it works thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900