public Hashtable GetUsersInWorkFlowLevel(int workFlowId, int workFlowLevelId, UserProfileFilter filter,
            UserProfileItem user)
        {

            var usersInWorkflow =
                _workFlowService.GetUsersInWorkflow(workFlowId, user.WorkFlowRefId)
                    .Select(u => Convert.ToInt64(u.ActorRefId))
                    .ToList();
            var usersInWorkflowLevel =
                _workFlowService.GetUsersInLevel(workFlowLevelId)
                .Select(u => Convert.ToInt64(u.ActorRefId))
                    .ToList();


            var presentFilter = new UserProfileFilter()
            {
                StateId = filter.StateId,
                LgaId = filter.LgaId,
                DistrictId = filter.DistrictId,
                Roles = filter.Roles,
                PresentIds = usersInWorkflowLevel
            };
            var absentfilter = new UserProfileFilter()
            {
                StateId = filter.StateId,
                LgaId = filter.LgaId,
                DistrictId = filter.DistrictId,
                Roles = filter.Roles,
               AbsentIds = usersInWorkflow
            };
            var personalInfoInWorkflowLevel = _userProfileRepository.GetUserProfileFilteredQueryable(presentFilter).ToList();

            var personalInfoNotInWorkFlowLevel = _userProfileRepository.GetUserProfileFilteredQueryable(absentfilter).ToList();

            var table = new Hashtable();
            table["PresentUsers"] =
                personalInfoInWorkflowLevel.Select(p => new {p.Id, p.FirstName, p.LastName, p.Username});
            table["AbsentUsers"] =
                personalInfoNotInWorkFlowLevel.Select(p => new {p.Id, p.FirstName, p.LastName, p.Username});
            return table;
        }
Example #2
0
 public void CreateSuperAdminUserProfile(UserProfileItem model, string createdBy)
 {
     try
     {
         Mapper.CreateMap<UserProfileItem, UserProfile>();
         _unitOfWork.BeginTransaction();
         var entity = Mapper.Map<UserProfileItem, UserProfile>(model);
         entity.CreatedBy = createdBy;
         entity.StateId = null;
         entity.RoleId = Convert.ToInt32(RolesConstants.Enum.SuperAdmin);
         entity.CreatedDate = DateTime.Now;
         _repository.Insert(entity);
         _unitOfWork.Commit();
     }
     catch (Exception)
     {
         _unitOfWork.Rollback();
         throw;
     }
 }
        private UserProfileFilter ProcessRolesFilterManageUsers(string workflowName,UserProfileItem user, IList<string> currentUserRoles)
        {
            const string setupIdentitfier = "setup";
            const string activityIdentifier = "activity";
            var userFilter = new UserProfileFilter();

            var rolesToFilter = new List<int>();
            
                currentUserRoles.ForEach(r =>
                {
                    switch (r)
                    {
                        case RolesConstants.SuperAdmin:
                            if (workflowName.ToLower().Contains(activityIdentifier))
                            {
                                rolesToFilter.AddRange(new int[]
                                {
                                    RolesConstants.RoleIdsDictionary[RolesConstants.ActivitySuperAdmin],
                                });
                            }
                            else 
                            {
                                rolesToFilter.AddRange(new int[]
                                {
                                    RolesConstants.RoleIdsDictionary[RolesConstants.SetupSuperAdmin]
                                });
                            }
                            break;
                        case RolesConstants.StateAdmin:
                            userFilter.StateId = user.StateId;
                            if (workflowName.ToLower().Contains(activityIdentifier))
                            {
                                rolesToFilter.AddRange(new int[]
                                {
                                    RolesConstants.RoleIdsDictionary[RolesConstants.ActivityStateAdmin],
                                });
                            }
                            else 
                            {
                                rolesToFilter.AddRange(new int[]
                                {
                                    RolesConstants.RoleIdsDictionary[RolesConstants.SetupStateAdmin]
                                });
                            }
                            break;
                    }
                });
            userFilter.Roles = rolesToFilter;
            return userFilter;
        }