public ContentDetailViewModel GetContentDetail(ContentDetailRequestModel requestModel) { IQueryable <Content> contents = _contentRepository.Get(); Content content = requestModel.GetFirstData(contents); ContentDetailViewModel model = new ContentDetailViewModel(content); var filtered = contents.Where(x => x.LevelId == content.LevelId); model.PreviousContentId = contents.FirstOrDefault(x => x.No == model.No - 1)?.Id; model.NextContentId = filtered.FirstOrDefault(x => x.No == model.No + 1)?.Id; return(model); }
public virtual ActionResult Blog(String id) { if (!IsModulActive(ContentType)) { return(HttpNotFound("Not Found")); } ContentDetailViewModel resultModel = ContentService2.GetContentDetail(id, ContentType); return(View(resultModel)); }
public ActionResult GetRelatedContents(int categoryId, String contentType) { var returnModel = new ContentDetailViewModel(); returnModel.SStore = MyStore; returnModel.SCategory = CategoryService.GetCategory(categoryId); returnModel.SRelatedContents = ContentService.GetContentByTypeAndCategoryId(MyStore.Id, contentType, categoryId, "", true).Take(5).ToList(); String partialViewName = @"pContents\pRelatedContents"; var html = this.RenderPartialToString(partialViewName, new ViewDataDictionary(returnModel)); return(Json(html, JsonRequestBehavior.AllowGet)); }
public ContentDetailViewModel GetDetail(Guid contentId, Guid traineeId) { var history = Db.TraineeHistories.FirstOrDefault(x => x.TraineeId == traineeId && x.ContentId == contentId); if (history != null) { Content content = Db.Contents.Find(contentId); ContentDetailViewModel detailViewModel = new ContentDetailViewModel(content); return(detailViewModel); } return(null); }
public async Task <IActionResult> ContentDetail(int cid) { var c = await _contentRepository.SingleOrDefault(co => co.Id == cid && co.IsEnable); if (c == null) { return(BadRequest("不存在此内容")); } await _contentRepository.LoadFilesAsync(c); var model = new ContentDetailViewModel(c); return(View("~/Views/Shared/_OnlyContent.cshtml", model)); }
public async Task <ContentDetailViewModel> GetContentDetail(Guid contentId, Guid traineeId) { var history = await Db.TraineeHistories.FirstOrDefaultAsync(x => x.TraineeId == traineeId && x.ContentId == contentId); if (history != null) { Content content = await Db.Contents.FindAsync(contentId); ContentDetailViewModel detailViewModel = new ContentDetailViewModel(content); return(detailViewModel); } return(null); }
public async Task <ResponseModel> Get(Guid id) { ResponseModel response; try { IContentService service = new ContentService(Db); ContentDetailViewModel data = await service.GetContentDetail(id, UserModel.Id); response = data != null ? new ResponseModel(data) : new ResponseModel(null, false, MessageContainer.NotYetUnlocked); } catch (Exception exception) { response = new ResponseModel(isSuccess: false, message: "Error occurrred", exception: exception); } return(response); }
public ContentDetailViewModel GetContentDetail(string id, string contentType) { var resultModel = new ContentDetailViewModel(); int newsId = id.Split("-".ToCharArray()).Last().ToInt(); resultModel.SContent = ContentRepository.GetContentsContentId(newsId); if (!CheckRequest(resultModel.SContent)) { throw new Exception("Not Found.Site content is wrong"); } resultModel.Type = contentType; resultModel.SStore = MyStore; resultModel.SCategory = CategoryRepository.GetCategory(resultModel.Content.CategoryId); resultModel.SCategories = CategoryRepository.GetCategoriesByStoreId(MyStore.Id, contentType); resultModel.SNavigations = NavigationRepository.GetStoreActiveNavigations(this.MyStore.Id); resultModel.SSettings = this.GetStoreSettings(); return(resultModel); }
private async Task <ContentDetailViewModel> MakeDetailViewModelAsync(uint contentId, int locpage, int prePageCount = 6, bool useJs = false, CommentSendModel sendModel = null) { var content = await _contentRepository.GetContentAsync(contentId); await _contentRepository.LoadFilesAsync(content); if (content == null) { return(null); } bool like = false; var user = await _userManager.GetUserAsync(User); if (User != null) { like = await _contentRepository.IsLikeContentAsync(user, contentId); } var comms = await _contentRepository.GetContentCommentsAsync(content.Id, prePageCount, locpage *prePageCount); foreach (var item in comms.Datas) { item.UserName = await _dbContext.Users.Where(u => u.Id == item.EaUserId).Select(u => u.UserName).FirstOrDefaultAsync(); } await _contentRepository.LoadFilesAsync(content); var retModel = new ContentDetailViewModel(content) { Sender = user, Comments = comms.Datas, IsLike = like, SendModel = sendModel ?? new CommentSendModel() { ContentId = contentId }, LocPage = locpage, UseJs = useJs, TotalCount = comms.Total }; return(retModel); }
public ContentDetailPage(ContentDetailViewModel viewModel) { InitializeComponent(); BindingContext = this.viewModel = viewModel; }