public ContactsViewModel(int?ID)
 {
     using (Dist23Data db = new Dist23Data())
     {
         contact          = db.Contacts.Where(c => c.pKey == ID).FirstOrDefault();
         positions        = db.ContactPosition.Where(p => p.ContactID == ID).ToList();
         contactPositions = new List <PositionViewModel>();
         foreach (ContactPosition pos in positions)
         {
             PositionViewModel pvm = new PositionViewModel();
             Positions         p   = db.Positions.Where(x => x.pKey == pos.PositionID).FirstOrDefault();
             Groups            g   = db.Groups.Where(x => x.pKey == pos.GroupID).FirstOrDefault();
             pvm.positionKey  = pos.pKey;
             pvm.PositionName = p.PositionName;
             pvm.GroupName    = g.GroupName;
             contactPositions.Add(pvm);
         }
     }
 }
Ejemplo n.º 2
0
 public ContactsViewModel(int? ID)
 {
     using(Dist23Data db = new Dist23Data())
     {
         contact = db.Contacts.Where(c => c.pKey == ID).FirstOrDefault();
         positions = db.ContactPosition.Where(p => p.ContactID == ID).ToList();
         contactPositions = new List<PositionViewModel>();
         foreach(ContactPosition pos in positions)
         {
             PositionViewModel pvm = new PositionViewModel();
             Positions p = db.Positions.Where(x => x.pKey == pos.PositionID).FirstOrDefault();
             Groups g = db.Groups.Where(x => x.pKey == pos.GroupID).FirstOrDefault();
             pvm.positionKey = pos.pKey;
             pvm.PositionName = p.PositionName;
             pvm.GroupName = g.GroupName;
             contactPositions.Add(pvm);
         }
     }
 }