Пример #1
0
        public JsonResult Put(Invertari inv)
        {
            string query = @" 
                            update dbo.Invertari set 
                    Emri = '" + inv.Emri + @"'
                    ,Kodi = '" + inv.Kodi + @"'
                    ,Sasia = '" + inv.Sasia + @"'
                    ,Pershkrimi = '" + inv.Pershkrimi + @"'

                    where invertariId = " + inv.invertariId + @" 
                             ";

            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("RestaurantAppCon");
            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"));
        }
Пример #2
0
        public JsonResult Post(Invertari inv)
        {
            string query = @" 
                            insert into dbo.Invertari values
                            ('" + inv.Emri + @"',
                            '" + inv.Kodi + @"',
                            '" + inv.Sasia + @"',
                            '" + inv.Pershkrimi + @"'
                 
                             )";

            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("RestaurantAppCon");
            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"));
        }