Exemplo n.º 1
0
        public DataSourceResult Search(DataSourceRequest dsRequest, int caseId, int workerId, int?caseMemberId)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }
            if (caseMemberId.HasValue && caseMemberId > 0)
            {
                FilterDescriptor filterDescriptor = new FilterDescriptor("CaseMemberID", FilterOperator.IsEqualTo, caseMemberId.Value);
                dsRequest.Filters.Add(filterDescriptor);
            }
            bool hasReadPermission     = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseMemberProfile, Constants.Actions.Read, true);
            bool hasEditPermission     = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseMemberProfile, Constants.Actions.Edit, true);
            bool hasDeletePermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseMemberProfile, Constants.Actions.Delete, true);
            bool IsUserAdminWorker     = CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1;
            bool IsUserRegionalManager = CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) != -1;

            List <CaseAssessment> caseAssessmentList = context.CaseAssessment
                                                       //.Join(context.CaseWorkerMemberAssignment, left => left.CaseMemberID, right => right.CaseMemberID, (left, right) => new { left, right })
                                                       //.Where(item => item.left.CaseMember.CaseID == caseId && item.right.CaseWorker.WorkerID == workerId)
                                                       .Where(item => item.CaseMember.CaseID == caseId)
                                                       //<JL:Comment:06/18/2017>
                                                       //.Where(item => context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(item.CaseMemberID) || IsUserAdminWorker)
                                                       .OrderByDescending(item => item.CreateDate).AsEnumerable().ToList()
                                                       .Select(
                caseassessment => new CaseAssessment()
            {
                ID                      = caseassessment.ID,
                CaseMemberID            = caseassessment.CaseMemberID,
                AssessmentTypeID        = caseassessment.AssessmentTypeID,
                AssessmentTypeName      = caseassessment.AssessmentType != null ? caseassessment.AssessmentType.Name : "",
                MemberStatusID          = caseassessment.MemberStatusID,
                DocumentedByID          = caseassessment.DocumentedByID,
                DocumentedByName        = caseassessment.DocumentedBy != null && caseassessment.DocumentedBy.Worker != null ? caseassessment.DocumentedBy.Worker.FirstName + " " + caseassessment.DocumentedBy.Worker.LastName : "",
                CaseMemberName          = caseassessment.CaseMember != null ? caseassessment.CaseMember.FirstName + " " + caseassessment.CaseMember.LastName : string.Empty,
                StartDate               = caseassessment.StartDate,
                EndDate                 = caseassessment.EndDate,
                ReasonsForDischargeName = caseassessment.ReasonsForDischarge != null ? caseassessment.ReasonsForDischarge.Name : "",
                CaseID                  = caseId,
                HasPermissionToRead     = hasReadPermission ? "" : "display:none;",
                //HasPermissionToEdit = IsUserAdminWorker || (caseassessment.AssessmentTypeID != 2 && hasEditPermission) || IsUserRegionalManager ? "" : "display:none;",
                HasPermissionToEdit   = IsUserAdminWorker || hasEditPermission || IsUserRegionalManager ? "" : "display:none;",
                HasPermissionToDelete = hasDeletePermission ? "" : "display:none;"
            }
                ).ToList();

            if (caseAssessmentList != null)
            {
                foreach (CaseAssessment caseAssessment in caseAssessmentList)
                {
                    caseAssessment.QualityOfLifeNames = string.Join(",", context.CaseAssessmentLivingCondition.Where(item => item.CaseAssessmentID == caseAssessment.ID).Select(item => item.QualityOfLife.Name));
                }
            }
            DataSourceResult dsResult = caseAssessmentList.ToDataSourceResult(dsRequest);

            return(dsResult);
        }
        public DataSourceResult Search(DataSourceRequest dsRequest, int caseId, int workerId, int?caseMemberId)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }
            if (caseMemberId.HasValue && caseMemberId > 0)
            {
                FilterDescriptor filterDescriptor = new FilterDescriptor("CaseMemberID", FilterOperator.IsEqualTo, caseMemberId.Value);
                dsRequest.Filters.Add(filterDescriptor);
            }
            bool             hasReadPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseMemberProfile, Constants.Actions.Read, true);
            bool             hasEditPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseMemberProfile, Constants.Actions.Edit, true);
            bool             hasDeletePermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseMemberProfile, Constants.Actions.Delete, true);
            bool             IsUserAdminWorker   = CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1;
            DataSourceResult dsResult            = context.CaseMemberProfile
                                                   //.Join(context.CaseWorkerMemberAssignment, left => left.CaseMemberID, right => right.CaseMemberID, (left, right) => new { left, right })
                                                   //.Where(item => item.left.CaseMember.CaseID == caseId && item.right.CaseWorker.WorkerID == workerId)
                                                   .Where(item => item.CaseMember.CaseID == caseId)
                                                   //<JL:Comment:06/18/2017>
                                                   //.Where(item => context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(item.CaseMemberID) || IsUserAdminWorker)
                                                   .OrderByDescending(item => item.ProfileDate).ToList()
                                                   .AsEnumerable()
                                                   .Select(
                item => new CaseMemberProfile()
            {
                ID = item.ID,
                CreatedByWorkerName         = item.CreatedByWorker.FirstName + " " + item.CreatedByWorker.LastName,
                ProfileDate                 = item.ProfileDate,
                ProfileTypeName             = item.ProfileType != null ? item.ProfileType.Name : "",
                HighestLevelOfEducationName = item.HighestLevelOfEducation != null ? item.HighestLevelOfEducation.Name : "",
                AnnualIncomeName            = item.AnnualIncome != null ? item.AnnualIncome.Name : "",
                HousingQualityName          = item.HousingQuality != null ? item.HousingQuality.Name : "",
                HousingQualityNote          = item.HousingQualityNote,
                HealthCondition             = item.HealthCondition,
                Occupation          = item.Occupation,
                CaseID              = item.CaseMember.CaseID,
                CaseMemberID        = item.CaseMemberID,
                ProfileTypeID       = item.ProfileTypeID,
                HasPermissionToRead = IsUserAdminWorker || hasReadPermission ? "" : "display:none;",
                //HasPermissionToEdit = IsUserAdminWorker || (item.ProfileTypeID != 2 && hasEditPermission) ? "" : "display:none;",
                HasPermissionToEdit   = IsUserAdminWorker || hasEditPermission ? "" : "display:none;",
                HasPermissionToDelete = IsUserAdminWorker || hasDeletePermission ? "" : "display:none;"
            }
                ).ToDataSourceResult(dsRequest);

            return(dsResult);
        }
        public DataSourceResult Search(DataSourceRequest dsRequest, int?caseprogressNoteId)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }

            bool             hasEditPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseProgressNote, Constants.Actions.Edit, true);
            bool             hasDeletePermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseProgressNote, Constants.Actions.Delete, true);
            DataSourceResult dsResult            = context.CaseProgressNoteMembers
                                                   //.Join(context.CaseWorkerMemberAssignment, left => left.CaseMemberID, right => right.CaseMemberID, (left, right) => new { left, right })

                                                   .Where(item => item.CaseProgressNoteID == caseprogressNoteId)
                                                   .ToDataSourceResult(dsRequest);

            return(dsResult);
        }
