protected void ButtonSubmit_Click(object sender, EventArgs e) { AspLinqDataContext dc = new AspLinqDataContext(); Forum forum = GetForum(int.Parse(HiddenFieldForumId.Value)); // insert topic Topic newTopic = new Topic(); newTopic.Title = TextBoxTitle.Text; newTopic.ForumId = forum.Id; newTopic.IsLocked = CheckBoxLock.Checked; newTopic.IsPinned = CheckBoxPin.Checked; dc.Topics.InsertOnSubmit(newTopic); dc.SubmitChanges(); // insert post Post newPost = new Post(); newPost.TopicId = newTopic.Id; newPost.MemberId = (Session["member"] as Member).Id; newPost.Content = TextBoxContent.Text; newPost.CreatedDate = DateTime.Now; newPost.FromIP = Request.UserHostAddress; dc.Posts.InsertOnSubmit(newPost); dc.SubmitChanges(); Response.Redirect("~/ViewTopic.aspx?id=" + newTopic.Id); }
protected Topic GetTopic(int id) { AspLinqDataContext dc = new AspLinqDataContext(); return((from Topic in dc.Topics where Topic.Id == id select Topic).SingleOrDefault()); }
public BLTopic() { dc = new AspLinqDataContext(); }
public BLMember() { dc = new AspLinqDataContext(); }
protected Member GetMemberById(int id) { AspLinqDataContext dc = new AspLinqDataContext(); return((from Member in dc.Members where Member.Id == id select Member).SingleOrDefault()); }
protected Forum GetForum(int id) { AspLinqDataContext dc = new AspLinqDataContext(); return((from Forum in dc.Forums where Forum.Id == id select Forum).Single()); }
public BLPost() { dc = new AspLinqDataContext(); }
public List <Forum> GetParentForums() { AspLinqDataContext dc = new AspLinqDataContext(); return((from Forum in dc.Forums where Forum.ParentForumId == null select Forum).ToList()); }
public BLForum() { dc = new AspLinqDataContext(); }