private void BuildProjectsSheet(IXLWorksheet ws, List <ProjectEntity> projects, CategoryEntity category, JudgeEntity vicePresident) { PutPageHeader(ws); var tableData = new List <List <string> > { new List <string> { "Nr. Crt.", "Denumire proiect" } }; tableData.AddRange(projects.Select(p => new List <string> { p.Title })); SetTitle(ws, "LISTA PROIECTELOR ÎNSCRISE LA SECȚIUNEA " + category.Name.ToUpper(), 7, 5); int crtRow = 9; SetTableContent(ws, ref crtRow, tableData, true, AdjustColumnWidth); if (_editionHasVicePresidents) { SetWhoSignsIndividual(ws, ref crtRow, "VICEPREȘEDINTE", vicePresident?.FullName.ToUpper(), 1); } }
public async Task <JudgingPageModel> BuildJudgingPageModel(JudgeEntity judge, JudgingType type) { var model = new JudgingPageModel { Judge = judge, Type = type }; var projectsE = await ProjectsRepo.GetAll(p => p.Category == judge.Category && (type == JudgingType.Project || p.IsInOpen)); model.Category = judge.Category; model.Projects = Mapper.Map <List <ProjectViewModel> >(projectsE); var sections = await SectionsRepo.GetAll(s => s.Category == model.Category && s.Type == type); foreach (var section in sections) { section.Criteria = section.Criteria.OrderBy(c => c.Name).ToList(); } model.JudgingSections = Mapper.Map <List <JudgingCriteriaSectionViewModel> >(sections); model.InitialPoints = Mapper.Map <List <ProjectJudgingCriterionPointsViewModel> >( await PointsRepo.GetAll(p => p.Judge == model.Judge && p.Criterion.Type == type)); return(model); }
private void BuildIndividualTallySheet(IXLWorksheet ws, JudgeEntity judge, List <ProjectEntity> projects, List <JudgingCriteriaSectionEntity> sections, List <ProjectJudgingCriterionPointsEntity> points, bool isOpen = false) { var cat = judge.Category; PutPageHeader(ws); var th = new List <string> { "Nr. Crt.", "Denumire proiect" }; th.AddRange(sections.Select((s, i) => "Criteriu " + (i + 1) + "\n" + s.MaxPoints / (cat.ScoresX10 ? 10f : 1) + "p")); th.Add("TOTAL\n" + (isOpen ? "OPEN" : "PROIECT")); SetTitle(ws, "BORDEROU INDIVIDUAL" + (isOpen ? " OPEN" : "") + " SECȚIUNEA " + judge.Category.Name.ToUpper(), 7, th.Count); var tableData = new List <List <string> > { th }; int crtRow = 9; var firstCol = 'A'; foreach (var project in projects) { // var row = sections.Select(s => // points.Where(p => p.Project == project && p.Criterion.Section == s).Sum(p => p.Points) // / (cat.ScoresX10 ? 10f : 1) // ).Select(s => s.ToString()).ToList(); // var row = sections.Select(s => s.CalcPointsFor(points, project, cat)).Select(s => s.ToString()) // .ToList(); var row = sections.Select(s => Math.Round(points.Where(p => p.Project == project && p.Criterion.Section == s).Sum(p => p.Points) / (cat.ScoresX10 ? 10f : 1), 2) ).Select(s => s.ToString(CultureInfo.InvariantCulture)).ToList(); row.Insert(0, project.Title); row.Add($"=CEILING(SUM({(char) (firstCol + 2)}<crtRow>:{(char) (firstCol + row.Count)}<crtRow>), 1)"); tableData.Add(row); } SetTableContent(ws, ref crtRow, tableData, true, AdjustColumnWidth, firstCol); SetWhoSignsIndividual(ws, ref crtRow, "MEMBRU EVALUATOR", judge.FullName.ToUpper(), th.Count - 1); }
public async Task <Dictionary <string, object> > SetPoints(JudgeEntity judge, string criterionId, string projectId, int points) { var existing = await PointsRepo.GetOne(p => p.Judge == judge && p.Criterion.Id == criterionId && p.Project.Id == projectId); if (existing != null) { if (existing.Points != points) { existing.Points = points; await PointsRepo.SaveChanges(); } } else { await PointsRepo.Add(new ProjectJudgingCriterionPointsEntity { Points = points, Judge = judge, Criterion = JudgingCriteriaRepo.Attach(criterionId), Project = ProjectsRepo.Attach(projectId), }); } var judgingType = await JudgingCriteriaRepo.Queryable.Where(jc => jc.Id == criterionId) .Select(jc => jc.Type).FirstOrDefaultAsync(); var projectPoints = await PointsRepo.DbSet.Where(p => p.Criterion.Type == judgingType && p.Judge == judge && p.Project.Id == projectId) .SumAsync(p => p.Points); var sectionsPoints = await PointsRepo.DbSet .Where(p => p.Criterion.Type == judgingType && p.Judge == judge && p.Project.Id == projectId) .GroupBy(p => p.Criterion.Section.Id) .Select(g => new { Id = g.Key, Points = g.Sum(p => p.Points) }).ToListAsync(); var dict = new Dictionary <string, object> { ["total"] = projectPoints.ToString(), ["sections"] = sectionsPoints, }; return(dict); }