public static UserActivity From(TalkRating rating, Talk talk, User user) { return new UserActivity { TalkId = rating.TalkId, Time = DateTime.UtcNow, TalkAuthor = talk.Author, Content = string.Format("\"{0}\" was thumbed-up ({1}) at #tccc19 http://speakr.cc/#{2}", talk.Title, talk.Ranking > 0 ? "+" + talk.Ranking.ToString() : talk.Ranking.ToString(), talk.Id) }; }
public ActionResult Index() { // Cheap way to track a user. We did do full auth with Mozilla Persona, // but we pulled this code out and instead did simple session tracking. var sessionCookieName = "SpeakrSessionTccc19"; var sessionCookie = Request.Cookies[sessionCookieName]; if (sessionCookie == null || string.IsNullOrEmpty(sessionCookie.Value)) { var sessionId = Guid.NewGuid().ToString(); var cookie = new HttpCookie(sessionCookieName, sessionId); cookie.Expires = DateTime.Now.AddYears(3); Response.SetCookie(cookie); var user = new User { SessionId = sessionId }; using (var session = RavenInstance.Db.OpenSession()) { session.Store(user); session.SaveChanges(); } } return View(); }