public async Task <IKnowledgeHubResponse> GetDetalis(int id, LanguageType language = LanguageType.AR)
        {
            try
            {
                KnowledgeHub knowledgeHub = await _appDbContext.KnowledgeHubs.FirstOrDefaultAsync(g => g.Id == id);

                var knowledgeHubView = new KnowledgeHubView()
                {
                    ID = knowledgeHub.Id,
                    KnowledgeHubTitle = language == LanguageType.EN? knowledgeHub.ArticleTitleEn: knowledgeHub.ArticleTitleAr,
                    ArticleTitleAr    = knowledgeHub.ArticleTitleAr,
                    AuthorTitleAr     = knowledgeHub.AuthorTitleAr,
                    ArticleTitleEn    = knowledgeHub.ArticleTitleEn,
                    AuthorTitleEn     = knowledgeHub.AuthorTitleEn,
                    ArticleTitle      = language == LanguageType.EN? knowledgeHub.ArticleTitleEn: knowledgeHub.ArticleTitleAr,
                    AuthorTitle       = language == LanguageType.EN? knowledgeHub.AuthorTitleEn: knowledgeHub.AuthorTitleAr,
                    ImageID           = knowledgeHub.ImageId,
                    HTMLContent       = language == LanguageType.EN ? knowledgeHub.HtmlcontentEn: knowledgeHub.HtmlcontentAr
                };
                if (knowledgeHub.ImageId.HasValue)
                {
                    knowledgeHubView.Image = _fileService.GetFile(knowledgeHub.ImageId.Value, false);
                }
                return(new KnowledgeHubResponse(knowledgeHubView));
            }
            catch (Exception e)
            {
                return(new KnowledgeHubResponse(e));
            }
        }
Exemple #2
0
 private KnowledgeHubResponse(bool success, string message, KnowledgeHubView view) : base(success, message)
 {
     KnowledgeHub = view;
 }
Exemple #3
0
 public KnowledgeHubResponse(KnowledgeHubView view) : this(true, string.Empty, view)
 {
 }