Exemplo n.º 4
0
        public DataSourceResult Search(DataSourceRequest dsRequest, int caseId, int CaseGoalId)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }
            bool          hasEditPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseAction, Constants.Actions.Edit, true);
            bool          hasDeletePermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseAction, Constants.Actions.Delete, true);
            StringBuilder sqlQuery            = new StringBuilder(@"SELECT [CA].[ID]
                                                        ,[CG].[GoalStatusID]
                                                        ,[CG].[PriorityTypeID]
                                                        ,[CA].[WorkerID]
                                                        ,[CA].[CaseMemberID]
                                                        ,[CA].[ServiceProviderID]
                                                        ,GAR.Name AS AssigneeRole
	                                                    ,CASE 
                                                        WHEN [CA].[CaseMemberID] IS NOT NULL THEN CM.FirstName + ' ' + CM.LastName
                                                        WHEN [CA].[ServiceProviderID] IS NOT NULL AND SP.Name <> 'Other' THEN SP.Name 
                                                        WHEN [CA].[ServiceProviderID] IS NOT NULL AND SP.Name = 'Other' THEN SP.Name + '-' + CA.AssigneeOther
		                                                WHEN [CA].[WorkerID] > 0 THEN [W].[FirstName] + ' ' + [W].[LastName]
                                                        WHEN [CA].[WorkerID] IS NULL AND ISNULL(CA.SubjectMatterExpertOther,'') <> '' THEN 'Subject Matter Expert - ' + CA.SubjectMatterExpertOther
                                                        ELSE CA.AssigneeOther 
		                                                END [AssignedTo]
                                                        ,[ActionDetail]
                                                        ,[CA].[CreatedByWorkerID]
                                                        ,[CA].[LastUpdatedByWorkerID]
                                                        ,[CA].[IsArchived]
                                                        ,[CA].[CreateDate]
                                                        ,[CA].[LastUpdateDate]
                                                        ," + caseId + @" [CaseID]
                                                        ,'" + hasDeletePermission.ToDisplayStyle() + @"' [HasPermissionToDelete]
                                                        ,'" + hasEditPermission.ToDisplayStyle() + @"' [HasPermissionToEdit]");

            sqlQuery.Append(@" FROM [dbo].[CaseActionNew] [CA] 
                            INNER JOIN CaseGoal AS CG ON CA.CaseGoalID = CG.ID
                            INNER JOIN GoalAssigneeRole AS GAR ON CA.GoalAssigneeRoleID = GAR.ID
                            LEFT JOIN [dbo].[Worker] [W] ON [CW].[WorkerID]= [W].[ID]
                            LEFT JOIN CaseMember CM ON CM.ID = [CA].[CaseMemberID]
                            LEFT JOIN ServiceProvider SP ON SP.ID = [CA].[ServiceProviderID]
                            WHERE [CA].IsArchived = 0 AND CA.CaseGoalID = " + CaseGoalId);
            sqlQuery.Append(" ORDER BY [CA].[CreateDate] DESC");
            DataSourceResult dsResult = context.Database.SqlQuery <CaseActionNew>(sqlQuery.ToString()).AsEnumerable().ToDataSourceResult(dsRequest);

            return(dsResult);
        }
Exemplo n.º 5
0
        public DataSourceResult Search(DataSourceRequest dsRequest, int caseId, int workerId, int?caseMemberId)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }
            if (caseMemberId.HasValue && caseMemberId > 0)
            {
                FilterDescriptor filterDescriptor = new FilterDescriptor("CaseMemberID", FilterOperator.IsEqualTo, caseMemberId.Value);
                dsRequest.Filters.Add(filterDescriptor);
            }
            bool hasReadPermission    = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseGoal, Constants.Actions.Read, true);
            bool hasEditPermission    = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseGoal, Constants.Actions.Edit, true);
            bool hasDeletePermission  = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseGoal, Constants.Actions.Delete, true);
            bool hasSetGoalPermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseSmartGoal, Constants.Actions.Create, true);
            bool IsUserAdminWorker    = CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1;
            //DataSourceResult dsResult = context.CaseGoal
            //    //.Join(context.CaseWorkerMemberAssignment, left => left.CaseMemberID, right => right.CaseMemberID, (left, right) => new { left, right })
            //    //.Where(item => item.left.CaseMember.CaseID == caseId && item.right.CaseWorker.WorkerID == workerId)
            //    .Where(item => item.CaseMember.CaseID == caseId)
            //    .Where(item => context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(item.CaseMemberID) || workerRoleIDs.Contains("1"))
            //    .OrderByDescending(item => item.CreateDate).ToList()
            //    .Select(
            //    caseGoal => new
            //    {
            //        caseGoal.ID,
            //        caseGoal.CaseMemberID,
            //        CaseMemberName = caseGoal.CaseMember.FirstName + " " + caseGoal.CaseMember.LastName,
            //        caseGoal.StartDate,
            //        caseGoal.EndDate,
            //        caseGoal.WishInLife,
            //        CaseID = caseId,
            //        HasPermissionToEdit = CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1 || hasEditPermission ? "" : "display:none;",
            //        HasPermissionToDelete = hasDeletePermission ? "" : "display:none;",
            //        HasPermissionToCreateSmartGoal = hasSetGoalPermission ? "" : "display:none;"
            //    }
            //    ).ToDataSourceResult(dsRequest);

            List <CaseGoal> caseGoalList = context.CaseGoal
                                           .Where(item => item.CaseMember.CaseID == caseId)
                                           //<JL:Comment:06/18/2017>
                                           //.Where(item => context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(item.CaseMemberID) || IsUserAdminWorker)
                                           .OrderByDescending(item => item.CreateDate).AsEnumerable().ToList()
                                           .Select(
                caseGoal => new CaseGoal()
            {
                ID                             = caseGoal.ID,
                CaseMemberID                   = caseGoal.CaseMemberID,
                CaseMemberName                 = caseGoal.CaseMember.FirstName + " " + caseGoal.CaseMember.LastName,
                StartDate                      = caseGoal.StartDate,
                EndDate                        = caseGoal.EndDate,
                WishInLife                     = caseGoal.WishInLife,
                CaseID                         = caseId,
                HasPermissionToRead            = IsUserAdminWorker || hasReadPermission ? "" : "display:none;",
                HasPermissionToEdit            = IsUserAdminWorker || hasEditPermission ? "" : "display:none;",
                HasPermissionToDelete          = hasDeletePermission ? "" : "display:none;",
                HasPermissionToCreateSmartGoal = hasSetGoalPermission ? "" : "display:none;"
            }
                ).ToList();

            if (caseGoalList != null)
            {
                foreach (CaseGoal caseGoal in caseGoalList)
                {
                    List <CaseGoalLivingCondition> qolList = context.CaseGoalLivingCondition.Where(item => item.CaseGoalID == caseGoal.ID).ToList();
                    if (qolList != null)
                    {
                        foreach (CaseGoalLivingCondition qol in qolList)
                        {
                            caseGoal.QualityOfLifeCategoryNames = caseGoal.QualityOfLifeCategoryNames.Concate(",", qol.QualityOfLifeCategory.Name);
                        }
                    }
                }
            }

            return(caseGoalList.ToDataSourceResult(dsRequest));
        }
