Ejemplo n.º 1
0
        public JsonResult Put(MenShoes shoe)
        {
            string        query         = @"
            update dbo.menshoes set 
            MenShoesName = '" + shoe.MenShoesName + @"'
            ,MenShoesPrice = '" + shoe.MenShoesPrice + @"'
            ,MenShoesQuantity = '" + shoe.MenShoesQuantity + @"'
            ,MenShoesPhoto = '" + shoe.MenShoesPhoto + @"'
            where MenShoesID = " + shoe.MenShoesID + @" 
            ";
            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"));
        }
Ejemplo n.º 2
0
        public JsonResult Post(MenShoes shoe)
        {
            string        query         = @"
            insert into dbo.menshoes
            (MenShoesName, MenShoesPrice, MenShoesQuantity, MenShoesPhoto) values
            (
            '" + shoe.MenShoesName + @"'
            ,'" + shoe.MenShoesPrice + @"'
            ,'" + shoe.MenShoesQuantity + @"'
            ,'" + shoe.MenShoesPhoto + @"'
            )";
            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"));
        }