Beispiel #1
0
        //
        // GET: /Permission/Details/5

        public ActionResult Details(Guid id)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, admin))
            {
                return(RedirectToAction("Index", "Home"));
            }

            Authoring.WebRole.Models.Permission permission = db.Permissions.Single(p => p.ID == id);
            return(View(permission));
        }
Beispiel #2
0
        //
        // GET: /Permission/Edit/5

        public ActionResult Edit(Guid id)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, admin))
            {
                return(RedirectToAction("Index", "Home"));
            }

            Authoring.WebRole.Models.Permission permission = db.Permissions.Single(p => p.ID == id);
            ViewBag.CreatedBy  = new SelectList(db.Users, "ID", "UserName", permission.CreatedBy);
            ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", permission.ModifiedBy);
            return(View(permission));
        }
Beispiel #3
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, admin))
            {
                return(RedirectToAction("Index", "Home"));
            }

            Authoring.WebRole.Models.Permission permission = db.Permissions.Single(p => p.ID == id);
            permission.ModifiedBy = Guid.Parse(Session["userid"].ToString());
            permission.ModifiedOn = DateTime.Now;
            permission.IsDeleted  = true;
            db.ObjectStateManager.ChangeObjectState(permission, EntityState.Modified);
            //db.Permissions.DeleteObject(permission);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public ActionResult Edit(Authoring.WebRole.Models.Permission permission)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, admin))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid)
            {
                db.Permissions.Attach(permission);
                permission.ModifiedBy = Guid.Parse(Session["userid"].ToString());
                permission.ModifiedOn = DateTime.Now;
                db.ObjectStateManager.ChangeObjectState(permission, EntityState.Modified);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CreatedBy  = new SelectList(db.Users, "ID", "UserName", permission.CreatedBy);
            ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", permission.ModifiedBy);
            return(View(permission));
        }
Beispiel #5
0
        private static bool GetPermission(byte rolepermission, string reqpermission)
        {
            //string user = HttpContext.User.Identity.Name;

            Authoring.WebRole.Models.Permission permission = db.Permissions.FirstOrDefault(p => p.Permission1 == reqpermission && (p.IsDeleted == null || p.IsDeleted == false));
            if (permission == null)
            {
                return(false);
            }
            byte requestpermission = permission.IntRepresentation.HasValue == true ? permission.IntRepresentation.Value : (byte)0;

            int providedPermission = rolepermission & requestpermission;

            if (providedPermission < requestpermission)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
 /// <summary>
 /// Create a new Permission object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="permission1">Initial value of the Permission1 property.</param>
 public static Permission CreatePermission(global::System.Guid id, global::System.String permission1)
 {
     Permission permission = new Permission();
     permission.ID = id;
     permission.Permission1 = permission1;
     return permission;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Permissions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPermissions(Permission permission)
 {
     base.AddObject("Permissions", permission);
 }