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; } }
public IActionResult AddGroceryList(GroceryLists groceryList) { groceryListDAL.AddGroceryList(groceryList); return(RedirectToAction("Index", "Home")); }