Exemple #1
0
        //--------------------------------------------------------------------
        // Build the Insert command String
        //--------------------------------------------------------------------
        private String BuildInsertCommand(AdsFeedback mngcom)
        {
            String command;

            command = "update feedbackstudenttoads_P3 set managercomment ='" + mngcom.Managercomment + "' where feedbackstudenttoads_P3.fbAdsNum=" + mngcom.FbAdsNum;

            return(command);
        }
        public HttpResponseMessage Insertcomment([FromBody] AdsFeedback addmngcom)
        {
            try
            {
                addmngcom.Insertcomment();

                return(Request.CreateResponse(HttpStatusCode.OK, "Comment added successfully"));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #3
0
        public List <AdsFeedback> GetFBad(int adCode)
        {
            SqlConnection      con    = null;
            List <AdsFeedback> FBList = new List <AdsFeedback>();

            try
            {
                con = connect1("DBConnectionString");
                String        selectSTR = "select * from feedbackstudenttoads_P3 inner join student_P on student_P.mail=feedbackstudenttoads_P3.studentmail  where feedbackstudenttoads_P3.adCode=" + adCode;
                SqlCommand    cmd       = new SqlCommand(selectSTR, con);
                SqlDataReader dr        = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                while (dr.Read())
                {   // Read till the end of the data into a row
                    AdsFeedback FB = new AdsFeedback();
                    FB.FbAdsNum       = Convert.ToInt16(dr["fbAdsNum"]);
                    FB.Student        = (new Student {
                        Fname = (string)dr["firstName"]
                    });
                    FB.Student.Mail   = (string)dr["mail"];
                    FB.CommentText    = (string)dr["commenttext"];
                    FB.CommentDate    = Convert.ToDateTime(dr["commentdate"]);
                    FB.Managercomment = Convert.ToString(dr["managercomment"]);


                    FBList.Add(FB);
                }
                return(FBList);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemple #4
0
        public int Insertcomment(AdsFeedback mngcom)
        {
            SqlConnection con;
            SqlCommand    cmd;

            try
            {
                con = connect1("DBConnectionString"); // create the connection
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }

            String cStr = BuildInsertCommand(mngcom);    // helper method to build the insert string

            cmd = CreateCommand1(cStr, con);             // create the command

            try
            {
                int numEffected = cmd.ExecuteNonQuery(); // execute the command
                return(numEffected);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }

            finally
            {
                if (con != null)
                {
                    // close the db connection
                    con.Close();
                }
            }
        }