コード例 #1
0
        public SettingsViewModel(
            Settings settings,
            OpmlRepository opmlRepository,
            ChapterRepository chapterRepository,
            RepoService repoService,
            ViewService viewService,
            IEventAggregator eventAggregator,
            DialogService dialogService
            )
        {
            this.opmlRepository    = opmlRepository;
            this.chapterRepository = chapterRepository;
            this.repoService       = repoService;
            this.viewService       = viewService;
            this.dialogService     = dialogService;
            this.Settings          = settings;

            AddChapterCommand    = new DelegateCommand(AddChapter);
            DeleteChapterCommand = new DelegateCommand(DeleteChapter);
            ExportOpmlCommand    = new DelegateCommand(ExportOpml);
            ImportOpmlCommand    = new DelegateCommand(ImportOpml);
            MoveLeftCommand      = new DelegateCommand(MoveLeft);
            MoveRightCommand     = new DelegateCommand(MoveRight);

            eventAggregator.GetEvent <WindowClosingEvent>().Subscribe(SaveChapterName);
        }
コード例 #2
0
 public GradeController()
 {
     this.gradeRepository   = new GradeRepository(new GContext());
     this.studentRepository = new StudentRepository(new GContext());
     this.bookRespository   = new BookRepository(new GContext());
     this.chapterRepository = new ChapterRepository(new GContext());
 }
コード例 #3
0
 static void Initialize()
 {
     mangaRepository   = new MangaRepository(config);
     chapterRepository = new ChapterRepository(config);
     pageRepository    = new PageRepository(config);
     tagRepository     = new TagRepository(config);
 }
コード例 #4
0
 public UnitOfWork(AppDbContext context)
 {
     _context = context;
     Worlds   = new WorldRepository(_context);
     Books    = new BookRepository(_context);
     Chapters = new ChapterRepository(_context);
 }
コード例 #5
0
        public void OnInitialized(IContainerProvider containerProvider)
        {
            var viewService       = containerProvider.Resolve <ViewService>();
            var chapterRepository = new ChapterRepository();
            var chapters          = chapterRepository.GetOrDefault();

            viewService.AddMenuViews(chapters);
        }
コード例 #6
0
        public async Task ImportMembers(Guid currentMemberId, Guid chapterId, CsvFile file)
        {
            await AssertMemberIsChapterAdmin(currentMemberId, chapterId);

            IReadOnlyCollection <ChapterProperty> chapterProperties = await ChapterRepository.GetChapterProperties(chapterId);

            MemberCsvFileHeaders headers = new MemberCsvFileHeaders(chapterProperties);

            IDictionary <string, int> headerIndexes = file.GetColumnIndexes();

            IDictionary <int, Member> members = new Dictionary <int, Member>();

            IDictionary <int, MemberSubscription> membersSubscriptions = new Dictionary <int, MemberSubscription>();

            IDictionary <int, IReadOnlyCollection <MemberProperty> > membersProperties =
                new Dictionary <int, IReadOnlyCollection <MemberProperty> >();

            for (int i = 0; i < file.Rows.Count; i++)
            {
                CsvRow row = file.Rows.ElementAt(i);

                members.Add(i, new Member(Guid.Empty, chapterId,
                                          row.Value(headerIndexes[MemberCsvFileHeaders.Email]),
                                          true,
                                          row.Value(headerIndexes[MemberCsvFileHeaders.FirstName]),
                                          row.Value(headerIndexes[MemberCsvFileHeaders.LastName]),
                                          DateTime.UtcNow,
                                          true,
                                          false,
                                          0));

                if (DateTime.TryParse(row.Value(headerIndexes[MemberCsvFileHeaders.SubscriptionExpiry]), out DateTime subscriptionExpiry))
                {
                    membersSubscriptions.Add(i, new MemberSubscription(Guid.Empty, SubscriptionType.Full, subscriptionExpiry));
                }

                membersProperties.Add(i, chapterProperties
                                      .Select(x => new MemberProperty(Guid.Empty, Guid.Empty, x.Id, row.Value(headerIndexes[x.Label])))
                                      .ToArray());
            }

            // TODO: validate members

            for (int i = 0; i < file.Rows.Count; i++)
            {
                Guid memberId = await _memberRepository.CreateMember(members[i]);

                await _memberRepository.UpdateMemberProperties(memberId, membersProperties[i]);

                if (membersSubscriptions.ContainsKey(i))
                {
                    MemberSubscription subscription = new MemberSubscription(memberId, membersSubscriptions[i].Type, membersSubscriptions[i].ExpiryDate);
                    await _memberRepository.UpdateMemberSubscription(subscription);
                }
            }
        }
コード例 #7
0
 public ViewSurveyController(IUnitOfWork unitOfWork, MultichoiceQuestionRepository mr, Survey_MultichoiceQuestionRepository smr, Survey_FreeTextQuestionRepository sfr, FreeTextQuestionRepository ftr, ChapterRepository cr, OptionsRepository or, MultichoiceQuestion_OptionsRepository mor, SurveyRepository sr)
 {
     _unitOfWork = unitOfWork;
     _mr         = mr;
     _smr        = smr;
     _sfr        = sfr;
     _ftr        = ftr;
     _cr         = cr;
     _or         = or;
     _mor        = mor;
     _sr         = sr;
 }
コード例 #8
0
        public async Task <CsvFile> GetMemberImportFile(Guid currentMemberId, Guid chapterId)
        {
            await AssertMemberIsChapterAdmin(currentMemberId, chapterId);

            IReadOnlyCollection <ChapterProperty> properties = await ChapterRepository.GetChapterProperties(chapterId);

            MemberCsvFileHeaders headers = new MemberCsvFileHeaders(properties);

            CsvFile file = new CsvFile();

            file.Header.AddValues(headers.ToFields());
            return(file);
        }
