////get_SamplesDB
        public List <sampleDetails> get_Sample_Details_DB()
        {
            List <sampleDetails> smpl_list = new List <sampleDetails>();
            SqlConnection        con       = null;

            try
            {
                con = connect("DBConnectionString");

                String     query = "SELECT * FROM [SampleDetails_2020]";
                SqlCommand cmd   = new SqlCommand(query, con);
                cmd.CommandTimeout = 480;                                              // enlarge T.O

                SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // the connection will close as reading completes

                while (dr.Read())
                {
                    sampleDetails smpl = new sampleDetails();

                    smpl.Batch_id    = Convert.ToInt32(dr["batch_id"]);
                    smpl.Date        = Convert.ToDateTime(dr["date"]);
                    smpl.Tank_temp   = (float)dr["Tank_temp"];
                    smpl.Sample_temp = (float)dr["Sample_Temp"];
                    smpl.Rate        = (float)dr["Rate"];
                    smpl.Gravity     = (float)dr["Gravity"];
                    smpl.Ph          = (float)dr["ph"];
                    smpl.Notes       = (string)dr["notes"];
                    smpl.Row_num     = Convert.ToInt32(dr["index"]);

                    smpl_list.Add(smpl);
                }

                return(smpl_list);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Beispiel #2
0
        [HttpPut]                                                       //
        public HttpResponseMessage Put([FromBody] sampleDetails sample) //
        {
            int numEffected = 0;

            try
            {
                numEffected = sample.Update();

                if (numEffected > 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, numEffected));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Found"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #3
0
        public HttpResponseMessage Delete([FromBody] string row_num) // row = row number in DB
        {
            int           numEffected = 0;
            sampleDetails smp         = new sampleDetails();

            try
            {
                numEffected = smp.delete_line(Convert.ToInt32(row_num));

                if (numEffected > 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, numEffected));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Found"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #4
0
 public int Post([FromBody] sampleDetails sample)
 {
     return(sample.insert());
 }
Beispiel #5
0
        public List <sampleDetails> Get()
        {
            sampleDetails sample = new sampleDetails();

            return(sample.get_Samples());
        }