Exemplo n.º 6
0
        public DataSourceResult Search(DataSourceRequest dsRequest, int caseId, int workerId, int?caseMemberId, bool isCompleted, int caseSmartGoalId, int caseProgressNoteId, int casesmartgoalserviceproviderid, bool includeServiceProviderAction, bool isProviderAction)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }
            bool          hasEditPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseAction, Constants.Actions.Edit, true);
            bool          hasDeletePermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseAction, Constants.Actions.Delete, true);
            StringBuilder sqlQuery            = new StringBuilder(@"SELECT [CA].[ID]
                                                        ,[CA].[CaseProgressNoteID]
	                                                    ,[CA].[CaseSmartGoalID]
                                                        ,[CA].[CaseSmartGoalServiceProviderID]
                                                        ,[CA].[CaseWorkerID]
                                                        ,[CA].[CaseMemberID]
	                                                    ,CASE 
		                                                --WHEN [CA].[CaseMemberID] IS NOT NULL THEN(SELECT CM.FirstName+' '+CM.LastName FROM CaseMember CM where CM.ID=[CA].[CaseMemberID])
                                                        WHEN [CA].[CaseMemberID] IS NOT NULL THEN CM.FirstName+' '+CM.LastName
		                                                ELSE [W].[FirstName]+' '+[W].[LastName]
		                                                END [CaseWorkerName]
                                                        ,[Action]
                                                        ,[ActionStartTime]
                                                        ,[ActionEndTime]
                                                        ,[IsCompleted]
                                                        ,[CA].[CreatedByWorkerID]
                                                        ,[CA].[LastUpdatedByWorkerID]
                                                        ,[CA].[IsArchived]
                                                        ,[CA].[CreateDate]
                                                        ,[CA].[LastUpdateDate]
                                                        ," + caseId + @" [CaseID]
                                                        ,'" + hasDeletePermission.ToDisplayStyle() + @"' [HasPermissionToDelete]
                                                        ,'" + hasEditPermission.ToDisplayStyle() + @"' [HasPermissionToEdit]");

            if (isProviderAction)
            {
                sqlQuery.Append(", (SELECT TOP 1 SP.Name FROM CaseSmartGoalServiceProvider CSGSP LEFT JOIN ServiceProvider SP ON CSGSP.ServiceProviderID=SP.ID WHERE CSGSP.ID=[CA].[CaseSmartGoalServiceProviderID]) AS ServiceProviderName");
            }
            sqlQuery.Append(@" FROM [dbo].[CaseAction] [CA] 
                                                    LEFT JOIN [dbo].[CaseWorker] [CW] ON [CA].[CaseWorkerID]= [CW].[ID]
                                                    LEFT JOIN [dbo].[Worker] [W] ON [CW].[WorkerID]= [W].[ID]
                                                    LEFT JOIN CaseMember CM ON CM.ID=[CA].[CaseMemberID]
                                                    WHERE [CA].IsArchived=0");
            if (caseMemberId.HasValue && caseMemberId.Value > 0 && caseSmartGoalId == 0 && caseProgressNoteId == 0 && casesmartgoalserviceproviderid == 0)
            {
                sqlQuery.Append(" AND ( [CA].[CaseProgressNoteID] IN (SELECT CPN.ID FROM CaseProgressNote CPN WHERE CPN.CaseMemberID=" + caseMemberId.Value + ")");
                sqlQuery.Append(" OR ( [CA].[CaseProgressNoteID] IN (SELECT CPN.CaseProgressNoteID FROM CaseProgressNoteMembers CPN WHERE CPN.CaseMemberID=" + caseMemberId.Value + "))");
                sqlQuery.Append(" OR ( [CA].[CaseSmartGoalID] IN (SELECT CSG.ID FROM CaseSmartGoal CSG LEFT JOIN CaseGoal CG ON CG.ID=CSG.CaseGoalID WHERE CG.CaseMemberID=" + caseMemberId.Value + "))");
                sqlQuery.Append(" OR ( [CA].[CaseSmartGoalServiceProviderID] IN (SELECT CSGSP.ID FROM CaseSmartGoalServiceProvider CSGSP LEFT JOIN CaseSmartGoal CSG ON CSG.ID=CSGSP.CaseSmartGoalID LEFT JOIN CaseGoal CG ON CG.ID=CSG.CaseGoalID WHERE CG.CaseMemberID=" + caseMemberId.Value + "))");
                sqlQuery.Append(" ) ");
            }
            else if (caseId > 0 && caseSmartGoalId == 0 && caseProgressNoteId == 0 && casesmartgoalserviceproviderid == 0)
            {
                sqlQuery.Append(" AND ( [CA].[CaseProgressNoteID] IN (SELECT CPN.ID FROM CaseProgressNote CPN WHERE CPN.CaseMemberID IN (SELECT ID FROM CaseMember WHERE CaseID=" + caseId + "))");
                sqlQuery.Append(" OR ( [CA].[CaseProgressNoteID] IN (SELECT CPN.CaseProgressNoteID FROM CaseProgressNoteMembers CPN WHERE CPN.CaseMemberID IN (SELECT ID FROM CaseMember WHERE CaseID=" + caseId + ")))");
                sqlQuery.Append(" OR ( [CA].[CaseSmartGoalID] IN (SELECT CSG.ID FROM CaseSmartGoal CSG LEFT JOIN CaseGoal CG ON CG.ID=CSG.CaseGoalID WHERE CG.CaseMemberID IN (SELECT ID FROM CaseMember WHERE CaseID=" + caseId + ")))");
                sqlQuery.Append(" OR ( [CA].[CaseSmartGoalServiceProviderID] IN (SELECT CSGSP.ID FROM CaseSmartGoalServiceProvider CSGSP LEFT JOIN CaseSmartGoal CSG ON CSG.ID=CSGSP.CaseSmartGoalID LEFT JOIN CaseGoal CG ON CG.ID=CSG.CaseGoalID WHERE CG.CaseMemberID IN (SELECT ID FROM CaseMember WHERE CaseID=" + caseId + ")))");
                sqlQuery.Append(" ) ");
            }
            else if (workerId > 0 && caseSmartGoalId == 0 && caseProgressNoteId == 0 && casesmartgoalserviceproviderid == 0)
            {
                sqlQuery.Append(" AND (( [CA].[CaseProgressNoteID] IN (SELECT CPN.ID FROM CaseProgressNote CPN INNER JOIN CaseWorkerMemberAssignment CWMA ON CPN.CaseMemberID=CWMA.CaseMemberID LEFT JOIN CaseWorker CW ON CWMA.CaseWorkerID=CW.ID WHERE CW.WorkerID=" + workerId + "))");
                sqlQuery.Append(" OR ([CA].[CaseProgressNoteID] IN (SELECT CPN.CaseProgressNoteID FROM CaseProgressNoteMembers CPN INNER JOIN CaseWorkerMemberAssignment CWMA ON CPN.CaseMemberID=CWMA.CaseMemberID LEFT JOIN CaseWorker CW ON CWMA.CaseWorkerID=CW.ID WHERE CW.WorkerID=" + workerId + "))");
                sqlQuery.Append(" OR ([CA].[CaseSmartGoalID] IN (SELECT CSG.ID FROM CaseSmartGoal CSG LEFT JOIN CaseGoal CG ON CG.ID=CSG.CaseGoalID INNER JOIN CaseWorkerMemberAssignment CWMA ON CG.CaseMemberID=CWMA.CaseMemberID LEFT JOIN CaseWorker CW ON CWMA.CaseWorkerID=CW.ID WHERE CW.WorkerID=" + workerId + "))");
                sqlQuery.Append(" OR ([CA].[CaseSmartGoalServiceProviderID] IN (SELECT CSGSP.ID FROM CaseSmartGoalServiceProvider CSGSP LEFT JOIN CaseSmartGoal CSG ON CSG.ID=CSGSP.CaseSmartGoalID LEFT JOIN CaseGoal CG ON CG.ID=CSG.CaseGoalID INNER JOIN CaseWorkerMemberAssignment CWMA ON CG.CaseMemberID=CWMA.CaseMemberID LEFT JOIN CaseWorker CW ON CWMA.CaseWorkerID=CW.ID WHERE CW.WorkerID=" + workerId + "))");
                sqlQuery.Append(" ) ");
            }

            if (caseProgressNoteId > 0)
            {
                sqlQuery.Append(" AND [CA].[CaseProgressNoteID]=" + caseProgressNoteId);
            }
            else if (casesmartgoalserviceproviderid > 0)
            {
                sqlQuery.Append(" AND [CA].[CaseSmartGoalServiceProviderID]=" + casesmartgoalserviceproviderid);
            }
            else if (isProviderAction)
            {
                sqlQuery.Append(" AND [CA].[CaseSmartGoalServiceProviderID] IN (SELECT ID FROM CaseSmartGoalServiceProvider WHERE CaseSmartGoalID=" + caseSmartGoalId + " )");
            }
            else if (caseSmartGoalId > 0 && includeServiceProviderAction)
            {
                sqlQuery.Append(" AND ( [CA].[CaseSmartGoalID]=" + caseSmartGoalId);
                sqlQuery.Append(" OR [CA].[CaseSmartGoalServiceProviderID] IN (SELECT ID FROM CaseSmartGoalServiceProvider WHERE CaseSmartGoalID=" + caseSmartGoalId + " ))");
            }
            else if (caseSmartGoalId > 0)
            {
                sqlQuery.Append(" AND [CA].[CaseSmartGoalID]=" + caseSmartGoalId);
            }

            //if (caseProgressNoteId > 0)
            //{
            //    sqlQuery.Append(" AND [CA].[CaseProgressNoteID]=" + caseProgressNoteId);
            //}

            if (casesmartgoalserviceproviderid > 0)
            {
                //sqlQuery.Append(" AND [CA].[CaseSmartGoalServiceProviderID]=" + casesmartgoalserviceproviderid);
            }
            else
            {
                if (isCompleted)
                {
                    sqlQuery.Append(" AND [CA].[IsCompleted]=1 ");
                }
                else
                {
                    sqlQuery.Append(" AND [CA].[IsCompleted]=0 ");
                }
            }
            sqlQuery.Append(" ORDER BY [CA].[CreateDate] DESC");
            DataSourceResult dsResult = context.Database.SqlQuery <CaseActionListViewModel>(sqlQuery.ToString()).AsEnumerable().ToDataSourceResult(dsRequest);

            return(dsResult);
        }
Exemplo n.º 7
0
        //public string FindWorkerNameByCaseWorkerID(int caseWorkerID)
        //{
        //    return context.CaseWorker.Join(context.Worker, left => left.WorkerID, right => right.ID, (left, right) => new { left, right }).Where(item => item.left.ID == caseWorkerID).Select(item =>item.right.FirstName +" "+item.right.LastName).FirstOrDefault();

        //}

//        public DataSourceResult Search(WorkerSearchViewModel searchParameters, DataSourceRequest paramDSRequest)
//        {
//            bool IsCurrentUserNotAdminRole = (CurrentLoggedInWorkerRoleIDs.IndexOf(1) == -1);
//            string hasEditPermission = (workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.WorkerManagement, Constants.Controllers.Worker, Constants.Actions.Edit, true)).ToDisplayStyle();
//            string hasDeletePermission = (workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.WorkerManagement, Constants.Controllers.Worker, Constants.Actions.Delete, true)).ToDisplayStyle();

//            DataSourceRequest dsRequest = paramDSRequest;
//            if (dsRequest == null)
//            {
//                dsRequest = new DataSourceRequest();
//            }
//            if (dsRequest.Filters == null || (dsRequest.Filters != null && dsRequest.Filters.Count == 0))
//            {
//                if (dsRequest.Filters == null)
//                {
//                    dsRequest.Filters = new List<IFilterDescriptor>();
//                }
//            }
//            if (dsRequest.Sorts == null || (dsRequest.Sorts != null && dsRequest.Sorts.Count == 0))
//            {
//                if (dsRequest.Sorts == null)
//                {
//                    dsRequest.Sorts = new List<SortDescriptor>();
//                }
//                SortDescriptor defaultSortExpression = new SortDescriptor("LastUpdateDate", System.ComponentModel.ListSortDirection.Descending);

//                dsRequest.Sorts.Add(defaultSortExpression);
//            }
//            if (dsRequest.PageSize == 0)
//            {
//                dsRequest.PageSize = Constants.CommonConstants.DefaultPageSize;
//            }
//            StringBuilder sqlQuery = new StringBuilder(@"SELECT DISTINCT
//                            W.ID,W.EmailAddress,W.IsActive, [W].[FirstName] + ' ' + [W].[LastName] [Name],
//                            '" + hasDeletePermission + @"' [HasPermissionToDelete],
//                            '" + hasEditPermission + @"' [HasPermissionToEdit]
//                            FROM Worker AS [W]
//                            LEFT JOIN WorkerInRoleNew WIR on W.ID = WIR.WorkerID
//                            LEFT JOIN WorkerRolePermissionNew WRP on WIR.WorkerRoleID = WRP.WorkerRoleID
//                            LEFT JOIN Permission AS P ON WRP.PermissionID = P.ID
//                            LEFT JOIN PermissionRegion AS PR ON P.ID = PR.PermissionID
//                            LEFT JOIN PermissionSubProgram AS PSP ON PR.ID = PSP.PermissionRegionID
//                            LEFT JOIN PermissionJamatkhana AS PJK ON PR.ID = PJK.PermissionRegionID
//                            WHERE [W].[ID] > 0 ");
//            if (IsCurrentUserNotAdminRole)
//            {
//                sqlQuery.Append(" AND [W].[ID] <> " + CurrentLoggedInWorker.ID + " ");
//            }
//            if (searchParameters.RegionID > 0)
//            {
//                searchParameters.RegionID = searchParameters.RegionID;
//                sqlQuery.Append(" AND [PR].[RegionID] =" + searchParameters.RegionID + "");
//            }
//            //else if (IsCurrentLoggedInWorkerRegionalAdministrator) //<JL:Comment:06/11/2017>
//            else if (IsCurrentUserNotAdminRole) //<JL:Add:06/11/2017>
//            {
//                StringBuilder regionquery = new StringBuilder();
//                regionquery.Append("SELECT DISTINCT PR.RegionID ");
//                regionquery.Append("FROM Worker AS [W] ");
//                regionquery.Append("LEFT JOIN WorkerInRoleNew WIR on W.ID = WIR.WorkerID ");
//                regionquery.Append("LEFT JOIN WorkerRolePermissionNew WRP on WIR.WorkerRoleID = WRP.WorkerRoleID ");
//                regionquery.Append("LEFT JOIN Permission AS P ON WRP.PermissionID = P.ID ");
//                regionquery.Append("LEFT JOIN PermissionRegion AS PR ON P.ID = PR.PermissionID ");
//                //regionquery.Append("WHERE [W].ID = " + CurrentLoggedInWorker.ID + " AND WIR.WorkerRoleID = " + SiteConfigurationReader.RegionalAdministratorRoleID); //<JL:Comment:06/11/2017>
//                regionquery.Append("WHERE [W].ID = " + CurrentLoggedInWorker.ID); //<JL:Add:06/11/2017>
//                searchParameters.RegionID = searchParameters.RegionID;
//                //sqlQuery.Append(" AND [PR].[RegionID] = (SELECT RegionID FROM WorkerInRoleNew WIR WHERE WorkerRoleID = " + SiteConfigurationReader.RegionalAdministratorRoleID + " AND WorkerID = " + CurrentLoggedInWorker.ID + ")");
//                sqlQuery.Append(" AND [PR].[RegionID] IN (" + regionquery.ToString() + ")");
//                sqlQuery.Append(" AND [W].[ID] !=1");
//            }
//            if (searchParameters.FirstName.IsNotNullOrEmpty())
//            {
//                searchParameters.FirstName = searchParameters.FirstName.Trim();
//                sqlQuery.Append(" AND [W].[FirstName] LIKE '%" + searchParameters.FirstName + "%'");
//            }

//            if (searchParameters.LastName.IsNotNullOrEmpty())
//            {
//                searchParameters.LastName = searchParameters.LastName.Trim();
//                sqlQuery.Append(" AND [W].[LastName] LIKE '%" + searchParameters.LastName + "%'");
//            }

//            if (searchParameters.RoleID > 0)
//            {
//                sqlQuery.Append(" AND [W].[ID] IN (SELECT [WorkerID] FROM WorkerInRoleNew WHERE WorkerRoleID = " + searchParameters.RoleID + ")");
//            }
//            if (searchParameters.ProgramID > 0)
//            {
//                sqlQuery.Append(" AND [PR].[ProgramID] =" + searchParameters.ProgramID + "");
//            }
//            else if (IsCurrentUserNotAdminRole) //<JL:Add:06/11/2017>
//            {
//                StringBuilder programquery = new StringBuilder();
//                programquery.Append("SELECT DISTINCT PR.ProgramID ");
//                programquery.Append("FROM Worker AS [W] ");
//                programquery.Append("INNER JOIN WorkerInRoleNew WIR on W.ID = WIR.WorkerID ");
//                programquery.Append("INNER JOIN WorkerRolePermissionNew WRP on WIR.WorkerRoleID = WRP.WorkerRoleID ");
//                programquery.Append("INNER JOIN Permission AS P ON WRP.PermissionID = P.ID ");
//                programquery.Append("INNER JOIN PermissionRegion AS PR ON P.ID = PR.PermissionID ");
//                programquery.Append("WHERE [W].ID = " + CurrentLoggedInWorker.ID);
//                searchParameters.ProgramID = searchParameters.ProgramID;

//                sqlQuery.Append(" AND [PR].[ProgramID] IN (" + programquery.ToString() + ")");
//                sqlQuery.Append(" AND [W].[ID] !=1");
//            }
//            if (IsCurrentUserNotAdminRole) //<JL:Add:06/11/2017>
//            {
//                StringBuilder subprogramquery = new StringBuilder();
//                subprogramquery.Append("SELECT DISTINCT PSP.SubProgramID ");
//                subprogramquery.Append("FROM Worker AS [W] ");
//                subprogramquery.Append("INNER JOIN WorkerInRoleNew WIR on W.ID = WIR.WorkerID ");
//                subprogramquery.Append("INNER JOIN WorkerRolePermissionNew WRP on WIR.WorkerRoleID = WRP.WorkerRoleID ");
//                subprogramquery.Append("INNER JOIN Permission AS P ON WRP.PermissionID = P.ID ");
//                subprogramquery.Append("INNER JOIN PermissionRegion AS PR ON P.ID = PR.PermissionID ");
//                subprogramquery.Append("INNER JOIN PermissionSubProgram AS PSP ON PR.ID = PSP.PermissionRegionID ");
//                subprogramquery.Append("WHERE [W].ID = " + CurrentLoggedInWorker.ID);

//                sqlQuery.Append(" AND [PSP].[SubProgramID] IN (" + subprogramquery.ToString() + ")");
//                sqlQuery.Append(" AND [W].[ID] !=1");

//                StringBuilder jkquery = new StringBuilder();
//                jkquery.Append("SELECT DISTINCT PJK.JamatkhanaID ");
//                jkquery.Append("FROM Worker AS [W] ");
//                jkquery.Append("INNER JOIN WorkerInRoleNew WIR on W.ID = WIR.WorkerID ");
//                jkquery.Append("INNER JOIN WorkerRolePermissionNew WRP on WIR.WorkerRoleID = WRP.WorkerRoleID ");
//                jkquery.Append("INNER JOIN Permission AS P ON WRP.PermissionID = P.ID ");
//                jkquery.Append("INNER JOIN PermissionRegion AS PR ON P.ID = PR.PermissionID ");
//                jkquery.Append("LEFT JOIN PermissionJamatkhana AS PJK ON PR.ID = PJK.PermissionRegionID ");
//                jkquery.Append("WHERE [W].ID = " + CurrentLoggedInWorker.ID);

//                sqlQuery.Append(" AND [PJK].[JamatkhanaID] IN (" + jkquery.ToString() + ")");
//            }

//            DataSourceResult dataSourceResult = context.Database.SqlQuery<WorkerListViewModel>(sqlQuery.ToString()).AsEnumerable().GroupBy(m=>m.ID).Select(m=>m.First()).ToDataSourceResult(dsRequest);

//            DataSourceRequest dsRequestTotalCountQuery = new DataSourceRequest();
//            dsRequestTotalCountQuery.Filters = dsRequest.Filters;
//            dataSourceResult.Total = context.Database.SqlQuery<WorkerListViewModel>(sqlQuery.ToString()).AsEnumerable().ToDataSourceResult(dsRequestTotalCountQuery).Data.AsQueryable().Count();
//            return dataSourceResult;
//        }

        public DataSourceResult Search(WorkerSearchViewModel searchParameters, DataSourceRequest paramDSRequest)
        {
            bool   IsCurrentUserNotAdminRole = (CurrentLoggedInWorkerRoleIDs.IndexOf(1) == -1);
            string hasEditPermission         = (workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.WorkerManagement, Constants.Controllers.Worker, Constants.Actions.Edit, true)).ToDisplayStyle();
            string hasDeletePermission       = (workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.WorkerManagement, Constants.Controllers.Worker, Constants.Actions.Delete, true)).ToDisplayStyle();

            DataSourceRequest dsRequest = paramDSRequest;

            if (dsRequest == null)
            {
                dsRequest = new DataSourceRequest();
            }
            if (dsRequest.Filters == null || (dsRequest.Filters != null && dsRequest.Filters.Count == 0))
            {
                if (dsRequest.Filters == null)
                {
                    dsRequest.Filters = new List <IFilterDescriptor>();
                }
            }
            if (dsRequest.Sorts == null || (dsRequest.Sorts != null && dsRequest.Sorts.Count == 0))
            {
                if (dsRequest.Sorts == null)
                {
                    dsRequest.Sorts = new List <SortDescriptor>();
                }
                SortDescriptor defaultSortExpression = new SortDescriptor("LastUpdateDate", System.ComponentModel.ListSortDirection.Descending);

                dsRequest.Sorts.Add(defaultSortExpression);
            }
            if (dsRequest.PageSize == 0)
            {
                dsRequest.PageSize = Constants.CommonConstants.DefaultPageSize;
            }
            StringBuilder sqlQuery;

            sqlQuery = new StringBuilder(@"SELECT DISTINCT 
                            W.ID,W.EmailAddress,W.IsActive, [W].[FirstName] + ' ' + [W].[LastName] [Name],
                            '" + hasDeletePermission + @"' [HasPermissionToDelete],
                            '" + hasEditPermission + @"' [HasPermissionToEdit]
                            FROM Worker AS [W] ");

            if (IsCurrentUserNotAdminRole)
            {
                sqlQuery.Append(" INNER JOIN WorkerInRoleNew WIR on W.ID = WIR.WorkerID");
                sqlQuery.Append(" INNER JOIN WorkerRolePermissionNew WRP on WIR.WorkerRoleID = WRP.WorkerRoleID");

                if (searchParameters.RegionID > 0 || searchParameters.ProgramID > 0)
                {
                    sqlQuery.Append(" INNER JOIN PermissionRegion AS PR ON WRP.PermissionID = PR.PermissionID");
                    if (searchParameters.RegionID > 0)
                    {
                        sqlQuery.Append(" AND [PR].[RegionID] =" + searchParameters.RegionID + "");
                    }
                    if (searchParameters.ProgramID > 0)
                    {
                        sqlQuery.Append(" AND [PR].[ProgramID] =" + searchParameters.ProgramID + "");
                    }
                }

                sqlQuery.Append(" INNER JOIN (");
                sqlQuery.Append(" SELECT WRP.PermissionID");
                sqlQuery.Append(" FROM WorkerInRoleNew AS WIR ");
                sqlQuery.Append(" INNER JOIN WorkerRolePermissionNew WRP ON WIR.WorkerRoleID = WRP.WorkerRoleID");
                sqlQuery.Append(" WHERE [WIR].WorkerID = " + CurrentLoggedInWorker.ID + " ");
                sqlQuery.Append(" ) AS CW ON [WRP].[PermissionID] = CW.PermissionID");
            }
            else
            {
                sqlQuery.Append(" LEFT JOIN WorkerInRoleNew WIR on W.ID = WIR.WorkerID");
                sqlQuery.Append(" LEFT JOIN WorkerRolePermissionNew WRP on WIR.WorkerRoleID = WRP.WorkerRoleID");

                if (searchParameters.RegionID > 0 || searchParameters.ProgramID > 0)
                {
                    sqlQuery.Append(" LEFT JOIN PermissionRegion AS PR ON WRP.PermissionID = PR.PermissionID");
                    if (searchParameters.RegionID > 0)
                    {
                        sqlQuery.Append(" AND [PR].[RegionID] =" + searchParameters.RegionID + "");
                    }
                    if (searchParameters.ProgramID > 0)
                    {
                        sqlQuery.Append(" AND [PR].[ProgramID] =" + searchParameters.ProgramID + "");
                    }
                }
            }

            sqlQuery.Append(" WHERE [W].[ID] > 0 ");

            if (IsCurrentUserNotAdminRole)
            {
                sqlQuery.Append(" AND [W].[ID] NOT IN (" + CurrentLoggedInWorker.ID + ",1) ");
            }

            if (searchParameters.FirstName.IsNotNullOrEmpty())
            {
                searchParameters.FirstName = searchParameters.FirstName.Trim();
                sqlQuery.Append(" AND [W].[FirstName] LIKE '%" + searchParameters.FirstName + "%'");
            }

            if (searchParameters.LastName.IsNotNullOrEmpty())
            {
                searchParameters.LastName = searchParameters.LastName.Trim();
                sqlQuery.Append(" AND [W].[LastName] LIKE '%" + searchParameters.LastName + "%'");
            }

            if (searchParameters.RoleID > 0)
            {
                sqlQuery.Append(" AND [W].[ID] IN (SELECT [WorkerID] FROM WorkerInRoleNew WHERE WorkerRoleID = " + searchParameters.RoleID + ")");
            }

            DataSourceResult dataSourceResult = context.Database.SqlQuery <WorkerListViewModel>(sqlQuery.ToString()).AsEnumerable().GroupBy(m => m.ID).Select(m => m.First()).ToDataSourceResult(dsRequest);

            DataSourceRequest dsRequestTotalCountQuery = new DataSourceRequest();

            dsRequestTotalCountQuery.Filters = dsRequest.Filters;
            dataSourceResult.Total           = context.Database.SqlQuery <WorkerListViewModel>(sqlQuery.ToString()).AsEnumerable().ToDataSourceResult(dsRequestTotalCountQuery).Data.AsQueryable().Count();
            return(dataSourceResult);
        }
