예제 #1
0
        public JsonResult Put(WomenShoes shoe)
        {
            string        query         = @"
            update dbo.womenshoes set 
            WomenShoesName = '" + shoe.WomenShoesName + @"'
            ,WomenShoesPrice = '" + shoe.WomenShoesPrice + @"'
            ,WomenShoesQuantity = '" + shoe.WomenShoesQuantity + @"'
            ,WomenShoesPhoto = '" + shoe.WomenShoesPhoto + @"'
            where WomenShoesID = " + shoe.WomenShoesID + @" 
            ";
            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("ClothesAppCon");
            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("Update Successful"));
        }
예제 #2
0
        public JsonResult Post(WomenShoes shoe)
        {
            string        query         = @"
            insert into dbo.womenshoes
            (WomenShoesName, WomenShoesPrice, WomenShoesQuantity, WomenShoesPhoto) values
            (
            '" + shoe.WomenShoesName + @"'
            ,'" + shoe.WomenShoesPrice + @"'
            ,'" + shoe.WomenShoesQuantity + @"'
            ,'" + shoe.WomenShoesPhoto + @"'
            )";
            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("ClothesAppCon");
            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 Successful"));
        }