public ActionResult ClientReport(string empCd) { ClientReportView view = new ClientReportView(); view.FromDate = usDate.Date; view.ToDate = usDate.Date; ViewBag.Empcd = empCd; if (empCd == null || empCd == "") //get the employee code from authentication. { empCd = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; } List <RIC_Client> company = (from s in unitOfwork.User.GetByEmpID(empCd).RIC_ClientMapping select new RIC_Client() { RC_Id = s.RIC_Client.RC_Id, RC_ClientName = s.RIC_Client.RC_ClientName }).ToList(); List <SelectListItem> _lstClient = new List <SelectListItem>(); _lstClient.Add(new SelectListItem() { Text = "All", Value = "All" }); foreach (var rule in company)// add the items in select list. { SelectListItem selectlistitem = new SelectListItem(); selectlistitem.Text = rule.RC_ClientName; selectlistitem.Value = rule.RC_ClientName.ToString(); _lstClient.Add(selectlistitem); } List <SelectListItem> _lstYear = new List <SelectListItem>(); _lstYear.Add(new SelectListItem() { Text = "All", Value = "0" }); var yearList = Enumerable.Range(2016, usDate.Year - 2015).Select(s => new SelectListItem { Text = s.ToString(), Value = s.ToString() }).OrderByDescending(s => s.Value).ToList(); foreach (var year in yearList)// add the items in select list. { SelectListItem selectlistitem = new SelectListItem(); selectlistitem.Text = year.Text; selectlistitem.Value = year.Value; _lstYear.Add(selectlistitem); } view.YearSelectList = _lstYear; view.ClientList = _lstClient; return(View(view)); }
public ActionResult ClientReport(ClientReportView ClientView, string empCd, string GetDates) { if (empCd == null || empCd == "") //get the employee code from authentication. { empCd = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; } DateTime fromDate = ClientView.FromDate; DateTime todate = ClientView.ToDate.AddDays(1); //get the submissions for all users.. bool getDateBool = (GetDates == "") ?true:false; var crosslist = (from Company in unitOfwork.User.GetByEmpID(empCd).RIC_ClientMapping from emp in unitOfwork.RIC_Employee.Get() where emp.RE_Resign_Date == null select new { Client = Company.RIC_Client.RC_ClientName, Empcd = emp.RE_Emp_Cd, JobDivaUserName = emp.RE_Jobdiva_User_Name }).ToList(); var submissionsYear = unitOfwork.RIC_Job_Report.GetAll() .Where(s => (ClientView.GetYear != 0 ? (getDateBool == false ? (s.RJ_Submit_Date >= fromDate && s.RJ_Submit_Date <= todate) : (s.RJ_Submit_Date.Year == ClientView.GetYear)) : (s.RJ_Submit_Date != null))) .GroupBy(s => new { s.RJ_Company, s.RJ_EmpCd, s.RJ_Submitted_By }) .Select(s => new { Client = s.Key.RJ_Company, Empcode = s.Key.RJ_EmpCd, EmployeeName = s.Key.RJ_Submitted_By, Submissions = s.Count() }).ToList(); var InterviewYear = unitOfwork.RIC_Job_Report.GetAll() .Where(s => (ClientView.GetYear != 0 ? (getDateBool == false ? (s.RJ_Interview_Date >= fromDate && s.RJ_Interview_Date <= todate) : (s.RJ_Interview_Date != null && s.RJ_Interview_Date.Value.Year == ClientView.GetYear)) : (s.RJ_Interview_Date != null))) .GroupBy(s => new { s.RJ_Company, s.RJ_EmpCd, s.RJ_Submitted_By }) .Select(s => new { Client = s.Key.RJ_Company, Empcode = s.Key.RJ_EmpCd, EmployeeName = s.Key.RJ_Submitted_By, Interviews = s.Count() }).ToList(); var HiresYear = unitOfwork.RIC_Job_Report.GetAll() .Where(s => (ClientView.GetYear != 0 ? (getDateBool == false ? (s.RJ_Hire_Date >= fromDate && s.RJ_Hire_Date <= todate) : (s.RJ_Hire_Date != null && s.RJ_Hire_Date.Value.Year == ClientView.GetYear)) : (s.RJ_Hire_Date != null))) .GroupBy(s => new { s.RJ_Company, s.RJ_EmpCd, s.RJ_Submitted_By }).Select(s => new { Client = s.Key.RJ_Company, Empcode = s.Key.RJ_EmpCd, EmployeeName = s.Key.RJ_Submitted_By, Hires = s.Count() }).ToList(); ClientView.FilterData = (from getData in (from data in crosslist join Sub in submissionsYear on new { a = data.Client, b = data.Empcd } equals new { a = Sub.Client, b = Sub.Empcode } into sj from sSub in sj.DefaultIfEmpty() join Int in InterviewYear on new { a = data.Client, b = data.Empcd } equals new { a = Int.Client, b = Int.Empcode } into si from sInt in si.DefaultIfEmpty() join Hire in HiresYear on new { a = data.Client, b = data.Empcd } equals new { a = Hire.Client, b = Hire.Empcode } into sh from sHir in sh.DefaultIfEmpty() where sSub != null || sInt != null || sHir != null select new ClientOperationalList() { Client = data.Client, EmpCd = data.Empcd, EmployeeName = data.JobDivaUserName, Submissions = sSub != null ? sSub.Submissions : 0, Interviews = sInt != null ? sInt.Interviews : 0, Hires = sHir != null ? sHir.Hires : 0, SubByInterview = Math.Round((Convert.ToDouble(sInt != null ? sInt.Interviews : 0) / Convert.ToDouble(sSub != null ? sSub.Submissions : 1) * 100), 2), SubByHire = Math.Round((Convert.ToDouble(sHir != null ? sHir.Hires : 0) / Convert.ToDouble(sSub != null ? sSub.Submissions : 1) * 100), 2), InterviewByHire = Math.Round((Convert.ToDouble(sHir != null ? sHir.Hires : 0) / Convert.ToDouble(sInt != null ? sInt.Interviews : 1) * 100), 2) }) where ((ClientView.ClientSelected != "All" ? ClientView.ClientSelected == getData.Client : null != getData.Client) && (ClientView.SubSelected == ">" ? getData.Submissions >= ClientView.Submissions : getData.Submissions <= ClientView.Submissions) && (ClientView.InterviewSelected == ">" ? getData.Interviews >= ClientView.Interviews : getData.Interviews <= ClientView.Interviews) && (ClientView.HireSelected == ">" ? getData.Hires >= ClientView.Hires : getData.Hires <= ClientView.Hires)) select getData) .ToList(); ViewBag.ShowTable = true; List <RIC_Client> company = (from s in unitOfwork.User.GetByEmpID(empCd).RIC_ClientMapping select new RIC_Client() { RC_Id = s.RIC_Client.RC_Id, RC_ClientName = s.RIC_Client.RC_ClientName }).ToList(); List <SelectListItem> _lstClient = new List <SelectListItem>(); List <SelectListItem> _lstYear = new List <SelectListItem>(); _lstClient.Add(new SelectListItem() { Text = "All", Value = "All" }); foreach (var rule in company)// add the items in select list. { SelectListItem selectlistitem = new SelectListItem(); selectlistitem.Text = rule.RC_ClientName; selectlistitem.Value = rule.RC_ClientName.ToString(); _lstClient.Add(selectlistitem); } _lstYear.Add(new SelectListItem() { Text = "All", Value = "0" }); var yearList = Enumerable.Range(2016, usDate.Year - 2015).Select(s => new SelectListItem { Text = s.ToString(), Value = s.ToString() }).OrderByDescending(s => s.Value).ToList(); foreach (var year in yearList)// add the items in select list. { SelectListItem selectlistitem = new SelectListItem(); selectlistitem.Text = year.Text; selectlistitem.Value = year.Value; _lstYear.Add(selectlistitem); } ClientView.YearSelectList = _lstYear; ClientView.ClientList = _lstClient; return(View(ClientView)); }
public void ClientReportStart() { ClientReportView clientReportView = new ClientReportView(); clientReportView.ShowDialog(); }