Exemplo n.º 8
0
        public DataSourceResult Search(DataSourceRequest dsRequest, int caseId, int workerId, int?caseMemberId, bool isClosed)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }
            if (caseMemberId.HasValue && caseMemberId > 0)
            {
                FilterDescriptor filterDescriptor = new FilterDescriptor("CaseMemberID", FilterOperator.IsEqualTo, caseMemberId.Value);
                dsRequest.Filters.Add(filterDescriptor);
            }
            bool hasReadPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseSmartGoal, Constants.Actions.Read, true);
            bool hasEditPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseSmartGoal, Constants.Actions.Edit, true);
            bool hasDeletePermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseSmartGoal, Constants.Actions.Delete, true);
            //bool hasDeletePermission = IsCurrentLoggedInWorkerAdministrator;
            bool hasTrackGoalPermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseSmartGoalProgress, Constants.Actions.Index, true);
            bool IsUserAdminWorker      = CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1;

            List <CaseSmartGoal> caseSmartGoalList = context.CaseSmartGoal
                                                     .Join(context.CaseGoal, left => left.CaseGoalID, right => right.ID, (left, right) => new { left, right })
                                                     //.Join(context.CaseWorkerMemberAssignment, secondleft => secondleft.right.CaseMemberID, secondright => secondright.CaseMemberID, (secondleft, secondright) => new { secondleft, secondright })
                                                     //.Where(item => item.secondleft.right.CaseMember.CaseID == caseId && item.secondright.CaseWorker.WorkerID == workerId)
                                                     .Where(item => item.right.CaseMember.CaseID == caseId)
                                                     //<JL:Comment:06/18/2017>
                                                     //.Where(item => context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(item.right.CaseMemberID) || IsUserAdminWorker)
                                                     .OrderBy(item => item.left.StartDate)
                                                     .AsEnumerable()
                                                     .ToList()
                                                     .Select(
                casesmartgoal => new CaseSmartGoal()
            {
                ID                        = casesmartgoal.left.ID,
                CreateDate                = casesmartgoal.left.CreateDate,
                CaseMemberID              = casesmartgoal.right.CaseMemberID,
                CaseMemberName            = casesmartgoal.right.CaseMember.FirstName + " " + casesmartgoal.right.CaseMember.LastName,
                ServiceLevelOutcomeID     = casesmartgoal.left.ServiceLevelOutcomeID,
                ServiceLevelOutcomeName   = casesmartgoal.left.ServiceLevelOutcome != null ? casesmartgoal.left.ServiceLevelOutcome.Name : "",
                QualityOfLifeCategoryName = casesmartgoal.left.QualityOfLifeCategory != null ? casesmartgoal.left.QualityOfLifeCategory.Name : "",
                StartDate                 = casesmartgoal.left.StartDate,
                EndDate                   = casesmartgoal.left.EndDate,
                CaseID                    = caseId,
                IsCompleted               = casesmartgoal.left.IsCompleted,
                HasPermissionToRead       = hasReadPermission ? "" : "display:none;",
                HasPermissionToEdit       = hasEditPermission ? "" : "display:none;",
                HasPermissionToDelete     = hasDeletePermission ? "" : "display:none;",
                HasPermissionToTrackGoal  = hasTrackGoalPermission ? "" : "display:none;"
            }
                ).ToList();

            if (caseSmartGoalList != null)
            {
                foreach (CaseSmartGoal caseSmartGoal in caseSmartGoalList)
                {
                    caseSmartGoal.TotalActionCount = context.CaseAction.Where(item => item.CaseSmartGoalID == caseSmartGoal.ID && item.CaseSmartGoalServiceProviderID == null).Count();
                    caseSmartGoal.OpenActionCount  = context.CaseAction.Where(item => (item.CaseSmartGoalID == caseSmartGoal.ID && item.CaseSmartGoalServiceProviderID == null) && item.IsCompleted == false).Count();
                    caseSmartGoal.CloseActionCount = context.CaseAction.Where(item => (item.CaseSmartGoalID == caseSmartGoal.ID && item.CaseSmartGoalServiceProviderID == null) && item.IsCompleted == true).Count();
                    List <CaseSmartGoalAssignment> goalAssignmentList = context.CaseSmartGoalAssignment.Where(item => item.CaseSmartGoalID == caseSmartGoal.ID).ToList();
                    if (goalAssignmentList != null)
                    {
                        foreach (CaseSmartGoalAssignment goalAssignment in goalAssignmentList)
                        {
                            caseSmartGoal.SmartGoalName = caseSmartGoal.SmartGoalName.Concate(",", goalAssignment.SmartGoal.Name);
                        }
                    }
                }
            }
            if (isClosed)
            {
                if (dsRequest.Filters == null || (dsRequest.Filters != null && dsRequest.Filters.Count == 0))
                {
                    if (dsRequest.Filters == null)
                    {
                        dsRequest.Filters = new List <IFilterDescriptor>();
                    }
                }
                FilterDescriptor newFilterDescriptor = new FilterDescriptor("IsCompleted", FilterOperator.IsEqualTo, true);
                dsRequest.Filters.Add(newFilterDescriptor);
            }
            else
            {
                if (dsRequest.Filters == null || (dsRequest.Filters != null && dsRequest.Filters.Count == 0))
                {
                    if (dsRequest.Filters == null)
                    {
                        dsRequest.Filters = new List <IFilterDescriptor>();
                    }
                }
                FilterDescriptor newFilterDescriptor = new FilterDescriptor("IsCompleted", FilterOperator.IsEqualTo, false);
                dsRequest.Filters.Add(newFilterDescriptor);
            }
            DataSourceResult dsResult = caseSmartGoalList.ToDataSourceResult(dsRequest);

            return(dsResult);
        }
