Ejemplo n.º 1
0
        public async Task <IActionResult> Show(ShowCommentsViewModel model)
        {
            if (string.IsNullOrEmpty(model.Language))
            {
                return(Content("Language not specified."));
            }
            if (string.IsNullOrEmpty(model.SourcePlatform))
            {
                return(Content("SourcePlatform not specified."));
            }
            if (string.IsNullOrEmpty(model.Page))
            {
                return(Content("Page not specified."));
            }
            //Set default locale for UI
            CultureInfo.CurrentUICulture = new CultureInfo(model.Language);
            CultureInfo.CurrentCulture   = new CultureInfo(model.Language);

            var selectedPage = await _dbContext.Pages.SingleOrDefaultAsync(p => p.PublicIdentifier == model.Page && p.SourcePlatformId == model.SourcePlatform);

            if (selectedPage != null)
            {
                ViewBag.CommentsCount          = selectedPage.CommentsCount;
                ViewBag.AllowAnonymousComments = selectedPage.AllowAnonymousComments;
            }
            else
            {
                ViewBag.CommentsCount          = 0;
                ViewBag.AllowAnonymousComments = false;
            }
            var AuthorizedUserReq = new Requirements.AuthorizedUserRequirement();
            await _authorizationService.AuthorizeAsync(null, model, AuthorizedUserReq);

            ViewBag.IsGuest = AuthorizedUserReq.IsGuest;
            if (!ViewBag.IsGuest)
            {
                //It means we passed the auth, so ID & Token are valid
                ViewBag.AuthorId = model.Id;
            }
            ViewBag.SourcePlatformId = model.SourcePlatform;
            ViewBag.PublicIdentifier = model.Page;
            ViewBag.LangCode         = model.Language;
            ViewBag.IsForum          = model.IsForum;
            return(View(new PostCommentViewModel()
            {
                Id = model.Id,
                Token = model.Token,
                AuthenticatedMode = !ViewBag.IsGuest,
                SourcePlatform = model.SourcePlatform,
                PageIdentifier = model.Page,
            }));
        }
        public IActionResult ShowComments(string UserId)
        {
            ShowCommentsViewModel model = repository.GetCommentsAndDoctorData(UserId);

            return(View(model));
        }