public int GetRegisteredTeachersCount(Subjects subject) { EducationDatabaseEntities ent = new EducationDatabaseEntities(); ISubjectsUsersRepository suRepo = new SubjectsUsersRepository(ent); return(suRepo.GetAll().Where(x => x.SubjectId == subject.Id).Where(x => x.Users.UserType == "Teacher").Count()); }
public void RegisterUserToSubject(Users user, Subjects subject) { EducationDatabaseEntities ent = new EducationDatabaseEntities(); ISubjectsUsersRepository suRepo = new SubjectsUsersRepository(ent); bool allowOperation = (suRepo.GetAll().Where(x => x.UserId == user.Id).Where(x => x.SubjectId == subject.Id).Count() > 0); // Szerepel már benne? if (allowOperation) { suRepo.Add(new SubjectsUsers() { EnrollDate = DateTime.Now, SubjectId = subject.Id, UserId = user.Id }); } }