private bool _deattchCertificateFromQuizes(bool isActive, int courseId, out string error) { error = string.Empty; if (isActive) { return(true); } try { var quizzes = CourseQuizzesRepository.GetMany(x => x.CourseId == courseId && x.AttachCertificate).ToList(); foreach (var entity in quizzes) { entity.UpdateQuizCertAttachState(false); } return(CourseQuizzesRepository.UnitOfWork.CommitAndRefreshChanges(out error)); } catch (Exception ex) { error = FormatError(ex); return(false); } }
public CertificateDTO GetCourseCertificate(int courseId) { try { var entity = CertificateRepository.GetMany(x => x.CourseId == courseId).FirstOrDefault(); if (entity == null) { var courseEntity = CourseRepository.GetById(courseId); return(courseEntity != null ? new CertificateDTO(courseId, courseEntity.CourseName, this.GetCurrentUserName()) : new CertificateDTO { IsValid = false, Message = "Course not found" }); } var token = entity.Entity2CertificateDto(StudentCertificatesRepository.IsAny(x => x.CertificateId == entity.CertificateId), CourseQuizzesRepository.IsAny(x => x.CourseId == entity.CourseId && x.AttachCertificate)); return(token); } catch (Exception ex) { Logger.Error("get certificate token", courseId, ex, CommonEnums.LoggerObjectTypes.Certificate); return(new CertificateDTO { IsValid = false , Message = FormatError(ex) }); } }