/// <summary> /// Show the view that allows adding new opinions. /// </summary> /// <param name="reason"></param> /// <returns></returns> public IActionResult Contribute(string reason = null) { // async Task<IActionResult> var model = new HomePageDto(); // We do not need trending today on contribute page // model.TopToday.Answers = await _answerService.FindAnswersTrendingToday(); model.Reason = reason; // Check if we need to debug react model.DebugReactControls = ReadUrlParameterAsBoolean(DEBUG_REACTJS_URL_PARAMETER_NAME); return(View(model)); }
public async Task <IActionResult> Index() { var clients = await _client.GetAllClientele(); var infos = await _catInfo.GetAllCategories(true); var tabs = await _catTab.GetAllCategories(); var model = new HomePageDto { Clienteles = clients, InfoCategories = infos, TabCategories = tabs }; return(View(model)); }
public IActionResult Index() { var result = _sliderService.GetAll(); if (result.Success) { var result2 = _pageService.GetByType(1); if (result2.Success) { HomePageDto homePageDto = new HomePageDto { Sliders = result.Data.Where(x => x.IsActive == true).ToList(), Pages = result2.Data.Where(x => x.IsActive == true).ToList() }; return(View(homePageDto)); } } return(View()); }
public IActionResult Index() { ViewData["LayoutData"] = userData.GetLayoutData(HttpContext); int userId = userData.GetUser(HttpContext).Id; User userFullData = facebookDataContext.Users.Where(x => x.Id == userId) .Include("UserRelationsDesider.Initiator.UsersPosts.Post.Comments.User.ProfilePhotos") .Include("UserRelationsDesider.Initiator.UsersPosts.Post.Likes.User.ProfilePhotos") .Include("UserRelationsDesider.Initiator.UsersPosts.Post.PostPhotos") .Include("UserRelationsInitiator.Desider.UsersPosts.Post.Comments.User.ProfilePhotos") .Include("UserRelationsInitiator.Desider.UsersPosts.Post.Likes.User.ProfilePhotos") .Include("UserRelationsInitiator.Desider.UsersPosts.Post.PostPhotos") .Include("UsersPosts.Post.Comments.User.ProfilePhotos") .Include("UsersPosts.Post.Likes.User.ProfilePhotos") .Include("UsersPosts.Post.PostPhotos") .Include("ProfilePhotos") .FirstOrDefault(); HomePageDto homePageDto = HomePageDtoMapper.Map(userFullData, hostingEnvironment); return(View(homePageDto)); }
/// <summary> /// Default home page view. /// </summary> /// <returns></returns> // GET: /<controller>/ public IActionResult Index(string reason = null, string searchPhrase = null) { var model = new HomePageDto(); // Use the search service if search phrase is passed if (!string.IsNullOrEmpty(searchPhrase) && !string.IsNullOrWhiteSpace(searchPhrase)) { // store the phrase that user typed. _searchEntryService.AddSearchEntry(new SearchEntryDto { SearchPhrase = searchPhrase, UserId = GetUserId(User, _userService) }); model.TopToday.Answers = _answerService.FindLastAnswers(searchPhrase).ToList(); model.Keyword = searchPhrase; model.HeaderText = string.Format(_resourcesService.GetString(this.Culture, Lines.SEARCH_RESULTS_FOR), searchPhrase); model.IsSearch = true; } else { model.TopToday.Answers = _answerService.FindAnswersTrendingToday().ToList(); model.HeaderText = _resourcesService.GetString(this.Culture, Lines.TRENDING_TODAY); } // Answer service does not do any stiching. Meaning it can not set user information in the model/answers. // Need to add user info to answers Stitcher <AnswerDto> .Stitch(model.TopToday.Answers, _userService); model.Reason = reason; // Check if we need to debug react model.DebugReactControls = ReadUrlParameterAsBoolean(DEBUG_REACTJS_URL_PARAMETER_NAME); return(View(model)); }
public static HomePageDto Map(User from, IWebHostEnvironment hostingEnvironment) { if (from == null) { return(null); } List <HomeUserTempDto> homeUserDtos = Map(from.UserRelationsInitiator.Where(x => x.Desider.IsDeleted == false), from.UserRelationsDesider.Where(x => x.Initiator.IsDeleted == false), hostingEnvironment, from.Id).ToList(); var to = new HomePageDto { FullName = $"{from.FirstName} {from.LastName}", Bio = from.Bio, UserId = from.Id, NumberOfFriends = from.UserRelationsDesider.Where(x => x.SocialStatusId == (int)SocialStatuses.Friend && x.Initiator.IsDeleted == false).Count() + from.UserRelationsInitiator.Where(x => x.SocialStatusId == (int)SocialStatuses.Friend && x.Desider.IsDeleted == false).Count(), HomeUserDtos = homeUserDtos.Select(x => new HomeUserDto(x.FullName, x.ProfilePicUrl, x.Bio, x.UserId)).ToList(), HomePostDto = GetAllPosts(homeUserDtos, from.UsersPosts, hostingEnvironment, from.Id).Select(x => new HomePostDto(x.FullName, x.ProfilePic, x.PostDate, x.PostContent, x.HomeCommentDto, x.HomeLikeDto, x.PostPicUrl, x.PostId, x.CanEditDelete, x.IsLike, x.UserId)).ToList(), }; string defaultPic = ""; if (from.GenderId == 1 /* Male */) { defaultPic = "default.jpg"; } else { defaultPic = "default_female.png"; } string path = hostingEnvironment.WebRootPath + "/ProfilePics/" + (from.ProfilePhotos.Where(x => x.IsCurrent).Select(x => x.Url).FirstOrDefault() ?? defaultPic); byte[] b = System.IO.File.ReadAllBytes(path); to.ProfilePicUrl = "data:image/png;base64," + Convert.ToBase64String(b); return(to); }