Exemplo n.º 1
0
        /*      public JsonResult CheckBOverlapping(int PermissionGroupID, string PermissionGroupName)
              {
               //PermissionGroupID=id of the group which is assigned to the user //47
               //PermissionGroupName=name of permission Group..Pärnu mnt. 102-2.Grupp 5xx++abcMe++demo 2++All areas24/7

                  bool isOverlappping = false;
                  var upgName = _userPermissionGroupRepository.FindAll(x => x.Id == PermissionGroupID).Select(x => x.Name).FirstOrDefault();

                  List<List<int>> buildingObjectIDs = new List<List<int>>();
                  List<int> AllBuildingObjIDs = new List<int>();

                  //If user have more than 1 permision Group. 
                  if (upgName.Contains("++"))
                  {
                      var allPermissionGroups = upgName.Split(new[] { "++" }, StringSplitOptions.None);
                      foreach (var grpName in allPermissionGroups)
                      { 
                      var grpID = _userPermissionGroupRepository.FindAll(x => x.Name == grpName && x.ParentUserPermissionGroupId == null && x.IsDeleted == false).FirstOrDefault().Id;

                          //select all BuildingObjectID for the GroupId from USERTIMEZONE table				
                          var grp_buildingObjIDs = _userPermissionGroupTimeZoneRepository.FindAll(x => x.UserPermissionGroupId == grpID && !x.IsDeleted && x.Active).Select(x => x.BuildingObjectId).ToList();
                          foreach (var boid in grp_buildingObjIDs)
                          {
                              AllBuildingObjIDs.Add(boid);
                          }
                      }
                  }
                  else
                  {
                      //If User have only 1 Permission Group
                      var grpID = _userPermissionGroupRepository.FindAll(x => x.Name == upgName && x.ParentUserPermissionGroupId == null && x.IsDeleted == false).FirstOrDefault().Id;
                      var grp_buildingObjIDs = _userPermissionGroupTimeZoneRepository.FindAll(x => x.UserPermissionGroupId == grpID && !x.IsDeleted && x.Active).Select(x => x.BuildingObjectId).ToList();

                      foreach (var boid in grp_buildingObjIDs)
                      {
                          AllBuildingObjIDs.Add(boid);
                      }


                  }
                  if (AllBuildingObjIDs != null)
                  {
                      //  var query = AllBuildingObjIDs.GroupBy(x => x)
                      //.Where(g => g.Count() > 1)
                      //.Select(y => new { Element = y.Key, Counter = y.Count() })
                      //.ToList();

                      var query = AllBuildingObjIDs.GroupBy(x => x).Where(g => g.Count() > 1).Select(y => y.Key).ToList(); //?

                      //  var query2 = AllBuildingObjIDs.GroupBy(x => x)
                      //.Where(g => g.Count() > 1)
                      //.ToDictionary(x => x.Key, y => y.Count());

                      isOverlappping = query.Count > 0 ? true : false;
                  }
                  return Json(isOverlappping, JsonRequestBehavior.AllowGet);

              }
        */
        public JsonResult DelPermissionGroupFromUsers(int userId, int dltGroupId)
        {

            return Json(_userPermissionGroupService.DelPermissionGroupFromUsers(userId, dltGroupId), JsonRequestBehavior.AllowGet);

        }