Exemplo n.º 1
0
        public JsonResult Put(Parku prk)
        {
            string        query         = @"
                    update Parku set 
                    EmriParkut = '" + prk.EmriParkut + @"'
                    EmriLokacionit = '" + prk.EmriLokacionit + @"'
                    where ParkuId = " + prk.ParkuId + @" 
                    ";
            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("LlojetEVendeveTuristikeAppCon");
            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("Updated Successfully"));
        }
Exemplo n.º 2
0
        public JsonResult Post(Parku prk)
        {
            string        query         = @"
                    insert into Parku values 
                    ('" + prk.EmriParkut + @"',
                     '" + prk.EmriLokacionit + @"')
                    ";
            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("LlojetEVendeveTuristikeAppCon");
            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"));
        }