public async Task SendMailForLecturers(BoardEnrollment boardEnrollment, Board board, string filePath) { try { string FromAddress = "*****@*****.**"; string FromAdressTitle = "Email from PMS!"; //To Address string ToAddress = boardEnrollment.Lecturer.Email; string ToAdressTitle = "PMS!"; string Subject = "Result form of " + board.Group.Project.Type; string BodyContent = "Xin gửi các thầy form chấm điểm của báo cáo đồ án " + board.Group.Project.Type + " của nhóm " + board.Group.GroupName; //Smtp Server string SmtpServer = this.config["EmailSettings:Server"]; //Smtp Port Number int SmtpPortNumber = Int32.Parse(this.config["EmailSettings:Port"]); var mimeMessage = new MimeMessage(); mimeMessage.From.Add(new MailboxAddress(FromAdressTitle, FromAddress)); mimeMessage.To.Add(new MailboxAddress(ToAdressTitle, ToAddress)); mimeMessage.Subject = Subject; var builder = new BodyBuilder(); builder.TextBody = BodyContent; // attach excel result file builder.Attachments.Add(filePath); // Now we just need to set the message body mimeMessage.Body = builder.ToMessageBody(); using (var client = new SmtpClient()) { client.Connect(SmtpServer, SmtpPortNumber, false); // Note: only needed if the SMTP server requires authentication // Error 5.5.1 Authentication client.Authenticate(this.config["EmailSettings:Email"], this.config["EmailSettings:Password"]); client.Send(mimeMessage); client.Disconnect(true); } } catch (Exception ex) { throw ex; } }
public void UpdateGrades(BoardEnrollment boardEnrollment, BoardEnrollmentResource boardEnrollmentResource) { var totalScore = 0.0; foreach (var gradeInformation in boardEnrollmentResource.GradeInformation) { var grade = context.Grades .Include(g => g.BoardEnrollment) .FirstOrDefault(g => g.BoardEnrollment.BoardEnrollmentId == boardEnrollment.BoardEnrollmentId && g.GradeDescription.Equals(gradeInformation.GradeDescription)); if (grade != null) { grade.Score = gradeInformation.Score; grade.Comment = gradeInformation.Comment; grade.BoardEnrollment = boardEnrollment; } totalScore += gradeInformation.Score.Value; } boardEnrollment.Score = totalScore; }
public void UpdateRecommendations(BoardEnrollment boardEnrollment, BoardEnrollmentResource boardEnrollmentResource) { if (boardEnrollmentResource.Recommendations != null && boardEnrollmentResource.Recommendations.Count >= 0) { //remove old tagprojects var oldRecommendations = boardEnrollment.Recommendations.Where(p => !boardEnrollmentResource.Recommendations.Any(id => id == p.Description)).ToList(); foreach (Recommendation recommendation in oldRecommendations) { recommendation.IsDeleted = true; boardEnrollment.Recommendations.Remove(recommendation); } //project.TagProjects.Clear(); //add new tagprojects var newRecommendations = boardEnrollmentResource.Recommendations.Where(t => !boardEnrollment.Recommendations.Any(id => id.Description == t)); foreach (var recommendation in newRecommendations) { boardEnrollment.Recommendations.Add(new Recommendation { IsDeleted = false, IsDone = false, Description = recommendation }); //project.TagProjects.Add(a); } } }
public async Task UpdateBoardEnrollments(Board board, BoardResource BoardResource) { if (BoardResource.BoardEnrollments != null && BoardResource.BoardEnrollments.Count >= 0) { // //remove old BoardEnrollments // board.BoardEnrollments.Clear(); // //add new enrollments // var newBoardEnrollments = context.BoardEnrollments.Where(e => BoardResource.BoardEnrollments.Any(id => id == e.BoardEnrollmentId)).ToList(); // foreach (var a in newBoardEnrollments) // { // board.BoardEnrollments.Add(a); // } var updatedBoardEnrollments = board.BoardEnrollments.ToList(); foreach (var boardEnrollment in updatedBoardEnrollments) { if (boardEnrollment.BoardRole.BoardRoleName == "Chair") { if (boardEnrollment.Lecturer.LecturerId == BoardResource.LecturerInformations.Chair.LecturerId) { boardEnrollment.Percentage = BoardResource.LecturerInformations.Chair.ScorePercent; } else { boardEnrollment.IsDeleted = true; board.BoardEnrollments.Remove(boardEnrollment); var chairBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = BoardResource.LecturerInformations.Chair.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Chair"), Lecturer = await context.Lecturers.FindAsync(BoardResource.LecturerInformations.Chair.LecturerId) }; context.BoardEnrollments.Add(chairBoardEnrollment); } } else if (boardEnrollment.BoardRole.BoardRoleName == "Secretary") { if (boardEnrollment.Lecturer.LecturerId == BoardResource.LecturerInformations.Secretary.LecturerId) { boardEnrollment.Percentage = BoardResource.LecturerInformations.Secretary.ScorePercent; } else { boardEnrollment.IsDeleted = true; board.BoardEnrollments.Remove(boardEnrollment); var secretaryBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = BoardResource.LecturerInformations.Secretary.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Secretary"), Lecturer = await context.Lecturers.FindAsync(BoardResource.LecturerInformations.Secretary.LecturerId) }; context.BoardEnrollments.Add(secretaryBoardEnrollment); } } else if (boardEnrollment.BoardRole.BoardRoleName == "Supervisor") { if (boardEnrollment.Lecturer.LecturerId == BoardResource.LecturerInformations.Supervisor.LecturerId) { boardEnrollment.Percentage = BoardResource.LecturerInformations.Supervisor.ScorePercent; } else { boardEnrollment.IsDeleted = true; board.BoardEnrollments.Remove(boardEnrollment); var supervisorBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = BoardResource.LecturerInformations.Supervisor.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Supervisor"), Lecturer = await context.Lecturers.FindAsync(BoardResource.LecturerInformations.Supervisor.LecturerId) }; context.BoardEnrollments.Add(supervisorBoardEnrollment); } } else if (boardEnrollment.BoardRole.BoardRoleName == "Reviewer") { if (boardEnrollment.Lecturer.LecturerId == BoardResource.LecturerInformations.Reviewer.LecturerId) { boardEnrollment.Percentage = BoardResource.LecturerInformations.Reviewer.ScorePercent; } else { boardEnrollment.IsDeleted = true; board.BoardEnrollments.Remove(boardEnrollment); var reviewerBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = BoardResource.LecturerInformations.Reviewer.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Reviewer"), Lecturer = await context.Lecturers.FindAsync(BoardResource.LecturerInformations.Reviewer.LecturerId) }; context.BoardEnrollments.Add(reviewerBoardEnrollment); } } } } }
public async Task AddLecturers(Board board, LecturerInformationResource lecturerInformations) { if (board.Group.Project.Type.Equals("Final Project")) { var presidentBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Chair.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Chair"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Chair.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Introduction", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (methods)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (analysis)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Media and Visual aids", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (delivery)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (preparation)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (style)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Audience connection", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (conclusion)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Questions and Answers", GradeMaxScore = 10 } } }; var secretaryBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Secretary.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Secretary"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Secretary.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Introduction", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (methods)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (analysis)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Media and Visual aids", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (delivery)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (preparation)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (style)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Audience connection", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (conclusion)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Questions and Answers", GradeMaxScore = 10 } } }; var reviewerBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Reviewer.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Reviewer"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Reviewer.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Introduction", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (methods)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (analysis)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Media and Visual aids", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (delivery)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (preparation)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (style)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Audience connection", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (conclusion)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Questions and Answers", GradeMaxScore = 10 } } }; var supervisorBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Supervisor.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Supervisor"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Supervisor.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Introduction", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (methods)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (analysis)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Media and Visual aids", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (delivery)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (preparation)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Presentation style (style)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Audience connection", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Content (conclusion)", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Questions and Answers", GradeMaxScore = 10 } } }; context.BoardEnrollments.Add(presidentBoardEnrollment); context.BoardEnrollments.Add(secretaryBoardEnrollment); context.BoardEnrollments.Add(reviewerBoardEnrollment); context.BoardEnrollments.Add(supervisorBoardEnrollment); } else { var presidentBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Chair.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Chair"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Chair.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Trình bày tốt (Chuẩn bị slide tốt, trình bày rõ ràng đúng thời hạn)", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Nội dung đề tai đạt yêu cầu đặt ra, có tính khoa học", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Phương pháp thực hiện tốt", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Kết quả đề tài có áp dụng thực tế", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Đề tài mới hoặc phương pháp thực hiện có tính sáng tạo", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Trả lời tập trung vào đề tài, trả lời tốt câu hỏi", GradeMaxScore = 20 }, } }; var secretaryBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Secretary.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Secretary"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Secretary.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Trình bày tốt (Chuẩn bị slide tốt, trình bày rõ ràng đúng thời hạn)", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Nội dung đề tai đạt yêu cầu đặt ra, có tính khoa học", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Phương pháp thực hiện tốt", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Kết quả đề tài có áp dụng thực tế", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Đề tài mới hoặc phương pháp thực hiện có tính sáng tạo", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Trả lời tập trung vào đề tài, trả lời tốt câu hỏi", GradeMaxScore = 20 }, } }; var reviewerBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Reviewer.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Reviewer"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Reviewer.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Trình bày tốt (Chuẩn bị slide tốt, trình bày rõ ràng đúng thời hạn)", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Nội dung đề tai đạt yêu cầu đặt ra, có tính khoa học", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Phương pháp thực hiện tốt", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Kết quả đề tài có áp dụng thực tế", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Đề tài mới hoặc phương pháp thực hiện có tính sáng tạo", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Trả lời tập trung vào đề tài, trả lời tốt câu hỏi", GradeMaxScore = 20 }, } }; var supervisorBoardEnrollment = new BoardEnrollment { Board = board, IsDeleted = false, isMarked = false, Percentage = lecturerInformations.Supervisor.ScorePercent, BoardRole = await context.BoardRoles.FirstOrDefaultAsync(c => c.BoardRoleName == "Supervisor"), Lecturer = await context.Lecturers.FindAsync(lecturerInformations.Supervisor.LecturerId), Grades = new Grade[] { new Grade { IsDeleted = false, GradeDescription = "Trình bày tốt (Chuẩn bị slide tốt, trình bày rõ ràng đúng thời hạn)", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Nội dung đề tai đạt yêu cầu đặt ra, có tính khoa học", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Phương pháp thực hiện tốt", GradeMaxScore = 20 }, new Grade { IsDeleted = false, GradeDescription = "Kết quả đề tài có áp dụng thực tế", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Đề tài mới hoặc phương pháp thực hiện có tính sáng tạo", GradeMaxScore = 10 }, new Grade { IsDeleted = false, GradeDescription = "Trả lời tập trung vào đề tài, trả lời tốt câu hỏi", GradeMaxScore = 20 }, } }; context.BoardEnrollments.Add(presidentBoardEnrollment); context.BoardEnrollments.Add(secretaryBoardEnrollment); context.BoardEnrollments.Add(reviewerBoardEnrollment); context.BoardEnrollments.Add(supervisorBoardEnrollment); } }
public string ExportExcelForLecturers(Board board, BoardEnrollment boardEnrollment) { var fileName = board.Group.GroupName + "_" + board.BoardId + "_resultForLecturers" + @".xlsx"; var formFolderPath = Path.Combine(host.ContentRootPath, "forms"); if (!System.IO.Directory.Exists(formFolderPath)) { System.IO.Directory.CreateDirectory(formFolderPath); } if (!board.Group.Project.Type.Equals("Final Project")) { var formFilePath = Path.Combine(formFolderPath, @"lecturer_form.xlsx"); // FileInfo file = new FileInfo(Path.Combine(rootFolder, fileName)); var uploadFolderPath = Path.Combine(host.ContentRootPath, "exports/excel"); if (!System.IO.Directory.Exists(uploadFolderPath)) { System.IO.Directory.CreateDirectory(uploadFolderPath); } var filePath = Path.Combine(uploadFolderPath, fileName); //copy file from formfolder to export folder System.IO.File.Copy(formFilePath, filePath, true); FileInfo file = new FileInfo(Path.Combine(uploadFolderPath, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; int studentRows = board.Group.Enrollments.Count(); worksheet.Cells[8, 3].Value = board.Group.Project.Title; int row = 12; var studentNames = board.Group.Enrollments.Select(e => e.Student.Name).ToList(); foreach (var studentName in studentNames) { worksheet.Cells[row, 3].Value = studentName; row++; } worksheet.Cells[16, 3].Value = boardEnrollment.Lecturer.Name; //add grade var firstGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Trình bày tốt (Chuẩn bị slide tốt, trình bày rõ ràng đúng thời hạn)")); worksheet.Cells[23, 4].Value = firstGrade.Score; worksheet.Cells[23, 5].Value = firstGrade.Comment; var secondGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Nội dung đề tai đạt yêu cầu đặt ra, có tính khoa học")); worksheet.Cells[24, 4].Value = secondGrade.Score; worksheet.Cells[24, 5].Value = secondGrade.Comment; var thirdGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Phương pháp thực hiện tốt")); worksheet.Cells[25, 4].Value = thirdGrade.Score; worksheet.Cells[25, 5].Value = thirdGrade.Comment; var fourthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Kết quả đề tài có áp dụng thực tế")); worksheet.Cells[26, 4].Value = fourthGrade.Score; worksheet.Cells[26, 5].Value = fourthGrade.Comment; var fifthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Đề tài mới hoặc phương pháp thực hiện có tính sáng tạo")); worksheet.Cells[27, 4].Value = fifthGrade.Score; worksheet.Cells[27, 5].Value = fifthGrade.Comment; var sixthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Trả lời tập trung vào đề tài, trả lời tốt câu hỏi")); worksheet.Cells[29, 4].Value = sixthGrade.Score; worksheet.Cells[29, 5].Value = sixthGrade.Comment; worksheet.Cells[30, 4].Value = firstGrade.Score.Value + secondGrade.Score.Value + thirdGrade.Score.Value + fourthGrade.Score.Value + fifthGrade.Score.Value + sixthGrade.Score.Value; // worksheet.Cells[22, 2].Value = boardEnrollment.Score; // worksheet.Cells[22, 3].Value = boardEnrollment.Comment; // row = 22; // foreach (var recommendation in boardEnrollment.Recommendations) // { // worksheet.Cells[row, 5].Value = recommendation.Description; // row++; // } worksheet.Cells[32, 5].Value = "Ngày " + DateTime.Now.Day.ToString() + " Tháng " + DateTime.Now.Month.ToString() + " Năm " + DateTime.Now.Year.ToString(); worksheet.PrinterSettings.FitToPage = true; worksheet.PrinterSettings.FitToWidth = 1; worksheet.PrinterSettings.FitToHeight = 0; package.Save(); //add to db var excel = new Excel { FileName = fileName }; excelRepository.AddExcel(excel); //send mail //SendMail(board, filePath); return(filePath); } } else { var formFilePath = Path.Combine(formFolderPath, @"lecturer_final_form.xlsx"); // FileInfo file = new FileInfo(Path.Combine(rootFolder, fileName)); var uploadFolderPath = Path.Combine(host.ContentRootPath, "exports/excel"); if (!System.IO.Directory.Exists(uploadFolderPath)) { System.IO.Directory.CreateDirectory(uploadFolderPath); } var filePath = Path.Combine(uploadFolderPath, fileName); //copy file from formfolder to export folder System.IO.File.Copy(formFilePath, filePath, true); FileInfo file = new FileInfo(Path.Combine(uploadFolderPath, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; int studentRows = board.Group.Enrollments.Count(); worksheet.Cells[8, 3].Value = board.Group.Project.Title; int row = 12; var studentNames = board.Group.Enrollments.Select(e => e.Student.Name).ToList(); foreach (var studentName in studentNames) { worksheet.Cells[row, 3].Value = studentName; row++; } worksheet.Cells[16, 3].Value = boardEnrollment.Lecturer.Name; //add grade var firstGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Introduction")); worksheet.Cells[23, FindNumberOfCell(firstGrade.Score.Value)].Value = "X"; var a = FindNumberOfCell(firstGrade.Score.Value); worksheet.Cells[23, 15].Value = firstGrade.Comment; var secondGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Content (methods)")); worksheet.Cells[24, FindNumberOfCell(secondGrade.Score.Value)].Value = "X"; worksheet.Cells[24, 15].Value = secondGrade.Comment; var thirdGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Content (analysis)")); worksheet.Cells[25, FindNumberOfCell(thirdGrade.Score.Value)].Value = "X"; worksheet.Cells[25, 15].Value = thirdGrade.Comment; var fourthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Media and Visual aids")); worksheet.Cells[26, FindNumberOfCell(fourthGrade.Score.Value)].Value = "X"; worksheet.Cells[26, 15].Value = fourthGrade.Comment; var fifthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Presentation style (delivery)")); worksheet.Cells[27, FindNumberOfCell(fifthGrade.Score.Value)].Value = "X"; worksheet.Cells[27, 15].Value = fifthGrade.Comment; var sixthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Presentation style (preparation)")); worksheet.Cells[28, FindNumberOfCell(sixthGrade.Score.Value)].Value = "X"; worksheet.Cells[28, 15].Value = sixthGrade.Comment; var seventhGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Presentation style (style)")); worksheet.Cells[29, FindNumberOfCell(seventhGrade.Score.Value)].Value = "X"; worksheet.Cells[29, 15].Value = sixthGrade.Comment; var eighthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Audience connection")); worksheet.Cells[30, FindNumberOfCell(eighthGrade.Score.Value)].Value = "X"; worksheet.Cells[30, 15].Value = sixthGrade.Comment; var ninethGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Content (conclusion)")); worksheet.Cells[31, FindNumberOfCell(ninethGrade.Score.Value)].Value = "X"; worksheet.Cells[31, 15].Value = sixthGrade.Comment; var tenthGrade = boardEnrollment.Grades.FirstOrDefault(g => g.GradeDescription.Equals("Questions and Answers")); worksheet.Cells[32, FindNumberOfCell(tenthGrade.Score.Value)].Value = "X"; worksheet.Cells[32, 15].Value = sixthGrade.Comment; worksheet.Cells[34, 4].Value = firstGrade.Score.Value + secondGrade.Score.Value + thirdGrade.Score.Value + fourthGrade.Score.Value + fifthGrade.Score.Value + sixthGrade.Score.Value + seventhGrade.Score.Value + eighthGrade.Score.Value + ninethGrade.Score.Value + tenthGrade.Score.Value; // worksheet.Cells[22, 2].Value = boardEnrollment.Score; // worksheet.Cells[22, 3].Value = boardEnrollment.Comment; // row = 22; // foreach (var recommendation in boardEnrollment.Recommendations) // { // worksheet.Cells[row, 5].Value = recommendation.Description; // row++; // } worksheet.Cells[36, 12].Value = "Ngày " + DateTime.Now.Day.ToString() + " Tháng " + DateTime.Now.Month.ToString() + " Năm " + DateTime.Now.Year.ToString(); worksheet.PrinterSettings.FitToPage = true; worksheet.PrinterSettings.FitToWidth = 1; worksheet.PrinterSettings.FitToHeight = 0; package.Save(); //add to db var excel = new Excel { FileName = fileName }; excelRepository.AddExcel(excel); //send mail //SendMail(board, filePath); return(filePath); } } }
public void RemoveBoardEnrollment(BoardEnrollment boardEnrollment) { boardEnrollment.IsDeleted = true; //context.Remove(boardEnrollment); }
public void AddBoardEnrollment(BoardEnrollment boardEnrollment) { context.BoardEnrollments.Add(boardEnrollment); }
public void UpdateScore(BoardEnrollment boardEnrollment) { context.Update(boardEnrollment); }