public ActionResult Like(string id) { var userId = User.Identity.GetUserId(); var logedinProfile = db.UserProfiles.Find(userId); var profileLinker = new ProfileLinker { ID = db.ProfileLinkers.Count(), Liked = true, Favorited = false, LinkedProfile = userId, UserLinkedId = id }; db.ProfileLinkers.Add(profileLinker); db.SaveChanges(); var RedirectUrl = UserProfile.NextProfile(id, db, HttpContext); return(Redirect(RedirectUrl)); }
public ActionResult Favorite(string id) { var userId = User.Identity.GetUserId(); var logedinProfile = db.UserProfiles.Find(userId); var profileLinker = new ProfileLinker { ID = db.ProfileLinkers.Count(), Liked = true, Favorited = true, LinkedProfile = userId, UserLinkedId = id }; db.ProfileLinkers.Add(profileLinker); db.SaveChanges(); var linkedUser = db.UserProfiles.Find(id); var relativeUrl = Url.Action("Details", "UserProfiles", new { id = id }); var builder = new UriBuilder(Request.Url.AbsoluteUri) { Path = relativeUrl }; var absoluteUrl = builder.Uri.ToString(); string body = $"<div>Congratulations, {linkedUser.FirstName}</div>" + $"<div> {logedinProfile.FirstName} has favorited you!</div>" + $"<div><a href = \"{absoluteUrl}\">Click here to see their profile!</a></div>"; MessageSender.SendEmail(linkedUser.EmailAddress, "You've been favorited!", body, MessageSender.BodyType.Html); var RedirectUrl = UserProfile.NextProfile(id, db, HttpContext); return(Redirect(RedirectUrl)); }