Example #1
0
        public async Task <ActionResultResponse <PageDetailViewModel> > Detail(int id)
        {
            var pageDetailViewModel = new PageDetailViewModel();
            var pageInfo            = await _pageRepository.GetInfo(id, true);

            if (pageInfo == null)
            {
                return(new ActionResultResponse <PageDetailViewModel>(-1, _resourceService.GetString("Page not found.")));
            }

            pageDetailViewModel.Id              = pageInfo.Id;
            pageDetailViewModel.BgColor         = pageInfo.BgColor;
            pageDetailViewModel.ChildCount      = pageInfo.ChildCount;
            pageDetailViewModel.Icon            = pageInfo.Icon;
            pageDetailViewModel.IsActive        = pageInfo.IsActive;
            pageDetailViewModel.Order           = pageInfo.Order;
            pageDetailViewModel.ParentId        = pageInfo.ParentId;
            pageDetailViewModel.Url             = pageInfo.Url;
            pageDetailViewModel.PageTranslation = await _pageTranslationRepository.SearchByPageId(id);

            return(new ActionResultResponse <PageDetailViewModel>
            {
                Data = pageDetailViewModel
            });
        }
        public async Task <IActionResult> Detail(PageDetailViewModel model)
        {
            var language = await _languageService.GetActiveByIdAsync(model.SelectedLanguageId);

            var currentPage = await _pageService.GetByHeaderAndLanguageAsync(
                model.HeaderId, language.Id);

            if (ModelState.IsValid)
            {
                var page = model.Page;
                page.LanguageId   = language.Id;
                page.PageHeaderId = model.HeaderId;

                if (currentPage == null)
                {
                    await _pageService.AddPageAsync(page);

                    ShowAlertSuccess("Page content added!");
                }
                else
                {
                    await _pageService.EditPageAsync(page);

                    ShowAlertSuccess("Page content updated!");
                }

                return(RedirectToAction(nameof(Detail), new
                {
                    id = model.HeaderId,
                    language = language.Name
                }));
            }

            var header = await _pageService.GetHeaderByIdAsync(model.HeaderId);

            var languages = await _languageService.GetActiveAsync();

            model.HeaderName   = header.PageName;
            model.HeaderStub   = header.Stub;
            model.LanguageList = new SelectList(languages, "Name", "Description", language.Name);

            if (currentPage?.IsPublished == true)
            {
                var baseUrl = await _siteService.GetBaseUrl(Request.Scheme, Request.Host.Value);

                var action = Url.Action("Index", "Info", new
                {
                    area    = "",
                    culture = language.Name,
                    id      = header.Stub
                });

                model.PageUrl = baseUrl + action;
            }

            return(View(model));
        }
        public async Task <IActionResult> DeletePage(PageDetailViewModel model)
        {
            var page = await _pageService.GetByHeaderAndLanguageAsync(model.HeaderId,
                                                                      model.SelectedLanguageId);

            await _pageService.DeletePageAsync(page.Id);

            var language = await _languageService.GetActiveByIdAsync(model.SelectedLanguageId);

            ShowAlertSuccess($"{language.Description} page removed!");
            return(RedirectToAction(nameof(Detail),
                                    new
            {
                id = model.HeaderId,
                language = language.Name
            }));
        }
        public async Task <IActionResult> Detail(int id, string language)
        {
            var header = await _pageService.GetHeaderByIdAsync(id);

            var languages = await _languageService.GetActiveAsync();

            var selectedLanguage = languages
                                   .FirstOrDefault(_ => _.Name.Equals(language, StringComparison.OrdinalIgnoreCase))
                                   ?? languages.Single(_ => _.IsDefault);

            var page = await _pageService.GetByHeaderAndLanguageAsync(id, selectedLanguage.Id);

            var viewModel = new PageDetailViewModel
            {
                Page         = page,
                HeaderId     = header.Id,
                HeaderName   = header.PageName,
                HeaderStub   = header.Stub,
                NewPage      = page == null,
                LanguageList = new SelectList(languages, "Name", "Description",
                                              selectedLanguage.Name),
                SelectedLanguageId = selectedLanguage.Id
            };

            if (page?.IsPublished == true)
            {
                var baseUrl = await _siteService.GetBaseUrl(Request.Scheme, Request.Host.Value);

                var action = Url.Action("Index", "Info", new
                {
                    area    = "",
                    culture = selectedLanguage.Name,
                    id      = header.Stub
                });

                viewModel.PageUrl = baseUrl + action;
            }

            return(View(viewModel));
        }
Example #5
0
        public IActionResult PageDetail(string pageSlug)
        {
            if (pageSlug == null)
            {
                return(RedirectToAction("Error"));
            }

            var findPage = _pageService.GetWeb(pageSlug);

            if (findPage == null)
            {
                return(RedirectToAction("Error"));
            }

            PageDetailViewModel viewModel = new PageDetailViewModel
            {
                Name          = findPage.Name,
                EditorContent = findPage.EditorContent,
                Description   = findPage.Description,
                ImageUrl      = findPage.ImageUrl
            };

            return(View(viewModel));
        }
        public ActionResult Details(string pageParam)
        {
            if (pageParam == "طراحی-سایت-شرکتی")
            {
                return(RedirectPermanent("/page/طراحی-وب-سایت"));
            }

            MenuData menu = new MenuData();

            if (pageParam == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Page page = db.Pages.FirstOrDefault(current =>
                                                current.UrlParameter == pageParam && current.IsDelete == false && current.IsActive);

            if (page == null)
            {
                Portfolio portfolio = db.Portfolios.FirstOrDefault(current =>
                                                                   current.UrlParameter == pageParam && current.IsDelete == false);

                if (portfolio != null)
                {
                    return(RedirectToActionPermanent("Details", "Portfolios", new { @pageParam = pageParam }));
                }

                return(HttpNotFound());
            }


            PageDetailViewModel pageDetail = new PageDetailViewModel()
            {
                Title        = page.Title,
                Body         = page.Body,
                Date         = GetDateStr(page.LastModificationDate),
                ImageUrl     = page.ImageUrl,
                CommentCount = db.Comments.Count(current =>
                                                 current.PageId == page.Id && current.IsActive && current.IsDelete == false),
                SidebarPages = GetSidebarPages(page.Id, page.PageGroupId),
                Comments     = ReturnComments(page.Id),
                UrlParameter = page.UrlParameter,
                // Rate = ReturnRate(page),
                DateModified    = page.LastModificationDate.ToString(),
                Faqs            = GetPageFaq(page.Id),
                HasFaq          = page.HasFaq,
                FaqTitle        = page.FaqTitle,
                TitleTag        = GetTitleTag(page),
                SummeryInDetail = page.SummeryInDetail
            };

            ViewBag.id = page.Id;

            ViewBag.Description = page.MetaDescription;
            ViewBag.Canonical   = "https://zavoshsoftware.com/page/" + page.UrlParameter;

            ViewBag.rate        = ReturnRate(page);
            ViewBag.RatingCount = ReturnRatingCount(page.Id);

            ViewBag.image        = "https://zavoshsoftware.com" + page.ImageUrl;
            ViewBag.creationDate = page.CreationDate;


            if (page.PageGroup.ParentId == new Guid("30FA953C-403F-4796-B787-528238A48100"))
            {
                ViewBag.ListUrl   = "https://zavoshsoftware.com/page";
                ViewBag.ListTitle = "خدمات";
            }
            else
            {
                ViewBag.ListUrl   = "https://zavoshsoftware.com/blog";
                ViewBag.ListTitle = "مطالب وبلاگ";
            }
            return(View(pageDetail));
        }