Ejemplo n.º 1
0
 public static List<MemberViewModel> CreateIndexViewModel()
 {
     List<MemberViewModel> mvms = new List<MemberViewModel>();
     foreach (Member member in Repository.Members)
     {
         MemberViewModel mvm = new MemberViewModel();
         mvm.MemberData=member;
         mvm.CityName = CityRepository.Cities.FirstOrDefault(c => c.CityId == member.CityId).CityName;
         mvms.Add(mvm);
     }
     return mvms;
 }
Ejemplo n.º 2
0
 public static MemberViewModel CreateViewModel(int id)
 {
     Member member = Repository.Members.FirstOrDefault(m => m.Id == id);
     if (member != null)
     {
         MemberViewModel mvm = new MemberViewModel();
         mvm.MemberData = member;
         mvm.CityName = CityRepository.Cities.FirstOrDefault(c => c.CityId == member.CityId).CityName;
         return mvm;
     }
     else
     {
         return null;
     }
 }
Ejemplo n.º 3
0
 public ActionResult Display(int id)
 {
     Member member = Repository.Members.FirstOrDefault(m => m.Id == id);
     if (member != null)
     {
         MemberViewModel mvm = new MemberViewModel();
         mvm.MemberData = member;
         City city = CityRepository.Cities.FirstOrDefault(c => c.CityId == member.CityId);
         if (city != null)
         {
             mvm.CityName = city.CityName;
         }
         return View(mvm);
     }
     else
         return View("ErrorPage", (object)string.Format("{0} not found", id));
 }