Exemple #1
0
        public IEnumerable <AbnormalChartPercentModel> AbnormalChartPercent()
        {
            var reasonType      = _abnormalReasonRepository.GetAll();
            var DateNow         = DateTime.Now;
            var firstDayOfMonth = new DateTime(DateNow.Year, DateNow.Month, 1);
            var abnomarData     = _abnormalCaseRepository.GetAbnormalChart();
            var model           = _abnormalCaseRepository.GetMulti(x => x.FingerTimeSheet.DayOfCheck > firstDayOfMonth && x.FingerTimeSheet.DayOfCheck < DateNow, new string[] { CommonConstants.AbnormalReason, CommonConstants.FingerTimeSheet });
            var total           = model.Count();
            List <AbnormalChartPercentModel> ListabnormalChartPercent = new List <AbnormalChartPercentModel>();

            foreach (var item in reasonType)
            {
                AbnormalChartPercentModel abnormalchartpercent = new AbnormalChartPercentModel()
                {
                    ReasonType     = item.Name,
                    ReasonTypeID   = item.ID,
                    Percentage     = model.Count(x => x.ReasonId == item.ID),
                    ApprovePercent = (abnomarData.Count(a => a.ReasonID == item.ID && a.StatusRequestID == 4)) == 0 ? 0: Math.Round(((double)(abnomarData.Count(a => a.ReasonID == item.ID && a.StatusRequestID == 4)) / (double)(model.Count(x => x.ReasonId == item.ID))) * 100, 1),
                    RejectPercent  = (abnomarData.Count(a => a.ReasonID == item.ID && a.StatusRequestID == 2)) == 0 ? 0: Math.Round(((double)(abnomarData.Count(a => a.ReasonID == item.ID && a.StatusRequestID == 2)) / (double)(model.Count(x => x.ReasonId == item.ID))) * 100, 1)
                };
                ListabnormalChartPercent.Add(abnormalchartpercent);
            }
            return(ListabnormalChartPercent);
        }
 public IEnumerable <AbnormalReason> GetAll()
 {
     return(_abnormalReasonRepository.GetAll());
 }