/// <summary> /// Adds a new comment to the article specifed with given id /// </summary> /// <param name="id">comment id</param> /// <param name="form">form containing data</param> /// <param name="ip">Client IP address</param> /// <returns></returns> public bool add(long id, Form_Comment_New form, string ip) { comment c = new comment(); c.useralias = form["name"].getValue(); c.title = form["title"].getValue(); c.text = form["text"].getValue(); c.parentid = null; c.ip = ip; c.email = form["email"].getValue(); c.articlesid = id; if (this._app.users().isLogged()) { c.usersid = this._app.users().getLogged().id; } try { using (LangDataContext a = new LangDataContext()) { a.comments.InsertOnSubmit(c); a.SubmitChanges(); } } catch { return false; } return true; }
partial void Deletecomment(comment instance);
partial void Updatecomment(comment instance);
partial void Insertcomment(comment instance);
private void detach_comments(comment entity) { this.SendPropertyChanging(); entity.comment1 = null; }
private void attach_comments(comment entity) { this.SendPropertyChanging(); entity.comment1 = this; }
/// <summary> /// Saves a reply to a comment with the given id /// </summary> /// <param name="id">Comment id</param> /// <param name="form">Reply data</param> /// <param name="aid">Article id</param> /// <param name="ip">Client IP address</param> /// <returns></returns> public bool reply(long id, Form_Comment_New form, string ip, out long aid) { comment c = new comment(); c.useralias = form["name"].getValue(); c.title = form["title"].getValue(); c.text = form["text"].getValue(); c.parentid = id; c.ip = ip; c.email = form["email"].getValue(); if (this._app.users().isLogged()) { c.usersid = this._app.users().getLogged().id; } try { using (LangDataContext a = new LangDataContext()) { comment replied = a.comments.Where(x => x.id == id).Single(); aid = c.articlesid = replied.articlesid; a.comments.InsertOnSubmit(c); a.SubmitChanges(); } } catch { aid = 0; return false; } return true; }