public List <RaiseQuery> GetAllQueries()
        {
            List <RaiseQuery> rqList = new List <RaiseQuery>();

            using (SqlConnection con = new SqlConnection(Queries.connection))
            {
                con.Open();
                SqlCommand command = new SqlCommand()
                {
                    Connection  = con,
                    CommandType = CommandType.Text,
                    CommandText = Queries.getAllQueries
                };
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    RaiseQuery rq = new RaiseQuery();
                    rq.Id          = Convert.ToInt32(reader.GetValue(reader.GetOrdinal(Constants.id)));
                    rq.Query       = Convert.ToString(reader.GetValue(reader.GetOrdinal(Constants.query)));
                    rq.Description = Convert.ToString(reader.GetValue(reader.GetOrdinal(Constants.description)));
                    rq.Status      = Convert.ToString(reader.GetValue(reader.GetOrdinal(Constants.status)));
                    rq.Result      = Convert.ToString(reader.GetValue(reader.GetOrdinal(Constants.result)));
                    rqList.Add(rq);
                }
                reader.Close();
            }
            return(rqList);
        }
 protected void btnSubmitQuery_Click(object sender, EventArgs e)
 {
     try
     {
         string     query       = txtQuery.Text;
         string     description = txtDescription.Text;
         RaiseQuery raiseQuery  = new RaiseQuery();
         raiseQuery.Query       = query;
         raiseQuery.Description = description;
         raiseQuery.Status      = "In Progress";
         raiseQuery.Result      = "No Result";
         BloodBL bl     = new BloodBL();
         int     result = bl.RaiseQuery(raiseQuery, int.Parse(lblUserId.Text));
         if (result == 1)
         {
             Response.Write("<script>alert('Query Raised Successfully');window.location.href='FAQ.aspx';</script>");
         }
         else
         {
             Response.Write("<script>alert('Error in raising query');window.location.href='FAQ.aspx';</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('" + ex.Message + "');</script>");
     }
 }
        public void TestRaiseQuery()
        {
            BloodBL    bl = new BloodBL();
            RaiseQuery rq = new RaiseQuery();

            rq.Query       = "Donate Blood";
            rq.Description = "Unable to Donate Blood";
            rq.Status      = "In Progress";
            Assert.AreEqual(1, bl.RaiseQuery(rq, 8));
        }
        public int RaiseQuery(RaiseQuery rq, int userId)
        {
            int result = 0;

            using (SqlConnection con = new SqlConnection(Queries.connection))
            {
                con.Open();
                SqlCommand command = new SqlCommand()
                {
                    Connection  = con,
                    CommandType = CommandType.Text,
                    CommandText = Queries.raiseQuery
                };
                command.Parameters.Add(Constants.paramQuery, SqlDbType.VarChar).Value       = rq.Query;
                command.Parameters.Add(Constants.paramDescription, SqlDbType.VarChar).Value = rq.Description;
                command.Parameters.Add(Constants.paramStatus, SqlDbType.VarChar).Value      = rq.Status;
                command.Parameters.Add(Constants.paramUserId, SqlDbType.Int).Value          = userId;
                command.Parameters.Add(Constants.paramResult, SqlDbType.VarChar).Value      = rq.Result;

                result = command.ExecuteNonQuery();
            }
            return(result);
        }