public ActionResult Index(DiscussionData data) { Compression.SetCompression(); var code = Model.GetCode(data.Guid, true); if (code == null) { throw new HttpException(404, "not found"); } if (!string.IsNullOrEmpty(data.NewComment)) { if (!SessionManager.IsUserInSession()) { return(this.Redirect(Utils.Utils.BaseUrl + @"login")); } Model.SaveComment(new Comment() { User_Id = (int)SessionManager.UserId, Text = data.NewComment, Code_Id = code.ID }); return(this.Redirect(Utils.Utils.BaseUrl + @"discussion/" + code.Guid + "#comment_" + Model.Comment_Last_Id(code.ID))); } if (!code.IsOnAWall) { data.Title = "Discussion not available"; } else { data.Title = code.Title; } data.Related = Model.GeRelated(code.ID); data.Votes = code.Votes; data.VoteUp = code.Voted; data.ShowComments = code.IsOnAWall; data.Code = code.Program; data.Date = code.Date; data.Language = code.Lang; data.Comments = Model.GetComments(data.Guid); var md = new MarkdownDeep.Markdown(); md.ExtraMode = true; md.SafeMode = true; foreach (var c in data.Comments) { c.Text = md.Transform(c.Text); } return(View(data)); }
public ActionResult Index(DiscussionData data) { Compression.SetCompression(); var code = Model.GetCode(data.Guid, true); if (code == null) { throw new HttpException(404, "not found"); } if (!string.IsNullOrEmpty(data.NewComment)) { if (!SessionManager.IsUserInSession()) { return this.Redirect(Utils.Utils.BaseUrl + @"login"); } Model.SaveComment(new Comment() { User_Id = (int)SessionManager.UserId, Text = data.NewComment, Code_Id = code.ID }); return this.Redirect(Utils.Utils.BaseUrl + @"discussion/" + code.Guid + "#comment_" + Model.Comment_Last_Id(code.ID)); } if (!code.IsOnAWall) data.Title = "Discussion not available"; else data.Title = code.Title; data.Related = Model.GeRelated(code.ID); data.Votes = code.Votes; data.VoteUp = code.Voted; data.ShowComments = code.IsOnAWall; data.Code = code.Program; data.Date = code.Date; data.Language = code.Lang; data.UserId = code.UserId; data.Comments = Model.GetComments(data.Guid); var md = new MarkdownDeep.Markdown(); md.ExtraMode = true; md.SafeMode = true; foreach (var c in data.Comments) { c.Text = md.Transform(c.Text); } return View(data); }
public string CancelVote(DiscussionData data) { Compression.SetCompression(); JavaScriptSerializer json = new JavaScriptSerializer(); if (!SessionManager.IsUserInSession()) { return json.Serialize(new VoteData() { NotLoggedIn = true }); } if (!Model.CancelVote(data.Guid)) { return json.Serialize(new VoteData() { AlreadyVoted = true }); } return json.Serialize(new VoteData()); }
public string CancelVote(DiscussionData data) { Compression.SetCompression(); JavaScriptSerializer json = new JavaScriptSerializer(); if (!SessionManager.IsUserInSession()) { return(json.Serialize(new VoteData() { NotLoggedIn = true })); } if (!Model.CancelVote(data.Guid)) { return(json.Serialize(new VoteData() { AlreadyVoted = true })); } return(json.Serialize(new VoteData())); }