コード例 #1
0
        public void addIfValid(
            string emailAddress,
            int universityId,
            StudentRepository studentRepository,
            UniversityRepository universityRepository)
        {
            Logger.log("Start add student with email", emailAddress);

            validateEmail(emailAddress);

            if (studentRepository.exists(emailAddress))
            {
                return;
            }

            University university = universityRepository.getByID(universityId);
            Student    student    = studentRepository.createStudent(emailAddress, universityId);

            PackageType type = university.getPackageType();

            BookAllowanceSetter allowanceSetter = new BookAllowanceSetter(student);

            allowanceSetter.SetAllowance(type);

            studentRepository.add(student);

            Logger.log("End add student with email", emailAddress);
        }
コード例 #2
0
 public IList<University> GetAll()
 {
     using (UniversityRepository repository = new UniversityRepository())
     {
         return repository.GetAll();
     }
 }
コード例 #3
0
 public AddStudyGroupServerAction(IServiceProvider serviceProvider, ProfileRepository profileRepository, UniversityRepository universityRepository, StudyGroupRepository studyGroupRepository, StringStandardizationService stringStandardizationService, TextService textService) : base(serviceProvider)
 {
     _universityRepository         = universityRepository;
     _studyGroupRepository         = studyGroupRepository;
     _stringStandardizationService = stringStandardizationService;
     _textService = textService;
 }
コード例 #4
0
        public IActionResult UniversityFullInfo(int IDUniversity)
        {
            var university          = UniversityRepository.Get(IDUniversity);
            var universityViewModel = Mapper.Map <UniversityViewModel>(university);

            return(View(universityViewModel));
        }
コード例 #5
0
        public IActionResult UniversityList()
        {
            var universities = UniversityRepository
                               .GetAll()
                               .Select(x => Mapper.Map <UniversityViewModel>(x))
                               .ToList();

            return(View(universities));
        }
コード例 #6
0
        public void AddUniversity(University university)
        {
            if (university == null)
                throw new ArgumentNullException("university");

            using (UniversityRepository universityRepository = new UniversityRepository())
            {
                universityRepository.Add(university);
                universityRepository.Commit();
            }
        }
コード例 #7
0
        public void AddSpecialityTest()
        {
            UniversityAppService target = new UniversityAppService();

            Speciality speciality = Speciality.CreateSpeciality(specialityId, "计算机", "理科", new Guid("D4FCA237-DA28-4B30-B357-0005CE66716A"),
                "工学","电气信息类", 4);
            target.AddSpeciality(speciality);
            UniversityRepository repository = new UniversityRepository();
            var university = repository.Get(speciality.UniversityId);
            var createdSpeciality = university.Specialities.SingleOrDefault<Speciality>(s => s.Id == specialityId);
            Assert.AreNotEqual(createdSpeciality, null);
            Assert.AreEqual(createdSpeciality.Id, specialityId);
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: KenanPashaiev/UniversityApp
        ////Adding
        //Adding Button Clicks
        private void AddUniversityButton_Click(object sender, EventArgs e)
        {
            var universityRepository = new UniversityRepository();
            var universityName       = addUniversityNameTextBox.Text;
            var university           = new University(universityName);

            if (_inspecting != Inspecting.Universities)
            {
                return;
            }

            universityRepository.Create(university);
            RefreshUniversitiesList();
        }
コード例 #9
0
 public UnitOfWork(AcaShareDbContext dbContext)
 {
     _db                     = dbContext;
     Universities            = new UniversityRepository(_db.University);
     Departments             = new DepartmentRepository(_db.Department);
     Semesters               = new SemesterRepository(_db.Semester);
     Subjects                = new SubjectRepository(_db.Subject);
     Lessons                 = new LessonRepository(_db.Lesson);
     Users                   = new UserRepository(_db.User);
     Materials               = new MaterialRepository(_db.Material, _db.File, _db.ChangeReason, _db.DeleteRequest, _db.EditRequest);
     MaterialStates          = new MaterialStatesRepository(_db.MaterialState);
     SidebarRepository       = new SidebarRepository(_db.Comment, _db.Material, _db.Favorites);
     StatisticsRepository    = new StatisticsRepository(_db.DeleteRequest);
     NotificationRepository  = new NotificationRepository(_db.Notification);
     MainModeratorRepository = new MainModeratorRepository(_db.UniversityMainModerator);
 }
コード例 #10
0
ファイル: Form1.cs プロジェクト: KenanPashaiev/UniversityApp
        private void SelectCellFromUniversityRow(DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ShowContextMenu(e);
                return;
            }

            var universityRepository = new UniversityRepository();

            var table        = universityRepository.FindAll();
            var universityId = table.Rows[e.RowIndex].Field <int>("UniversityID");

            _inspecting = Inspecting.Groups;
            _inspectingList.Add(universityId);
            RefreshGroupsList(universityId);
        }
