public PartialViewResult GiveALike(int postID) { int currentPersonID = ActiveSession.GetPersonID(); Account.GiveALikeSL(postID, currentPersonID); return(PartialView("_InteractButtons", Account.GetInteractsCountSL(postID, currentPersonID))); }
public string ChangeAvatar() { if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any()) { var avatarFile = System.Web.HttpContext.Current.Request.Files["ImageFile"]; return(Account.ChangeAvatarSL(avatarFile, ActiveSession.GetPersonID())); } return(""); }
public ActionResult Search(SearchDTO model) { if (!ModelState.IsValid) { return(View(model)); } model.MatchesFound = home.FindMatchesSL(model.WordToSearch, ActiveSession.GetPersonID()); return(View(model)); }
public JsonResult EditDetailsForm(ProfileDetailsDTO model) { if (!ModelState.IsValid) { return(Json(new { message = "Fallaron las validaciones" })); } ProfileDetailsDTO newDetails = Account.ChangeProfileDetailsSL(model, ActiveSession.GetPersonID()); return(Json(new { personalDescription = newDetails.PersonalDescription, websiteURL = newDetails.WebSiteURL, birthDate = newDetails.Birthdate })); }
public ActionResult NewList(ListDTO model) { if (!ModelState.IsValid) { return(View(model)); } Account.NewListSL(model, ActiveSession.GetPersonID()); return(RedirectToAction("ProfileScreen", "Account", new { id = ActiveSession.GetPersonID(), v = "lists" })); }
public JsonResult FollowUser(int follow) { if (Account.FollowUserSL(ActiveSession.GetPersonID(), follow)) { return(Json(new { buttonText = "Dejar de seguir", className = "btn-danger" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { buttonText = "Seguir", className = "btn-success" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Timeline() { try { var model = Account.TimelineCollectionDataSL(ActiveSession.GetPersonID()); return(View(model)); } catch (Exception ex) { return(ProcessError(ex)); } }
public ActionResult NewPost(NewPostDTO model) { if (!ModelState.IsValid) { return(Content("Fallaron las validaciones.")); } if (Account.CreateNewPostSL(model, ActiveSession.GetPersonID(), Server)) { TempData["message"] = "El post se ha publicado."; return(RedirectToAction("Timeline", "Account")); } return(RedirectToAction("Index", "Home")); }
public ActionResult NewReply(NewPostDTO model) { if (!ModelState.IsValid) { return(Content("Fallaron las validaciones.")); } if (Account.CreateNewPostSL(model, ActiveSession.GetPersonID(), Server)) { var newModel = Account.ViewPostCollectionDataSL(Convert.ToInt32(model.InReplyTo)); return(PartialView("_RepliesToPost", newModel.RepliesToPost)); } return(RedirectToAction("Timeline", "Account")); }
public JsonResult ToggleTheme() { var darkMode = Account.ToggleThemeSL(ActiveSession.GetPersonID()); var session = (SessionInformation)Session["MiniBirdAccount"]; if (darkMode) { session.Theme = Domain_Layer.Enum.Theme.Dark; } else { session.Theme = Domain_Layer.Enum.Theme.Light; } Session["MiniBirdAccount"] = session; return(Json(new { darkMode = darkMode }, JsonRequestBehavior.AllowGet)); }
public ActionResult Search(string q) { try { var matchesFound = home.FindMatchesSL(q, ActiveSession.GetPersonID()); if (Request.IsAjaxRequest()) { return(PartialView("_Suggestions", matchesFound)); } else { SearchDTO model = new SearchDTO(); model.WordToSearch = q; model.MatchesFound = matchesFound; return(View(model)); } } catch (Exception ex) { return(ProcessError(ex)); } }
public ProfileScreenDTO ProfileScreenCollectionDataDL(int personID, string v) { try { using (var context = new MiniBirdEntities()) { Person person = context.Person.Find(personID); var follows = context.Follow; var profileScreenDTO = new ProfileScreenDTO(); profileScreenDTO.ProfileInformation.PersonID = person.PersonID; profileScreenDTO.ProfileInformation.UserName = person.UserName; profileScreenDTO.ProfileInformation.NickName = person.NickName; profileScreenDTO.ProfileInformation.PersonalDescription = person.PersonalDescription; profileScreenDTO.ProfileInformation.WebSiteURL = person.WebSiteURL; profileScreenDTO.ProfileInformation.Birthdate = (person.Birthdate.HasValue) ? BirthDatePhrase(person.Birthdate) : ""; profileScreenDTO.ProfileInformation.RegistrationDate = person.RegistrationDate; profileScreenDTO.ProfileInformation.ProfileAvatar = (person.ProfileAvatar != null) ? ByteArrayToBase64(person.ProfileAvatar, person.ProfileAvatar_MimeType) : defaultAvatar; profileScreenDTO.ProfileInformation.ProfileHeader = (person.ProfileHeader != null) ? ByteArrayToBase64(person.ProfileHeader, person.ProfileHeader_MimeType) : defaultHeader; profileScreenDTO.TopTrendings = TopTrendings(); profileScreenDTO.StatisticsBar.PostsCount = context.Post.Where(ps => ps.ID_Person == person.PersonID && ps.InReplyTo == null).Count(); profileScreenDTO.StatisticsBar.FollowingCount = GetFollowingCount(follows, person.PersonID); profileScreenDTO.StatisticsBar.FollowersCount = GetFollowersCount(follows, person.PersonID); profileScreenDTO.StatisticsBar.LikesCount = context.LikePost.Where(lp => lp.ID_PersonThatLikesPost == person.PersonID).Count(); profileScreenDTO.StatisticsBar.ListsCount = context.List.Where(ml => ml.ID_Person == person.PersonID).Count(); if (ActiveSession.GetPersonID() != person.PersonID) { Person activeUser = context.Person.Find(ActiveSession.GetPersonID()); profileScreenDTO.Following = follows.Any(f => f.ID_Person == activeUser.PersonID && f.ID_PersonFollowed == person.PersonID); } switch (v) { case "following": var myFollowings = follows.Where(f => f.ID_Person == person.PersonID); foreach (var following in myFollowings) { var personFollowed = context.Person.Find(following.ID_PersonFollowed); profileScreenDTO.Followings.Add(new FollowingDTO() { PersonID = personFollowed.PersonID, NickName = personFollowed.NickName, UserName = personFollowed.UserName, ProfileAvatar = (personFollowed.ProfileAvatar != null) ? ByteArrayToBase64(personFollowed.ProfileAvatar, personFollowed.ProfileAvatar_MimeType) : defaultAvatar, Description = personFollowed.PersonalDescription, FollowingCount = GetFollowingCount(follows, personFollowed.PersonID), FollowersCount = GetFollowersCount(follows, personFollowed.PersonID) }); } break; case "followers": var myFollowers = follows.Where(f => f.ID_PersonFollowed == person.PersonID); foreach (var follower in myFollowers) { var personThatFollowMe = context.Person.Find(follower.ID_Person); profileScreenDTO.Followers.Add(new FollowingDTO() { PersonID = personThatFollowMe.PersonID, NickName = personThatFollowMe.NickName, UserName = personThatFollowMe.UserName, ProfileAvatar = (personThatFollowMe.ProfileAvatar != null) ? ByteArrayToBase64(personThatFollowMe.ProfileAvatar, personThatFollowMe.ProfileAvatar_MimeType) : defaultAvatar, Description = personThatFollowMe.PersonalDescription, FollowingCount = follows.Where(f => f.ID_Person == personThatFollowMe.PersonID).Count(), FollowersCount = follows.Where(f => f.ID_PersonFollowed == personThatFollowMe.PersonID).Count(), Following = context.Follow.Any(f => f.ID_Person == person.PersonID && f.ID_PersonFollowed == personThatFollowMe.PersonID) }); } break; case "likes": var myLikes = context.LikePost.Where(lp => lp.ID_PersonThatLikesPost == person.PersonID).OrderByDescending(lp => lp.DateOfAction); foreach (var like in myLikes) { var postLiked = context.Post.Find(like.ID_Post); var createdBy = context.Person.Find(postLiked.ID_Person); profileScreenDTO.LikesSection.Add(new PostSectionDTO() { PostID = postLiked.PostID, Comment = postLiked.Comment, GIFImage = postLiked.GIFImage, VideoFile = postLiked.VideoFile, Thumbnails = GetPostedThumbnails(postLiked.PostID), PublicationDate = postLiked.PublicationDate, CreatedBy = createdBy.PersonID, NickName = createdBy.NickName, UserName = createdBy.UserName, ProfileAvatar = (createdBy.ProfileAvatar != null) ? ByteArrayToBase64(createdBy.ProfileAvatar, createdBy.ProfileAvatar_MimeType) : defaultAvatar, InteractButtons = GetInteractsCountDL(postLiked.PostID, person.PersonID) }); } break; case "lists": var myLists = context.List.Where(ml => ml.ID_Person == person.PersonID); foreach (var list in myLists) { profileScreenDTO.MyLists.Add(new ListDTO() { MyListID = list.ListID, Name = list.Name, Description = list.Description, Privacy = (list.IsPrivate != true) ? Privacy.Public : Privacy.Private, MembersCount = context.UserToList.Where(ul => ul.ID_List == list.ListID).Count() }); } break; default: var myPosts = context.Post.Where(mp => mp.ID_Person == personID && mp.InReplyTo == null).ToList(); var myReposts = context.RePost.Where(rp => rp.ID_PersonThatRePost == person.PersonID).ToList(); profileScreenDTO.PostsSection.AddRange(FillPostSection(myPosts, person.PersonID, myReposts)); profileScreenDTO.PostsSection = profileScreenDTO.PostsSection.OrderByDescending(ps => ps.PublicationDate).ToList(); break; } return(profileScreenDTO); } } catch { throw; } }
public ViewPostDTO ViewPostAjaxCollectionDataDL(int postID) { try { using (var context = new MiniBirdEntities()) { var post = context.Post.Find(postID); var createdBy = context.Person.Find(post.ID_Person); var ViewPost = new ViewPostDTO(); ViewPost.PostSection.PostID = post.PostID; ViewPost.PostSection.Comment = post.Comment; ViewPost.PostSection.GIFImage = post.GIFImage; ViewPost.PostSection.VideoFile = post.VideoFile; ViewPost.PostSection.Thumbnails = GetPostedThumbnails(post.PostID); ViewPost.PostSection.PublicationDate = post.PublicationDate; ViewPost.PostSection.CreatedBy = createdBy.PersonID; ViewPost.PostSection.NickName = createdBy.NickName; ViewPost.PostSection.UserName = createdBy.UserName; ViewPost.PostSection.ProfileAvatar = (createdBy.ProfileAvatar != null) ? ByteArrayToBase64(createdBy.ProfileAvatar, createdBy.ProfileAvatar_MimeType) : defaultAvatar; ViewPost.PostSection.InteractButtons = GetInteractsCountDL(post.PostID, ActiveSession.GetPersonID()); if (post.InReplyTo > 0) { var toProfile = context.Post.Find(post.InReplyTo).ID_Person; ViewPost.IsReply = true; ViewPost.ReplyData.ToProfile = toProfile; ViewPost.ReplyData.ToUsername = context.Person.Find(toProfile).UserName; ViewPost.ReplyData.ToPost = Convert.ToInt32(post.InReplyTo); } else { ViewPost.IsReply = false; } var replies = context.Post.Where(r => r.InReplyTo == postID).OrderByDescending(r => r.PublicationDate); foreach (var reply in replies) { var replyCreatedBy = context.Person.Find(reply.ID_Person); ViewPost.RepliesToPost.Add(new PostSectionDTO() { PostID = reply.PostID, Comment = reply.Comment, GIFImage = reply.GIFImage, VideoFile = reply.VideoFile, Thumbnails = GetPostedThumbnails(reply.PostID), PublicationDate = reply.PublicationDate, CreatedBy = replyCreatedBy.PersonID, NickName = replyCreatedBy.NickName, UserName = replyCreatedBy.UserName, ProfileAvatar = (replyCreatedBy.ProfileAvatar != null) ? ByteArrayToBase64(replyCreatedBy.ProfileAvatar, replyCreatedBy.ProfileAvatar_MimeType) : defaultAvatar, InteractButtons = GetInteractsCountDL(reply.PostID, ActiveSession.GetPersonID()) }); } return(ViewPost); } } catch { throw; } }
public ActionResult ListScreen(int id) { var model = Account.ListScreenCollectionDataSL(id, ActiveSession.GetPersonID()); return(View(model)); }
public HashtagDTO GetPostsUsingHashtagDL(string name) { try { using (var context = new MiniBirdEntities()) { IQueryable <Post> posts = context.Post.Where(p => p.Hashtag.Any(h => h.Name == name)); HashtagDTO hashtagDTO = new HashtagDTO(); hashtagDTO.Name = name; foreach (var post in posts) { var createdBy = context.Person.Find(post.ID_Person); hashtagDTO.PostSection.Add(new PostSectionDTO() { PostID = post.PostID, Comment = post.Comment, GIFImage = post.GIFImage, VideoFile = post.VideoFile, Thumbnails = new AccountDL().GetPostedThumbnails(post.PostID), PublicationDate = post.PublicationDate, CreatedBy = createdBy.PersonID, NickName = createdBy.NickName, UserName = createdBy.UserName, ProfileAvatar = (createdBy.ProfileAvatar != null) ? ByteArrayToBase64(createdBy.ProfileAvatar, createdBy.ProfileAvatar_MimeType) : "/Content/images/defaultAvatar.png", InteractButtons = new AccountDL().GetInteractsCountDL(post.PostID, ActiveSession.GetPersonID()), }); } return(hashtagDTO); } } catch { throw; } }
public ActionResult RemoveList(ListScreenDTO model) { Account.RemoveListSL(model.CurrentListSection.MyListID, ActiveSession.GetPersonID()); return(RedirectToAction("ProfileScreen", "Account", new { id = ActiveSession.GetPersonID(), v = "lists" })); }
public PartialViewResult EditDetailsForm() { var model = Account.ChangeProfileDetailsSL(ActiveSession.GetPersonID()); return(PartialView("_EditProfileDetails", model)); }
public PartialViewResult CheckboxLists(int currentProfileID) { ViewBag.currentProfileID = currentProfileID; return(PartialView("_CheckboxLists", Account.CheckboxListsSL(currentProfileID, ActiveSession.GetPersonID()))); }