Esempio n. 1
0
        public static List<AssignmentStatusByUser_StandardData> GetAssignmentStatusByUser_StandardData(SearchAssignmentStatusByUser search)
        {
            var result = new List<AssignmentStatusByUser_StandardData>();

            using (var DBMEdition01_Entities = new DBMEdition01_Entities())
            {
                try
                {

                    int SiteID = Convert.ToInt32(search.SelectedSiteIDs);
                    int ProgramID = Convert.ToInt32(search.ProgramIDs);
                    int ChapterID = Convert.ToInt32(search.SelectedChapterIDs);
                    int SelectedAssignedToID = Convert.ToInt32(search.SelectedAssignedToIDs);

                    result = DBMEdition01_Entities.GetAssignmentStatusByUser_StandardWise(SiteID, ProgramID,
                        ChapterID, search.SelectedStandardIDs, search.SelectedScoreType, SelectedAssignedToID, search.IncludeFSAEPs,
                        search.IncludeDocumentationRequired, search.IncludeNewChangedEPs, search.StartDate, search.EndDate, search.StandardEffBeginDate, search.ScoreValueList).ToList();

                    result
                        .Where(a => (decimal)(a.ScoreCompletePercentage.Value + a.ScoreNotCompletePercentage.Value + a.ScorePastDueDatePercentage.Value) > (decimal)100.00).ToList()
                        .ForEach(delegate (AssignmentStatusByUser_StandardData userData)
                        {

                            decimal difference = (userData.ScoreCompletePercentage.Value + userData.ScoreNotCompletePercentage.Value + userData.ScorePastDueDatePercentage.Value) - 100;

                            if (userData.ScoreCompletePercentage.Value > difference * 2)
                                userData.ScoreCompletePercentage = userData.ScoreCompletePercentage.Value - difference;
                            else if (userData.ScoreNotCompletePercentage.Value > difference * 2)
                                userData.ScoreNotCompletePercentage = userData.ScoreNotCompletePercentage.Value - difference;
                            else if (userData.ScorePastDueDatePercentage.Value > difference * 2)
                                userData.ScorePastDueDatePercentage = userData.ScorePastDueDatePercentage.Value - difference;

                        });

                }
                catch (Exception ex)
                {
                    throw ex;
                }

                return result;
            }
        }