Пример #1
0
 // GET: Groups/Details/5
 public ActionResult GroupsDetails(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Groups group = db.Groups.Find(id);
     GroupViewModel gvm = new GroupViewModel();
     gvm.pKey = group.pKey;
     gvm.group = group;
     ContactPosition cp = db.ContactPosition.Where(x => x.DistKey == GlobalVariables.DistKey).Where(x => x.GroupID == group.pKey).Where(x => x.PositionID == 2).FirstOrDefault();
     if (cp != null)
     {
         int GSRID = cp.ContactID;
         gvm.contact = db.Contacts.Where(x => x.pKey == GSRID).FirstOrDefault();
     }
     return View(gvm);
 }
Пример #2
0
 // GET: Groups
 public ActionResult GroupsIndex()
 {
     List<GroupViewModel> gvmList = new List<GroupViewModel>();
     var groupList = db.Groups.Where(x => x.DistKey == GlobalVariables.DistKey).ToList();
     foreach(Groups group in groupList)
     {
         GroupViewModel gvm = new GroupViewModel();
         gvm.group = group;
         gvm.pKey = group.pKey;
         ContactPosition cp = db.ContactPosition.Where(x => x.DistKey == GlobalVariables.DistKey).Where(x => x.GroupID == group.pKey).Where(x => x.PositionID == 2).FirstOrDefault();
         if (cp != null)
         {
             int GSRID = cp.ContactID;
             gvm.contact = db.Contacts.Where(x => x.pKey == GSRID).FirstOrDefault();
         }
         gvmList.Add(gvm);
     }
     return View(gvmList);
 }