public String GenerateIdentifier(String code, CertificationTracker tracker) { CertificationPlanGenerator generator = new CertificationPlanGenerator(); var DiffMonth = generator.DifferenceMonth(generator.GetCertificationPlanA(code, tracker)); if (DiffMonth > 0) { if (DiffMonth <= 31) { return("One Month Overdue"); } else if (DiffMonth > 31 && DiffMonth < 63) { return("Almost Two Months Overdue"); } else { return("Two Months Overdue"); } } else { return("In due time"); } }
public EmployeeProgressDetails GetEmployeeDetails(String id) { EmployeeProgressDetails empP = new EmployeeProgressDetails(); var Certificates = entities.Certifications.ToList(); var CertificationTracker = entities.certificateTracker_Vw.ToList(); List <CertificationTracker> MyCertificates = new List <CertificationTracker>(); var NumberOfCertified = 0; var NumberOfRecertified = 0; int TotalCertifiedPoints = 0; int TotalReCertifiedPoints = 0; CertificationPlanGenerator generator = new CertificationPlanGenerator(); if (id != null) { var employee = entities.EmployeeDCR_Vw.Where(emp => emp.Employee_ID == id).FirstOrDefault(); if (employee != null) { empP.EmpBadgeNo = employee.Employee_ID; empP.FullName = employee.Last_Name + " , " + employee.First_Name; empP.Position = employee.Position; empP.HrcCell = employee.HRCCell; empP.HrcSupervisor = employee.HRCSupervisor; empP.CurrentCell = employee.CurrentCell; empP.CurrentSupervisor = employee.CurrentSupervisor; empP.SkillsCertified = entities.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID).OrderBy(cr => cr.CertificationCode).ToList().Count() + " out of " + Certificates; NumberOfCertified = entities.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID).OrderBy(cr => cr.CertificationCode).ToList().Count(); empP.SkillsCertified = NumberOfCertified + " out of " + Certificates.Count(); NumberOfRecertified = entities.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID && cr.DateRecertified != null).OrderBy(cr => cr.Id).ToList().Count(); empP.SkillsReCertified = NumberOfRecertified + " out of " + NumberOfCertified; double SKP = (Convert.ToDouble(NumberOfCertified) / Convert.ToDouble(Certificates.Count())) * (100); empP.SkillsCertifiedPercentage = !Double.IsNaN(SKP) ? Convert.ToInt32(SKP).ToString() + "%" : "0%"; double SRKP = (Convert.ToDouble(NumberOfRecertified) / Convert.ToDouble(Certificates.Count())) * (100); empP.SkillsReCertifiedPercentage = !Double.IsNaN(SRKP) ? Convert.ToInt32(SRKP).ToString() + "%" : "0%"; MyCertificates = entities.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID).OrderBy(cr => cr.CertificationCode).ToList(); foreach (var certif in Certificates) { var existCert = MyCertificates.Where(cert => cert.CertificationCode == certif.Code).FirstOrDefault(); if (existCert != null) { TotalCertifiedPoints = TotalCertifiedPoints + Convert.ToInt32(certif.Points); if (existCert.DateRecertified != null) { TotalReCertifiedPoints = TotalReCertifiedPoints + Convert.ToInt32(certif.Points); } empP.EmployeeCertificates.Add( new EmployeeCertificates() { CertificateCode = certif.Code, Description = certif.Description, Type = certif.Type, DateCertified = Convert.ToDateTime(existCert.DateCertified).ToShortDateString(), DateRecertified = existCert.DateRecertified == null ? "Not yet Recertified" : Convert.ToDateTime(existCert.DateRecertified).ToShortDateString(), CertificationPlan = generator.GetCertificationPlanA(certif.Code, existCert).ToShortDateString(), Status = generator.DateNowAddMonth(-2) <= generator.GetCertificationPlanA(certif.Code, existCert) ?"Active" : "In-Active", Identifier = GenerateIdentifier(certif.Code, existCert) } ); } } empP.SkillsCertifiedPoints = TotalCertifiedPoints.ToString(); empP.SkillsReCertifiedPoints = TotalReCertifiedPoints.ToString(); } } return(empP); }