コード例 #11
0
ファイル: APITests.cs プロジェクト: mariekassis/si2
        public void setUp()
        {
            obj        = new UniversitiesController(_linkGenerator, _logger, _universityService);
            id         = new Guid("1B7F86DD-FCD0-42A5-5E5F-08D7D5A16E26");
            repository = new UniversityRepository(dbContext);
            source     = new CancellationTokenSource();
            token      = source.Token;
            pagedResourceParameters = new UniversityResourceParameters();
            context       = new ActionContext();
            universityDto = new UniversityDto();

            //serviceProvider
            var serviceCollection = new ServiceCollection();

            //serviceCollection.AddSingleton<IUniversityService, UniversityService>();
            //serviceCollection.AddTransient<University>();
            serviceCollection.AddTransient <IInstitutionService, InstitutionService>();

            _serviceProvider = serviceCollection.BuildServiceProvider();
            //--------------------------------------------------------------

            uow = new UnitOfWork(dbContext, _serviceProvider);

            //logger
            var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .AddFilter("Microsoft", LogLevel.Warning)
                .AddFilter("System", LogLevel.Warning)
                .AddFilter("LoggingConsoleApp.University", LogLevel.Debug)
                .AddConsole()
                .AddEventLog();
            });

            logger = loggerFactory.CreateLogger <UniversityService>();
            logger.LogInformation("Example log message");
            //------------------------------------------------------------------

            _mapper           = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }).CreateMapper();
            universityService = new UniversityService(uow, _mapper, logger);
        }
コード例 #12
0
 public LecturerService(UniversityRepository <Lecturer> lecturerRepository)
 {
     this.lecturerRepository = lecturerRepository;
 }
コード例 #13
0
 public StudentService(UniversityRepository <Student> studentRepository)
 {
     this.studentRepository = studentRepository;
 }
コード例 #14
0
 public void AddUniversityTest()
 {
     UniversityAppService target = new UniversityAppService();
     University university = University.CreateUniversity(universityId, "上海测试大学", "普通高校", "无", "上海市福州路1号", false, true, false, "上海市", "上海市");
     target.AddUniversity(university);
     using (UniversityRepository repository = new UniversityRepository())
     {
         var createdUniversity = repository.Get(universityId);
         Assert.AreNotEqual(createdUniversity, null);
         Assert.AreEqual(createdUniversity.Name, "上海测试大学");
     }
 }
コード例 #15
0
 public void UpdateUniversityTest()
 {
     UniversityAppService target = new UniversityAppService();
     using (UniversityRepository repository = new UniversityRepository())
     {
         var university = repository.Get(new Guid("AA1E7B07-3701-41FC-9291-D742B9E17DDE"));//universityId);
         university.Email = "*****@*****.**";
         target.UpdateUniversity(university);
         repository.Refresh(university);
         Assert.AreEqual(university.Email, "*****@*****.**");
     }
 }
コード例 #16
0
        public void UpdateUniversity(University university)
        {
            if (university == null)
                throw new ArgumentNullException("university");

            using (UniversityRepository universityRepository = new UniversityRepository())
            {
                var original = universityRepository.Get(university.Id);
                universityRepository.Merge(university);
                universityRepository.Commit();
            }
        }
コード例 #17
0
 public EducationalInstitutionController(UniversityRepository universityRepository, SchoolRepository schoolRepository, IMapper mapper)
 {
     UniversityRepository = universityRepository;
     SchoolRepository     = schoolRepository;
     Mapper = mapper;
 }
コード例 #18
0
 public CourseService(UniversityRepository <Lecturer> lecturerRepository, UniversityRepository <Course> courseRepository, UniversityRepository <Student> studentRepository)
 {
     this.lecturerRepository = lecturerRepository;
     this.courseRepository   = courseRepository;
     this.studentRepository  = studentRepository;
 }
コード例 #19
0
        public CoursesController(UniversityContext context, IMapper mapper)
        {
            repo = new UniversityRepository(context);

            this.mapper = mapper;
        }
コード例 #20
0
 public GetUniversitiesAndStudyGroupsServerAction(IServiceProvider serviceProvider, UniversityRepository universityRepository, UniwikiContext uniwikiContext) : base(serviceProvider)
 {
     _universityRepository = universityRepository;
     _uniwikiContext       = uniwikiContext;
 }
コード例 #21
0
 public UniversityManager()
 {
     _IUniversityRepository = new UniversityRepository();
 }
コード例 #22
0
 public void RemoveUniversity(Guid universityId)
 {
     using (UniversityRepository universityRepository = new UniversityRepository())
     {
         var university = universityRepository.Get(universityId);
         if (university != null)
         {
             universityRepository.Remove(university);
             universityRepository.Commit();
         }
     }
 }
コード例 #23
0
 public HomeTaskService(UniversityRepository <Course> courseRepository, UniversityRepository <HomeTask> homeTaskRepository)
 {
     this.courseRepository   = courseRepository;
     this.homeTaskRepository = homeTaskRepository;
 }
コード例 #24
0
 public AddUniversityServerAction(IServiceProvider serviceProvider, UniversityRepository universityRepository, TextService textService) : base(serviceProvider)
 {
     _universityRepository = universityRepository;
     _textService          = textService;
 }