Adds ingredients managing
This commit is contained in:
@@ -25,10 +25,18 @@ impl<'a> CreateRecipe<'a> {
|
||||
self.title = title;
|
||||
}
|
||||
|
||||
fn add_ingredient(&mut self, ingredient: String) {
|
||||
// TODO: Validate ingredient
|
||||
self.ingredients.push_str(&ingredient);
|
||||
println!("+");
|
||||
fn add_ingredient(&mut self, name: String) {
|
||||
use crate::ingredients::*;
|
||||
|
||||
// Check it exists or create
|
||||
if let Some(ingdt) = find(self.connection, &name) {
|
||||
println!("=");
|
||||
} else {
|
||||
create(self.connection, &name);
|
||||
println!("+{}", &name);
|
||||
}
|
||||
|
||||
self.ingredients.push_str(&name);
|
||||
}
|
||||
|
||||
fn insert(self) {
|
||||
|
||||
Reference in New Issue
Block a user