Esempio n. 1
0
 /*
  * It returns a comment given a code. If the code
  * does not exist an empty comment will be returned.
  */
 public CommentBE getComment()
 {
     CommentBE comment = new CommentBE();
     //TODO
     return comment;
 }
Esempio n. 2
0
 /*
  * Update, in general, a comment.
  */
 public void update(CommentBE comment)
 {
     //TODO
 }
Esempio n. 3
0
 /*
  * Delete the given comment.
  */
 public void deleteComment(CommentBE comment)
 {
     //TODO
 }
Esempio n. 4
0
        // /////////////////////////////////////////////////////////////////////
        // Methods /////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Comment Insertion.
        /// Inserts the given comment in the database.
        /// </summary>
        /// <param name="comment">The comment to be inserted.</param>
        /// <returns>A string which contains an error/success message.</returns> */
        public string insertComment(CommentBE comment)
        {
            String result = "The comment has been successfully added!";
            SqlConnection c = new SqlConnection(connection);
            try
            {
                c.Open();

                SqlParameter project = new SqlParameter();
                project.ParameterName = "@project";
                project.Value = comment.Project.Code;
                SqlParameter usr = new SqlParameter();
                usr.ParameterName = "@usr";
                usr.Value = comment.Writer.Email;
                SqlParameter date = new SqlParameter();
                date.ParameterName = "@date";
                date.Value = comment.Date.ToString("G");
                SqlParameter content = new SqlParameter();
                content.ParameterName = "@comment";
                content.Value = comment.Content;

                SqlCommand com = new SqlCommand("Insert into comments (project, usr, date, comment)" +
                    "values (@project, @usr, @date, @comment)", c);

                com.Parameters.Add(project);
                com.Parameters.Add(usr);
                com.Parameters.Add(date);
                com.Parameters.Add(content);

                com.ExecuteNonQuery();
            }
            catch (SqlException e)
            {
                //TODO

            }
            catch (Exception e)
            {
                // Show message box
            }
            finally
            {
                c.Close();
            }

            return result;
        }
Esempio n. 5
0
        /*
         * Update, in general, a comment.
         */
        public void update (CommentBE comment) {

        }
Esempio n. 6
0
    	/*
    	 * It returns a comment given a code. If the code
    	 * does not exist an empty comment will be returned.
    	 */
    	public CommentBE getComment (string code) {
    		CommentBE comment = new CommentBE();

    		return comment;
    	}
Esempio n. 7
0
    	/*
    	 * Creation in the DB of a comment.
    	 */
    	public string createComment (CommentBE comment) {
    		string code="";

    		return code;
    	}
        protected void uploadComment(object sender, EventArgs e)
        {
            //Get the query string parameters.
            string projectTitle = Session["ProjectTitle"].ToString();
            int projectCode = Int32.Parse(Session["ProjectCode"].ToString());

            //Create a project and look for the one we are being asked.
            ProjectBE project = new ProjectBE();
            project.Code = projectCode;
            project = project.getByCode();

            //If we get something different from the database, or nothing: error.
            //They could have change since we opened the page.
            if (project.Code != projectCode || project.Title != projectTitle)
                Response.Redirect("Error.aspx");

            //We need this so we get the nickname and we do not show the user's email to the public.
            UserBE writer = new UserBE();
            writer.Email = Session["UserEmail"].ToString();
            writer = writer.getUserByEmail();

            //Now we get the dateTime
            DateTime creationDate = DateTime.Now;

            //And the message content.
            String message = commentProjectText.Text;

            //Comment creation
            CommentBE crComment = new CommentBE(writer, project, creationDate, message);

            crComment.create();

            //Reload the page with the added comment.
            Response.Redirect(Request.RawUrl);
        }