Пример #1
0
        /// <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;
        }
Пример #2
0
 partial void Deletecomment(comment instance);
Пример #3
0
 partial void Updatecomment(comment instance);
Пример #4
0
 partial void Insertcomment(comment instance);
Пример #5
0
		private void detach_comments(comment entity)
		{
			this.SendPropertyChanging();
			entity.comment1 = null;
		}
Пример #6
0
		private void attach_comments(comment entity)
		{
			this.SendPropertyChanging();
			entity.comment1 = this;
		}
Пример #7
0
        /// <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;
        }