Exemplo n.º 1
0
        public void AddGroceryList(GroceryLists newGroceryList)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();

                    string sql = $"INSERT INTO groceryLists (groceryListImage) values (@groceryListImage);";

                    SqlCommand command = new SqlCommand(sql, connection);

                    command.Parameters.AddWithValue("@groceryListImage", newGroceryList.GroceryListImage);

                    command.ExecuteNonQuery();
                }
            }
            catch (SqlException exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public IActionResult AddGroceryList(GroceryLists groceryList)
        {
            groceryListDAL.AddGroceryList(groceryList);

            return(RedirectToAction("Index", "Home"));
        }