コード例 #1
0
        public bool UpdatePermissionGroup(string user_ID, Permission_Group group)
        {
            var itemFromDb = base.DbConnection.Get <Permission_Group>(group.Group_ID);

            if (itemFromDb != null)
            {
                itemFromDb.LastUpdateBy   = user_ID;
                itemFromDb.LastUpdateDate = DateTime.Now;
                return(base.DbConnection.Update(group));
            }
            return(false);
        }
コード例 #2
0
        public async Task <bool> AddPermissionGroup(Permission_Group newGroup)
        {
            var lastID = await base.DbConnection.QueryFirstAsync <string>("SELECT MAX(Group_ID) FROM dbo.Permission_Group");

            if (await base.DbConnection.GetAsync <Permission_Group>(newGroup.Group_Name.ToLower()) == null)
            {
                newGroup.Group_ID       = "gp" + String.Format("{0:D5}", Int32.Parse(lastID.Substring(2)) + 1);
                newGroup.LastUpdateDate = DateTime.Now;
                await base.DbConnection.InsertAsync(newGroup);

                return(true);
            }
            return(false);
        }
コード例 #3
0
        public async Task <IActionResult> AddPermissionGroup(Permission_Group group, string user_ID)
        {
            //if(user_ID.Equals(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            //return Unauthorized();
            group.LastUpdateBy   = user_ID;
            group.LastUpdateDate = DateTime.Now;
            var isAdded = await _repo.AddPermissionGroup(group);

            if (isAdded)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #4
0
 protected void SaveChanges_Click(object sender, EventArgs e)
 {
     try
     {
         int Group_Id      = int.Parse(ddlGroups.SelectedValue.ToString());
         var Permision_Ids = PermissionGroupGridView.GetSelectedFieldValues("Permission_Id");
         db.Database.ExecuteSqlCommand("Delete Permission_Group where Group_Id = " + Group_Id);
         for (int i = 0; i < Permision_Ids.Count; i++)
         {
             Permission_Group per_group = db.Permission_Group.Create();
             per_group.Group_Id      = Group_Id;
             per_group.Permission_Id = int.Parse(Permision_Ids[i].ToString());
             db.Permission_Group.Add(per_group);
         }
         db.SaveChanges();
     }catch { }
 }
コード例 #5
0
        public IActionResult UpdatePermissionGroup(string id, string user_ID, Permission_Group permission_Group)
        {
            if (!user_ID.Equals(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            permission_Group.LastUpdateBy   = user_ID;
            permission_Group.LastUpdateDate = DateTime.Now;
            var isUpdated = _repo.UpdatePermissionGroup(id, permission_Group);

            if (isUpdated)
            {
                return(NoContent());
            }
            else
            {
                throw new Exception($"Updating Permission Group: {id} failed");
            }
        }
コード例 #6
0
 protected void SaveChanges_Click(object sender, EventArgs e)
 {
     try
     {
         int Group_Id      = int.Parse(ddlGroups.SelectedValue.ToString());
         var Permision_Ids = PermissionGroupGridView.GetSelectedFieldValues("Permission_Id");
         db.Database.ExecuteSqlCommand("Delete Permission_Group where Group_Id = " + Group_Id);
         for (int i = 0; i < Permision_Ids.Count; i++)
         {
             Permission_Group per_group = db.Permission_Group.Create();
             per_group.Group_Id      = Group_Id;
             per_group.Permission_Id = int.Parse(Permision_Ids[i].ToString());
             db.Permission_Group.Add(per_group);
         }
         db.SaveChanges();
         /* Add it to log file */
         LogData = "data:" + JsonConvert.SerializeObject(Group_Id, logFileModule.settings);
         logFileModule.logfile(10, "تعديل صلاحيات المجموعة", "update group permissions", LogData);
     }
     catch { }
 }