コード例 #9
0
        public LinksViewModel(
            ChapterRepository chapterRepository,
            DialogService dialogService,
            DetectionService detectionService,
            IEventAggregator eventAggregator
            )
        {
            this.chapterRepository = chapterRepository;
            this.eventAggregator   = eventAggregator;
            this.dialogService     = dialogService;

            AddCommand       = new DelegateCommand(async() => await detectionService.SetAddress(Data.Linked));
            MoveCommand      = new DelegateCommand <Link>(Move);
            DeleteCommand    = new DelegateCommand <Link>(Delete);
            SelectionCommand = new DelegateCommand <Link>(link => detectionService.Selected(Data.Linked, link));
        }
コード例 #10
0
        public List <Chapter_Type> BookChapters(string BookName)
        {
            List <ChapterType>  _books = new ChapterRepository(BookName, UserID, "BookModel", "BookChapters").Books;
            List <Chapter_Type> books  = new List <Chapter_Type>();

            foreach (var item in _books)
            {
                books.Add(new Chapter_Type
                {
                    BookName     = item.BookName,
                    Chapter      = item.Chapter,
                    ChapterName  = item.ChapterName,
                    DisplayOrder = item.DisplayOrder,
                    Title        = item.Title
                });
            }
            return(books);
        }
コード例 #11
0
        public void AddChapterTest()
        {
            //-- Arrange
            var     random   = new Random();
            Chapter expected = new Chapter
            {
                Id        = random.Next(1_000_000, 2_000_000),
                DiaryId   = 1,
                Name      = "TestChapter",
                Location  = "Narnia",
                Date      = new DateTime(2020, 3, 3),
                Content   = "Test Content",
                CreatedOn = new DateTime(2020, 9, 9)
            };

            var dbContextFactory = new AtwDbContextFactory();
            var dbContext        = dbContextFactory.CreateDbContext(new string[0]);

            var chapterRepository = new ChapterRepository(dbContext);

            //-- Act
            chapterRepository.Add(expected);
            chapterRepository.SaveChanges();
            var actual = chapterRepository.GetById(expected.Id);



            //--Assert
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.DiaryId, actual.DiaryId);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Location, actual.Location);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Content, actual.Content);
            Assert.AreEqual(expected.CreatedOn, actual.CreatedOn);

            dbContext.Dispose();
        }
コード例 #12
0
        public void Should_Fail_When_AddingAChapterWithNegativeDiaryId()
        {
            var dbContextFactory = new AtwDbContextFactory();
            var dbContext        = dbContextFactory.CreateDbContext(new string[0]);

            try
            {
                //-- Arrange
                var     random   = new Random();
                Chapter expected = new Chapter
                {
                    Id        = random.Next(1_000_000, 2_000_000),
                    DiaryId   = -1,
                    Name      = "TestChapter",
                    Location  = "Narnia",
                    Date      = new DateTime(2020, 3, 3),
                    Content   = "Test Content",
                    CreatedOn = new DateTime(2020, 9, 9)
                };



                var chapterRepository = new ChapterRepository(dbContext);

                //-- Act
                chapterRepository.Add(expected);
                chapterRepository.SaveChanges();
            }

            finally
            {
                dbContext.Dispose();
            }


            //--Assert
        }
コード例 #13
0
        public TheragathaProvider(ChapterRepository chapterRepository)
        {
            _chapterRepository = chapterRepository;
            _sources           = new List <SourceFile>();
            _sources.Add(new SourceFile {
                Type = ChapterType.ThagSingleVerse, Location = "thag.01.00x.than.html"
            });

            DirectoryInfo dir = new DirectoryInfo(SITEBASE.ToApplicationPath());

            foreach (var file in dir.GetFiles())
            {
                Regex fileMatch = new Regex(@"thag\.(\d+\.\d+)\.than.html");
                if (fileMatch.IsMatch(file.Name) && file.Name != "thag.01.00x.than.html")
                {
                    _sources.Add(new SourceFile {
                        Type = ChapterType.ThagMultipleVerse, Location = file.Name
                    });
                }
            }

            //_sources.Add(new SourceFile { Type = ChapterType.ThagMultipleVerse, Location = "thag.02.13.than.html"});
            //_sources.Add(new SourceFile { Type = ChapterType.ThagMultipleVerse, Location = "thag.02.24.than.html"});
        }
コード例 #14
0
 public Handler(ChapterRepository repository)
 {
     _repository = repository;
 }
コード例 #15
0
 public DhammapadaProvider(ChapterRepository chapterRepository)
 {
     this.chapterRepository = chapterRepository;
 }
コード例 #16
0
 public ChapterService()
 {
     _chapterRepository     = new ChapterRepository();
     _subjectChapterService = new SubjectChapterService();
 }
コード例 #17
0
 public SnippetService()
 {
     this.chapterRepository = new ChapterRepository();
     this.verseRepository   = new VerseRepository();
 }
コード例 #18
0
ファイル: ChapterController.cs プロジェクト: rmendezm8219/GWA
 public ChapterController()
 {
     this.bookRepository    = new BookRepository(new GContext());
     this.chapterRepository = new ChapterRepository(new GContext());
 }
コード例 #19
0
 public Handler(SagaRepository sagaRepository, ChapterRepository chapterRepository)
 {
     _sagaRepository    = sagaRepository;
     _chapterRepository = chapterRepository;
 }