Exemplo n.º 9
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            object objCurrentControllerName = string.Empty;

            this.RouteData.Values.TryGetValue("controller", out objCurrentControllerName);
            object objCurrentActionName = string.Empty;

            this.RouteData.Values.TryGetValue("action", out objCurrentActionName);
            object currentAreaName = string.Empty;

            this.RouteData.Values.TryGetValue("Areas", out currentAreaName);
            if (this.RouteData.DataTokens.ContainsKey("area"))
            {
                currentAreaName = this.RouteData.DataTokens["area"].ToString();
            }
            string currentActionName     = objCurrentActionName.ToString(true);
            string currentControllerName = objCurrentControllerName.ToString(true);

            ViewBag.HasAccessToOtherConfigurationData = false;
            ViewBag.CurrentActionName     = currentActionName;
            ViewBag.CurrentControllerName = currentControllerName;
            ViewBag.CurrentAreaName       = currentAreaName;

            ViewBag.HasAccessToWorkerModule         = false;
            ViewBag.HasAccessToReportModule         = false;
            ViewBag.HasAccessToAdminModule          = false;
            ViewBag.HasAccessToCaseManagementModule = true;
            ViewBag.IsRegionalAdministrator         = false;

            if (CurrentLoggedInWorker != null)
            {
                ViewBag.CurrentWorkerID = CurrentLoggedInWorker.ID;
                //ViewBag.CurrentWorkerRoleID = CurrentLoggedInWorker.UserRoleID;
                ViewBag.CurrentWorkerName = CurrentLoggedInWorker.FirstName + " " + CurrentLoggedInWorker.LastName;
            }
            currentActionName = currentActionName.ToLower();
            if (!currentActionName.Contains("ajax"))
            {
                //<JL:Comment:06/13/2017>
                //if (WebHelper.CurrentSession.Content.RegionVisibility == VisibilityStatus.UnDefined && workerRolePermissionRepository != null)
                if (WebHelper.CurrentSession.Content.RegionVisibility == VisibilityStatus.UnDefined && workerRolePermissionNewRepository != null)
                {
                    VisibilityStatus regionVisiblity     = VisibilityStatus.UnDefined;
                    VisibilityStatus programVisiblity    = VisibilityStatus.UnDefined;
                    VisibilityStatus subProgramVisiblity = VisibilityStatus.UnDefined;
                    VisibilityStatus caseVisiblity       = VisibilityStatus.UnDefined;
                    workerRolePermissionNewRepository.FindVisiblity(CurrentLoggedInWorker.ID, ref regionVisiblity, ref programVisiblity, ref subProgramVisiblity, ref caseVisiblity);
                    WebHelper.CurrentSession.Content.RegionVisibility     = regionVisiblity;
                    WebHelper.CurrentSession.Content.ProgramVisibility    = programVisiblity;
                    WebHelper.CurrentSession.Content.SubProgramVisibility = subProgramVisiblity;
                    WebHelper.CurrentSession.Content.CaseVisibility       = caseVisiblity;
                }
            }

            ViewBag.CurrentLoggedInWorkerRoleIDs = CurrentLoggedInWorkerRoleIDs;

            if (CurrentLoggedInWorkerRoleIDs != null && CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1)
            {
                ViewBag.HasAccessToWorkerModule = true;
                ViewBag.HasAccessToReportModule = true;
                ViewBag.HasAccessToAdminModule  = true;
            }

            //<JL:Add:06/11/2017>
            if (workerroleactionpermissionnewRepository != null)
            {
                bool HasWorkerMenuPermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.WorkerManagement, Constants.Controllers.Worker, string.Empty, true);
                if (HasWorkerMenuPermission)
                {
                    ViewBag.HasAccessToWorkerModule = true;
                }
                bool HasReportMenuPermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.Reporting, Constants.Controllers.Report, string.Empty, true);
                if (HasReportMenuPermission)
                {
                    ViewBag.HasAccessToReportModule = true;
                }
            }
            //</JL:Add:06/11/2017>

            if (CurrentLoggedInWorkerRoleIDs != null && CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) != -1)
            {
                ViewBag.HasAccessToWorkerModule           = true;
                ViewBag.HasAccessToReportModule           = true;
                ViewBag.HasAccessToAdminModule            = false;
                ViewBag.HasAccessToCaseManagementModule   = false;
                ViewBag.IsRegionalAdministrator           = true;
                ViewBag.HasAccessToOtherConfigurationData = true;
            }

            base.OnActionExecuting(filterContext);
        }
