public static void RemoveRecipe(Recipe recipe) { try { DBRecipes.DeleteRecipe(recipe); } catch (Exception) { throw; } }
public static int SaveRecipe(Recipe recipe, IList types) { // Send information to database layer try { // Before printing check that all fields are valid if (recipe.Name == String.Empty || recipe.Time == String.Empty || recipe.Instructions == String.Empty || recipe.Writer == String.Empty) { throw new Exception("Reseptissä ei voi olla tyhjiä kenttiä!"); } return(DBRecipes.SaveRecipe(recipe, types)); } catch (Exception) { throw; } }
public static List <Recipe> GetAllRecipes(string searchWord, IList types) { List <Recipe> recipes = new List <Recipe>(); try { DataTable dt = DBRecipes.GetAll(searchWord, types); Recipe recipe; foreach (DataRow dr in dt.Rows) { recipe = new Recipe(Convert.ToInt32(dr["id"]), Convert.ToString(dr["name"]), Convert.ToString(dr["time"]), Convert.ToString(dr["instructions"]), Convert.ToString(dr["writer"])); recipes.Add(recipe); } return(recipes); } catch (Exception) { throw; } }
public static List <string> GetAllTypes() { List <string> types = new List <string>(); try { DataTable dt = DBRecipes.GetAllTypes(); string temp = null; foreach (DataRow dr in dt.Rows) { temp = Convert.ToString(dr["typename"]); types.Add(temp); } return(types); } catch (Exception) { throw; } }