예제 #1
0
 public UnitOfWork(ELearningDBContext context)
 {
     _context = context;
     Account  = new AccountRepository(_context);
     Comments = new CommentRepository(_context);
     Courses  = new CourseRepository(_context);
     // CourseSubject = new CourseSubjectRepository(_context);
     Documents       = new DocumentRepository(_context);
     Lectures        = new LectureRepository(_context);
     Rating          = new RatingRepository(_context);
     Role            = new RoleRepository(_context);
     StudentSubjects = new StudentSubjectRepository(_context);
     StudentTests    = new StudentTestRepository(_context);
     Subjects        = new SubjectRepository(_context);
     TeacherSubjects = new TeacherSubjectRepository(_context);
 }
예제 #2
0
        public RatingDto CalculatorRate(int CourseId)
        {
            NumberFormatInfo nfi = new NumberFormatInfo
            {
                NumberDecimalSeparator = "."
            };

            using (var db = new ELearningDBContext())
            {
                var ratings = db.Ratings.Where(x => x.CourseId == CourseId).ToList();
                if (ratings.Count == 0)
                {
                    return(new RatingDto
                    {
                        Count = 0,
                        Rate = 0,
                        RateStr = "0",
                        Total = 0,
                        TotalRateStr = "0",
                    });
                }
                double rate = 0;
                foreach (var item in ratings)
                {
                    rate += item.Point;
                }
                double total = rate / (double)ratings.Count;
                return(new RatingDto
                {
                    Count = ratings.Count,
                    Rate = rate,
                    RateStr = rate.ToString(nfi),
                    Total = total,
                    TotalRateStr = total.ToString(nfi),
                });
            }
        }
 public StudentTestRepository(ELearningDBContext context)
     : base(context)
 {
 }
 public DocumentRepository(ELearningDBContext context)
     : base(context)
 {
 }
 public SubjectRepository(ELearningDBContext context)
     : base(context)
 {
 }
예제 #6
0
 public RoleRepository(ELearningDBContext context)
     : base(context)
 {
 }
예제 #7
0
 public LectureRepository(ELearningDBContext context)
     : base(context)
 {
 }
 public AccountRepository(ELearningDBContext context)
     : base(context)
 {
 }
예제 #9
0
 public CourseRepository(ELearningDBContext context)
     : base(context)
 {
 }