public JsonResult Post(pr_request pr)
        {
            string        query         = @"select request_id from dbo.pr_request where  pr_name LIKE  '%" + pr.pr_name + "%' ";
            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("APIcon");
            SqlDataReader myReader;

            using (SqlConnection myCon = new SqlConnection(sqlDataSource))
            {
                myCon.Open();
                using (SqlCommand myCommand = new SqlCommand(query, myCon))
                {
                    myReader = myCommand.ExecuteReader();
                    table.Load(myReader);

                    myReader.Close();
                    myCon.Close();
                }
            }

            return(new JsonResult(table));
        }
Exemplo n.º 2
0
        public JsonResult Post(pr_request prq)
        {
            string        query         = @"insert into dbo.pr_request (ledger_id,requested_user,inserted_date,pr_name) values (  '" + prq.ledger_id + @"' , '" + prq.requested_user + @"' , '" + prq.inserted_date + @"' , '" + prq.pr_name + @"') ";
            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("APIcon");
            SqlDataReader myReader;

            using (SqlConnection myCon = new SqlConnection(sqlDataSource))
            {
                myCon.Open();
                using (SqlCommand myCommand = new SqlCommand(query, myCon))
                {
                    myReader = myCommand.ExecuteReader();
                    table.Load(myReader);

                    myReader.Close();
                    myCon.Close();
                }
            }

            return(new JsonResult("Added Successfully"));
        }