public ActionResult Create(SabaqGroup sabaqgroup)
        {
            if (ModelState.IsValid)
            {
                db.SabaqGroups.Add(sabaqgroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            var         _roles = db.Roles.Include(u => u.Users);
            List <User> users  = new List <Models.User>();

            foreach (Role role in _roles)
            {
                if (role.RoleId == (int)ENRole.Moallim)
                {
                    users.AddRange(role.Users.ToList <User>());
                    break;
                }
            }

            ViewBag.NisaabId      = new SelectList(db.Nisaabs, "NisaabId", "NisaabName", sabaqgroup.NisaabId);
            ViewBag.MohallaId     = new SelectList(db.Regions.Where(c => c.RegionTypeId == (int)ENRegionType.Mohalla).Include(d => d.Region1), "RegionId", "RegionName", sabaqgroup.MohallaId);
            ViewBag.MoallimId     = new SelectList(users, "UserId", "DisplayName", sabaqgroup.MoallimId);
            ViewBag.SabaqStatusId = new SelectList(db.SabaqStatus, "SabaqStatusId", "SabaqStatusName", sabaqgroup.SabaqStatusId);
            return(View(sabaqgroup));
        }
        public ActionResult DeleteConfirmed(long id)
        {
            SabaqGroup sabaqgroup = db.SabaqGroups.Find(id);

            db.SabaqGroups.Remove(sabaqgroup);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //
        // GET: /SabaqGroup/Edit/5

        public ActionResult Edit(long id)
        {
            SabaqGroup sabaqgroup = db.SabaqGroups.Find(id);

            ViewBag.NisaabId      = new SelectList(db.Nisaabs, "NisaabId", "NisaabName", sabaqgroup.NisaabId);
            ViewBag.MohallaId     = new SelectList(db.Regions.Where(c => c.RegionTypeId == (int)ENRegionType.Mohalla).Include(d => d.Region1), "RegionId", "RegionName", sabaqgroup.MohallaId);
            ViewBag.MoallimId     = new SelectList(db.Users, "UserId", "DisplayName", sabaqgroup.MoallimId);
            ViewBag.SabaqStatusId = new SelectList(db.SabaqStatus, "SabaqStatusId", "SabaqStatusName", sabaqgroup.SabaqStatusId);
            return(View(sabaqgroup));
        }
 public ActionResult Edit(SabaqGroup sabaqgroup)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sabaqgroup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.NisaabId      = new SelectList(db.Nisaabs, "NisaabId", "NisaabName", sabaqgroup.NisaabId);
     ViewBag.MohallaId     = new SelectList(db.Regions.Where(c => c.RegionTypeId == (int)ENRegionType.Mohalla).Include(d => d.Region1), "RegionId", "RegionName", sabaqgroup.MohallaId);
     ViewBag.MoallimId     = new SelectList(db.Users, "UserId", "DisplayName", sabaqgroup.MoallimId);
     ViewBag.SabaqStatusId = new SelectList(db.SabaqStatus, "SabaqStatusId", "SabaqStatusName", sabaqgroup.SabaqStatusId);
     return(View(sabaqgroup));
 }
        //
        // GET: SabaqGroup/Register

        public ActionResult Register(int id)
        {
            SabaqGroup        sabaqGroup    = db.SabaqGroups.Find(id);
            List <SabaqGroup> lstSabaqGroup = new List <SabaqGroup>();

            lstSabaqGroup.Add(sabaqGroup);

            ViewBag.SabaqGroupId  = new SelectList(lstSabaqGroup, "SabaqGroupId", "GroupName", id);
            ViewBag.SabaqStatusId = new SelectList(db.SabaqStatus, "SabaqStatusId", "SabaqStatusName", (int)ENSabaqStatus.Approved);
            //ViewBag.MemberId = new SelectList(db.Users, "UserId", "UserID_DisplayName");

            var users = from u in db.Users
                        where !(from u1 in db.SabaqRegistrations
                                where u1.SabaqGroupId == sabaqGroup.SabaqGroupId
                                select u1.MemberId).Contains(u.UserId)
                        select u;

            SabaqRegistration model = new SabaqRegistration();

            model.AllMembers = new MultiSelectList(users, "UserId", "UserID_DisplayName").AsEnumerable();
            return(View(model));
        }
        //
        // GET: /SabaqGroup/Details/5

        public ViewResult Details(long id)
        {
            SabaqGroup sabaqgroup = db.SabaqGroups.Find(id);

            return(View(sabaqgroup));
        }
        //
        // GET: /SabaqGroup/Delete/5

        public ActionResult Delete(long id)
        {
            SabaqGroup sabaqgroup = db.SabaqGroups.Find(id);

            return(View(sabaqgroup));
        }