Esempio n. 1
0
        public async Task <CardSectionMessage> ProcessItem(Article article)
        {
            var cardSections = new List <CardSection>();

            var contentResult = await _wikiArticle.Simple(article.Id);

            foreach (var section in contentResult.Sections)
            {
                if (section.Title.Equals("References", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                var rulingSection = new CardSection
                {
                    Name        = section.Title,
                    ContentList = SectionHelper.GetSectionContentList(section)
                };

                cardSections.Add(rulingSection);
            }

            var cardSectionMessage = new CardSectionMessage {
                Name = article.Title, CardSections = cardSections
            };

            return(cardSectionMessage);
        }
        public async Task <ArticleTaskResult> ProcessItem(UnexpandedArticle item)
        {
            var response = new ArticleTaskResult {
                Article = item
            };

            var card = await _cardService.CardByName(item.Title);

            if (card != null)
            {
                var triviaSections = new List <CardTriviaSection>();

                var articleCardTrivia = await _wikiArticle.Simple(item.Id);

                foreach (var cardTriviaSection in articleCardTrivia.Sections)
                {
                    if (cardTriviaSection.Title.Equals("References", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    var rulingSection = new CardTriviaSection
                    {
                        Name   = cardTriviaSection.Title,
                        Trivia = SectionHelper.GetSectionContentList(cardTriviaSection)
                    };

                    triviaSections.Add(rulingSection);
                }

                await _cardTriviaService.Update(card.Id, triviaSections);
            }

            return(response);
        }
Esempio n. 3
0
        public dynamic SearchSectionBySectionId(DTO.LABURNUM.COM.SectionModel model)
        {
            if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
            {
                if (model.SectionId <= 0)
                {
                    return(GetApiResponseModel("Section Id Cannnot Be Null.", true, null));
                }

                List <DTO.LABURNUM.COM.SectionModel> dbSections = new SectionHelper(new FrontEndApi.SectionApi().GetSectionByAdvanceSearch(model)).Map();
                if (dbSections.Count == 0)
                {
                    return(GetApiResponseModel("No Record Found For Given Section Id", true, null));
                }
                if (dbSections.Count > 1)
                {
                    return(GetApiResponseModel("More Than One Record Found Please Contact Administrator", true, null));
                }
                return(GetApiResponseModel("Successfully Performed.", true, dbSections[0]));
            }
            else
            {
                return(GetApiResponseModel("Api Access User Name or Password Invalid.", false, null));
            }
        }
 /// <summary>
 /// F16 Defence Prior Information factory constructor.
 /// </summary>
 /// <param name="notice">The notice</param>
 /// <param name="eSenderLogin">The TED esender login</param>
 /// <param name="tedESenderOrganisation">Organisation that sends notices to eSender api</param>
 /// <param name="tedContactEmail">Contact email for technical</param>
 /// <param name="translationProvider"></param>
 public F16Factory(NoticeContract notice, string eSenderLogin, string tedESenderOrganisation, string tedContactEmail, ITranslationProvider translationProvider)
 {
     _notice                 = notice;
     _eSenderLogin           = eSenderLogin;
     _tedContactEmail        = tedContactEmail;
     _tedESenderOrganisation = tedESenderOrganisation;
     _configuration          = NoticeConfigurationFactory.CreateConfiguration(notice);
     _helper                 = new SectionHelper(_notice, _configuration, translationProvider);
 }
Esempio n. 5
0
        public void Given_A_Section_With_ContentList_Should_Return_All_ListElements(Section section, string[] expected)
        {
            // Assert

            // Act
            var result = SectionHelper.GetSectionContentList(section);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
Esempio n. 6
0
        public void Given_A_Section_With_ContentList_Should_Use_Recursion_To_Traverse_Data(Section section, string[] expected)
        {
            // Assert

            // Act
            var result = SectionHelper.GetSectionContentList(section);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
Esempio n. 7
0
 public dynamic SearchAllSections(DTO.LABURNUM.COM.SectionModel model)
 {
     if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
     {
         List <DTO.LABURNUM.COM.SectionModel> dbSections = new SectionHelper(new FrontEndApi.SectionApi().GetActiveSections()).Map();
         return(GetApiResponseModel("Successfully Performed.", true, dbSections));
     }
     else
     {
         return(GetApiResponseModel("Api Access User Name or Password Invalid.", false, null));
     }
 }
        public void Modify(SectionInChunk Loc, BlockInSection slot, byte blockId)
        {
            if (m_Helpers.TryGetValue(Loc.Value, out var SectionHelper))
            {
                SectionHelper.Modify(slot, blockId);
            }
            else
            {
                m_Changes.Add(new SectionChange(Loc.Value));
                SectionHelper = new SaveHelper_Section(m_Changes[m_Changes.Count - 1]);

                m_Helpers.Add(Loc.Value, SectionHelper);
                SectionHelper.Modify(slot, blockId);
            }
        }
Esempio n. 9
0
        public ActionResult Index(LoginModel model)
        {
            var result = new AccountModel().Login(model.UserName, model.PassWord);

            if (result && ModelState.IsValid)
            {
                SectionHelper.SetSection(new UserSection()
                {
                    UserName = model.UserName
                });
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "Tao đố mày biết tên đăng nhập hay mật khẩu sai :) ");
            }
            return(View(model));
        }
Esempio n. 10
0
        public dynamic SearchSectionByClassId(DTO.LABURNUM.COM.SectionModel model)
        {
            if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password))
            {
                if (model.ClassId <= 0)
                {
                    return(GetApiResponseModel("Class Id Cannnot Be Null.", true, null));
                }

                List <DTO.LABURNUM.COM.SectionModel> dbSections = new SectionHelper(new FrontEndApi.SectionApi().GetSectionByAdvanceSearch(model)).Map();
                if (dbSections.Count == 0)
                {
                    return(GetApiResponseModel("No Section Found For Given Class Id", true, dbSections));
                }
                return(GetApiResponseModel("Successfully Performed.", true, dbSections));
            }
            else
            {
                return(GetApiResponseModel("Api Access User Name or Password Invalid.", false, null));
            }
        }
Esempio n. 11
0
        public async Task <ArticleTaskResult> ProcessItem(UnexpandedArticle item)
        {
            var response = new ArticleTaskResult {
                Article = item
            };

            var card = await _cardService.CardByName(item.Title);

            if (card != null)
            {
                var tipSections = new List <CardTipSection>();

                var articleCardTips = await _wikiArticle.Simple(item.Id);

                foreach (var cardTipSection in articleCardTips.Sections)
                {
                    var tipSection = new CardTipSection
                    {
                        Name = cardTipSection.Title,
                        Tips = SectionHelper.GetSectionContentList(cardTipSection)
                    };


                    if (cardTipSection.Title.Equals("List", StringComparison.OrdinalIgnoreCase) ||
                        cardTipSection.Title.Equals("Lists", StringComparison.OrdinalIgnoreCase))
                    {
                        tipSection.Name = tipSection.Tips.First();
                        tipSection.Tips.Clear();
                        _tipRelatedWebPage.GetTipRelatedCards(tipSection, item);
                    }

                    tipSections.Add(tipSection);
                }

                await _cardTipService.Update(card.Id, tipSections);
            }

            return(response);
        }
        public async Task <ArticleTaskResult> ProcessItem(Article article)
        {
            var response = new ArticleTaskResult {
                Article = article
            };

            var tipSections = new List <CardSection>();

            var articleCardTips = await _wikiArticle.Simple(article.Id);

            foreach (var cardTipSection in articleCardTips.Sections)
            {
                var tipSection = new CardSection
                {
                    Name        = cardTipSection.Title,
                    ContentList = SectionHelper.GetSectionContentList(cardTipSection)
                };

                if (cardTipSection.Title.Equals("List", StringComparison.OrdinalIgnoreCase) ||
                    cardTipSection.Title.Equals("Lists", StringComparison.OrdinalIgnoreCase))
                {
                    tipSection.Name = tipSection.ContentList.First();
                    tipSection.ContentList.Clear();
                    _tipRelatedWebPage.GetTipRelatedCards(tipSection, article);
                }

                tipSections.Add(tipSection);
            }

            var cardSectionMessage = new CardSectionMessage {
                Name = article.Title, CardSections = tipSections
            };

            await _queues.Single(q => q.Handles(ArticleCategory.CardTips)).Publish(cardSectionMessage);

            return(response);
        }
Esempio n. 13
0
 public static void AddSectionToAllUsers()
 {
     SectionHelper.AddSectionToAllUsers(Name, Alias, Icon);
 }