Exemplo n.º 10
0
        public DataSourceResult Search(DataSourceRequest dsRequest, int caseId, int workerId, int?caseMemberId, List <int> workerRoleIDs)
        {
            if (dsRequest.Filters == null)
            {
                dsRequest.Filters = new List <IFilterDescriptor>();
            }
            //if (caseMemberId.HasValue && caseMemberId > 0)
            //{
            //    FilterDescriptor filterDescriptor = new FilterDescriptor("CaseMemberID", FilterOperator.IsEqualTo, caseMemberId.Value);
            //    dsRequest.Filters.Add(filterDescriptor);
            //}
            bool hasReadPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseProgressNote, Constants.Actions.Read, true);
            bool hasEditPermission   = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseProgressNote, Constants.Actions.Edit, true);
            bool hasDeletePermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.CaseManagement, Constants.Controllers.CaseProgressNote, Constants.Actions.Delete, true);
            //DataSourceResult dsResult = context.CaseProgressNote
            //    .Join(context.CaseProgressNoteMembers, left => left.ID, right => right.CaseProgressNoteID, (left, right) => new { left,right})
            //    .Join(context.CaseMember,secondleft=>secondleft.right.CaseMemberID,secondright=>secondright.ID,(secondleft,secondright)=>new {secondleft,secondright})
            //    //.Join(context.CaseWorkerMemberAssignment, left => left.CaseMemberID, right => right.CaseMemberID, (left, right) => new { left, right })
            //    .Where(item => item.secondleft.left.CaseMember.CaseID == caseId || item.secondright.CaseID==caseId)
            //    .Where(item => context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(item.secondleft.left.CaseMemberID) || workerRoleIDs.Contains("1") || context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(item.secondleft.right.CaseMemberID))
            //    .OrderByDescending(item => item.secondleft.left.CreateDate).ToList()
            //    .Select(
            //    caseprogressnote => new
            //    {
            //        caseprogressnote.secondleft.left.ID,
            //        CaseID = (caseprogressnote.secondleft.left.CaseMember.CaseID>0?caseprogressnote.secondleft.left.CaseMember.CaseID:caseprogressnote.secondright.CaseID),
            //        //caseprogressnote.CaseMemberID,
            //        caseprogressnote.secondleft.left.NoteDate,
            //        caseprogressnote.secondleft.left.Note,
            //        CaseMemberName = (caseprogressnote.secondleft.left.CaseMember != null ? caseprogressnote.secondleft.left.CaseMember.FirstName + " " + caseprogressnote.secondleft.left.CaseMember.LastName : (caseprogressnote.secondright != null ? caseprogressnote.secondright.FirstName + " " + caseprogressnote.secondright.LastName :"")),
            //        ActivityTypeName = caseprogressnote.secondleft.left.ActivityType != null ? caseprogressnote.secondleft.left.ActivityType.Name : "",
            //        HasPermissionToEdit = hasEditPermission ? "" : "display:none;",
            //        HasPermissionToDelete = hasDeletePermission ? "" : "display:none;"
            //    }
            //    ).ToDataSourceResult(dsRequest);

            //DataSourceResult dsResult = (from s in context.CaseProgressNote
            //                             join m1 in context.CaseMember
            //                             on s.CaseMemberID equals m1.ID
            //                             into tempmember
            //                             from mem in tempmember.DefaultIfEmpty()
            //                             join cm in context.CaseProgressNoteMembers
            //                             on s.ID equals cm.CaseProgressNoteID into temp
            //                             from t in temp.DefaultIfEmpty()

            //                             where ( t.CaseMember.CaseID==caseId || mem.CaseID==caseId)
            //                             && (context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(s.CaseMemberID)
            //                             || workerRoleIDs.Contains("1")
            //                             || context.CaseWorkerMemberAssignment.Where(worker => worker.CaseWorker.WorkerID == workerId).Select(member => member.CaseMemberID).Contains(t.CaseMemberID)
            //                             )
            //                             select new {
            //                             s.ID,
            //                             s.NoteDate,
            //                             s.Note,
            //                             CaseMemberName = (t.CaseMember != null ? t.CaseMember.FirstName + " " + t.CaseMember.LastName : (mem != null ? mem.FirstName + " " + mem.LastName : "")),
            //                             HasPermissionToEdit = hasEditPermission ? "" : "display:none;",
            //                             HasPermissionToDelete = hasDeletePermission ? "" : "display:none;"
            //                             }).ToDataSourceResult(dsRequest);


            string sqlQuery = "";

            sqlQuery += "DECLARE @WorkerIds nvarchar(max) ; ";
            sqlQuery += " SET @WorkerIds='" + workerRoleIDs + "' ;";
            sqlQuery += " SELECT " + caseId + " AS CaseID,cpn.ID,(SELECT STUFF((SELECT ', ' + (cm1.FirstName+' '+cm1.LastName) from CaseProgressNote cpn1 left join CaseProgressNoteMembers cpm1 on cpn1.ID=cpm1.CaseProgressNoteID left join CaseMember cm1 on cm1.ID=cpm1.CaseMemberID or cm1.ID=cpn1.CaseMemberID where cm1.CaseID=" + caseId + " and cpn1.ID=cpn.ID ";
            sqlQuery += " ";
            sqlQuery += "" + (caseMemberId.HasValue && caseMemberId > 0 ? " and cm1.ID=" + caseMemberId + "" : "") + "";
            sqlQuery += " FOR XML PATH('')), 1, 2, '')) as CaseMemberName";
            sqlQuery += ",cpn.NoteDate,at.Name as ActivityTypeName,cpn.Note,'" + (hasReadPermission ? "" : "display:none;") + "' AS HasPermissionToRead,'" + (hasEditPermission ? "" : "display:none;") + "' AS HasPermissionToEdit,'" + (hasDeletePermission ? "" : "display:none;") + "' AS HasPermissionToDelete  from CaseProgressNote cpn";
            sqlQuery += " join ActivityType at on  at.ID=cpn.ActivityTypeID  left join CaseProgressNoteMembers cpm on cpn.ID=cpm.CaseProgressNoteID ";
            sqlQuery += " left join CaseMember cm on cm.ID=cpm.CaseMemberID or cm.ID=cpn.CaseMemberID where cm.CaseID=" + caseId + "";
            sqlQuery += "";
            sqlQuery += "" + (caseMemberId.HasValue && caseMemberId > 0 ? " and cm.ID=" + caseMemberId + "" : "") + "";
            sqlQuery += " group by cpn.ID,NoteDate,at.Name,Note";

            DataSourceResult dsResult = context.Database.SqlQuery <CaseProgressNoteModel>(sqlQuery.ToString()).AsEnumerable().ToDataSourceResult(dsRequest);

            return(dsResult);
        }