asp.net mvc - MVC 5 c# foreach over ViewBag containing 3 Lists in View -
i have userprofilemodel contains standard profile items plus 2 list of classes contain userlanguages , userpendingitems. have seen number of questions similar not help me...
userprofilemodels
public class userprofilemodels { [key] public string userprofileid { get; set; } // same user id public string userprofilepictureurl { get; set; } public string userprofilecompanyid { get; set; } // same company id // if userprofilecompanyid empty european union individual , next fields available // else info companyprofile public string userprofilestreet { get; set; } public string userprofiletown { get; set; } public string userprofilecountry { get; set; } // allows decide on currency, timezone, state / county, post code / zip etc public string userprofilestate { get; set; } public string userprofilepostcode { get; set; } public string userprofiledob { get; set; } // date of birth public string userprofilesex { get; set; } public string userprofilerole { get; set; } // if role > "client" next fields used. public string userprofiletelephonenumber { get; set; } public string userprofilemobilenumber { get; set; } public list<userlanguagemodels> userlanguages { get; set; } public list<userprofilependingitems> userpendingitems { get; set; } }
userprofilependingitems
public class userprofilependingitems { public string userprofileid { get; set; } public string userprofiledescription { get; set; } }
userlanguagemodels
public class userlanguagemodels { public string userprofileid { get; set; } public string userlanguage { get; set; } }
in view there dropdown menu contains list of userspendingitems
view
<ul class="dropdown-menu extended tasks-bar"> <div class="notify-arrow notify-arrow-green"></div> <li> <p class="green">@viewbag.pendingmessages.count()</p> </li>
problems begin here
@foreach (ccslabs.controllers.administration.administrationcontroller.userprofile message in viewbag.pendingmessages) { <li> <a href="index.html#"> <div class="task-info"> <div class="desc">@message.userpendingitems.</div> <div class="percent">40%</div> </div> <div class="progress progress-striped"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%"> <span class="sr-only">40% finish (success)</span> </div> </div> </a> </li> }
so thought within user's profile have list of items need (pending items). send view via viewbag (there much improve way of doing this!) foreach on viewbag , create dropdown menu.
however,
i going end much code logic in view making nightmare maintain. i can't see pendingitemsmodel within viewbag anyway.questions
how can send first 4 or 5 pendingitems, user has, view how create iteration of view list items generate drop downwards menu using little code in view possible. c# asp.net-mvc model viewbag
No comments:
Post a Comment