示例#1
0
        public void AddRole(RoleW role, string[] features)
        {
            role.Id = Guid.NewGuid();
            Db.Roles.Add(role.ToBase());
            MakeRoleFeatureConnections(role.Id, features);

            Db.SaveChanges();
        }
示例#2
0
        public void EditRole(RoleW roleW, string[] features)
        {
            var role = this.GetBaseRole(roleW.Id);

            role.DisplayName = roleW.DisplayName;
            MakeRoleFeatureConnections(role.Id, features);

            Db.SaveChanges();
        }
示例#3
0
        public ActionResult Edit([Bind(Include = "Id,DisplayName")] RoleW role, string[] features)
        {
            if (ModelState.IsValid)
            {
                Rep.EditRole(role, features);
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
示例#4
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            RoleW role = Rep.GetRole(id.Value);

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

            ViewBag.Features = Rep.GetFeatures();
            return(View(role));
        }
示例#5
0
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            RoleW role = Rep.GetRole(id.Value);

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

            if (Request.IsAjaxRequest())
            {
                return(PartialView(role));
            }

            return(View(role));
        }