I have problem with how to and where to add if condition in view which has two models in a single view.
This is view
@foreach (service_provider SP in ViewBag.service_provider) {
<tr>
<td>@SP.Sp_email</td>
<td>@SP.Sp_name</td>
<td>@SP.city.Cityname</td>
</tr>}@foreach (picture img in ViewBag.pictures){
<tr>
<td><img src="data:image/png;base64,@Convert.ToBase64String(img.pic,0,img.pic.Length)" width="100" />
</td>
</tr>
}
This is picture model
public int PIC_ID { get; set; }
public string pic_name { get; set; }
public Nullable<int> belong_id { get; set; }
public byte[] pic { get; set; }
This is service_provider model
public int SPID { get; set; }
public string Sp_email { get; set; }
public string Sp_password { get; set; }
public string Sp_name { get; set; }
This is my controller
public ActionResult Index(){
ViewBag.service_provider = dc.service_provider;
ViewBag.pictures = dc.pictures;
return View();
}
The purpose of the above view is to display details of the service_provider with it's picture by where belong_id in picture equals SPID in service_provider. but I couldn't understand where do I add if condition.I'm using Database first approach