Exemplo n.º 1
0
        public List <ShippingCertificates> getSCertificates()
        {
            List <ShippingCertificates> SCL = new List <ShippingCertificates>();
            SqlConnection con = null;

            try
            {
                con = Connect("DBConnectionString"); // create a connection to the database using the connection String defined in the web config file

                String     selectSTR = "SELECT * FROM GLN_ShippingCertificate";
                SqlCommand cmd       = new SqlCommand(selectSTR, con);

                // get a reader
                SqlDataReader dr = cmd.ExecuteReader();//(CommandBehavior.CloseConnection); // CommandBehavior.CloseConnection: the connection will be closed after reading has reached the end

                while (dr.Read())
                {   // Read till the end of the data into a row
                    ShippingCertificates a = new ShippingCertificates();

                    a.ShippingCertificate = Convert.ToInt32(dr["ShippingCertificate"]);
                    a.DateReceive         = (string)(dr["DateReceive"]);
                    SCL.Add(a);
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
            return(SCL);
        }
Exemplo n.º 2
0
        // GET api/<controller>
        public List <ShippingCertificates> Get()
        {
            ShippingCertificates SC = new ShippingCertificates();

            return(SC.getSCertificates());
        }