-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature 25 edit options #93
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! Just need to look up automapper.
Automapper docs are very good https://docs.automapper.org/en/stable/Getting-started.html
@@ -70,6 +70,19 @@ public async Task<string> AddIngredient(IngredientAddDTO ingredientAddDTO) | |||
return ingredientAddDTO.Name; | |||
} | |||
|
|||
public async Task UpdateIngredient(string name, IngredientAddDTO ingredientAddDTO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ingredient services currently has this update method https://github.com/chrisK00/CRUDRecipeEF/blob/master/CRUDRecipeEF.BL.DL/Services/IIngredientService.cs
@@ -78,6 +78,19 @@ public async Task<string> AddIngredientToRecipe(IngredientAddDTO ingredientAddDT | |||
return recipeName; | |||
} | |||
|
|||
public async Task UpdateRecipe(string name, RecipeAddDTO recipeAddDTO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend doing it the way we did with automapper in the ingredientservice. Msg me on discord if you want me to explain if it isnt clear whats happening
// this is super shit code, sorry | ||
//TODO: Fix this mess | ||
var recipe = await _recipeService.GetRecipeByName(name); | ||
RecipeAddDTO recipeAdd = new RecipeAddDTO() { Name = recipe.Name }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automapper can fix this easily
- We need a configuration inside the AutoMapperProfiles CreateMap<from, to>
- use the mapper like this: _mapper.Map(fromObject)
} | ||
else if (char.ToUpper(editWhat[0]) == 'I') | ||
{ | ||
//TODO: Not DRY, extract this and use it in common locations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, some sort of generic method or factory is probably the way to go.
…lacing it anyways.
Feature/97 ingredient repo
…q and if we wanna test the repo we can use in memory db
Feature/95 ingredientservice tests
closes #25