不包括以前程序的价值评级
我有一个表格,该表显示申请人是否是某些计划的一部分,它将平均从以前的程序和当前程序中获得评级。一旦将申请人添加到新程序中,他们的评级为0,但是除非有人给他们的评级大于0,否则该评级将不包括在总体平均评级中,但是,如果将此人从当前程序中删除,并且然后稍后再次添加到同一程序中,然后将值0包括到整体评分。我不想那个,但是我一直在试图解决这个问题,即我的大脑都被扰乱了。我已经放置了使所有申请人都具有各自的程序,以前的程序和评级的代码。有什么帮助吗?我希望我有道理。
public async Task<T> GetAllApplicants()
{
// Other Code up here
IList<T> participants = await GetAllParticipants();
// applicants is being set somewhere else
foreach (var applicant in applicants)
{
applicant.Programs = participants
.Where(p => p.Email.EqualsIgnoreCase(applicant.Email))
.Select(p => p.ProgramName)
.ToList();
applicant.PreviousPrograms = participants
.Where(p => p.Email.EqualsIgnoreCase(applicant.Email) && p.IsPreviousParticipant)
.Select(p => p.ProgramName)
.ToList(p => p.ProgramName);
applicant.AverageRating = participants
.Where(p => p.Email.EqualsIgnoreCase(applicant.Email) && p.Rating > 0)
.Select(p => p.Rating)
.DefaultIfEmpty(3)
.Average()
.ToDouble();
}
return applicants;
}
I have a table that shows if an Applicant was part of certain program and it will average out their rating from previous programs and current programs. Once an applicant is added to a new program their rating is a 0 to start but it will not be included in the overall average rating unless someone gives them a different rating bigger than 0, however, if this person is removed from a current program and then later added again to that same program then it includes the value 0 to the overall rating. I don't want that but I've been trying to solve this issue that my brain is all scrambled. I have put the code that gets all Applicants with their respective programs, previous programs, and rating. Any help on this? I hope I made sense.
public async Task<T> GetAllApplicants()
{
// Other Code up here
IList<T> participants = await GetAllParticipants();
// applicants is being set somewhere else
foreach (var applicant in applicants)
{
applicant.Programs = participants
.Where(p => p.Email.EqualsIgnoreCase(applicant.Email))
.Select(p => p.ProgramName)
.ToList();
applicant.PreviousPrograms = participants
.Where(p => p.Email.EqualsIgnoreCase(applicant.Email) && p.IsPreviousParticipant)
.Select(p => p.ProgramName)
.ToList(p => p.ProgramName);
applicant.AverageRating = participants
.Where(p => p.Email.EqualsIgnoreCase(applicant.Email) && p.Rating > 0)
.Select(p => p.Rating)
.DefaultIfEmpty(3)
.Average()
.ToDouble();
}
return applicants;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜是,申请人没有正确地重新添加,因此以下返回一个空列表:
以下仅给出了平均值的默认值3:
I'd guess is that the applicant is not being re-added correctly so the following returns an empty list:
The the following just gives the default value of 3 for the average: