コード例 #1
0
        // GET: Groups/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblGroups tblGroups = db.tblGroups.Find(id);

            if (tblGroups == null)
            {
                return(HttpNotFound());
            }

            GroupsViewModel    groupsViewModel    = new GroupsViewModel();
            ImplementedMethods implementedMethods = new ImplementedMethods();

            groupsViewModel.Name    = tblGroups.Name;
            groupsViewModel.PK_Id   = tblGroups.PK_Id;
            groupsViewModel.Actions = tblGroups.tblGroupActions.Select(s => new ActionsViewModel
            {
                PK_Id = s.PK_Id,
                Name  = s.ActionName
            }).ToList();

            ViewBag.AvailableActions = implementedMethods.ActiveMethods.Where(t => !db.tblGroupActions.Any(k => k.FK_Group == id && k.ActionName == t)).Select(s => new SelectListItem {
                Value = s, Text = s
            }).ToList();


            return(View(groupsViewModel));
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblGroups tblGroups = db.tblGroups.Find(id);

            db.tblGroups.Remove(tblGroups);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "PK_Id,Name")] tblGroups tblGroups)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblGroups).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblGroups));
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "PK_Id,Name")] tblGroups tblGroups)
        {
            if (ModelState.IsValid)
            {
                db.tblGroups.Add(tblGroups);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblGroups));
        }
コード例 #5
0
        // GET: Groups/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblGroups tblGroups = db.tblGroups.Find(id);

            if (tblGroups == null)
            {
                return(HttpNotFound());
            }
            return(View(tblGroups));
        }