"There are a lot of people in the UK who watch my videos so let's change the country to Europe! Not everything has to be about America." As a fellow American, this is a brilliant piece of trolling. Well done.
First of all, thank you very much your videos have helped me a lot and secondly I am commenting this before finishing the video, but I want to ask, how to do a dynamic update? if I want to update a single object of the model, some or all.
For UpdatePokemon You get the ownerId and categoryId in the controller and give them to the repository but don't do anything with them, so owner and category of the pokemon are not updated.
Yes, he fucked up a little. But I guess we dont have to change them updating Pokemon. Because the Pokemon and the Owner are linked by Id. If we change some properties of the Pokemon nothing happens with the Owner or the Category
17:28 TOTALLY WRONG WTF Misty resides in Celadon City, Saffron City is Sabrina's gym *flips table* 1/10 bad API. jk I liked every video so far huheuhe.
I love how simple this tutorials are. They are basic so it allows us to do a bit more on our own. I have made another dtos without ids. Which is great in post but in put i dont need validation check for update since i just update the string and id is applied to mapping. This project is awesome playground. One question tough. I have created and abstract class since update, post and save can be done in generic way in repositories (and i dont have to repeat myself :). I mean everything works but is this good practice or bad?
@@TeddySmithDev ty for fast response. I didnt do whole repo. Juat stuff that gets repeated. Like that 2 line saving, or thins that are pretty much the same everywhere (update and create)
hello, thank you for your teaching but I'm little bit confusing when we use tag ProducesResponseType 404, 400 and 204 but in the code we return return StatusCode(500, ModelState);.
You said you would never say pica pica in real life but you did in real life video!! LOL!! Also, the last error was you were missing the first quotation mark " on the title in swagger
Thank you for your lovely and educational videos, I have learned a lot just by watching your videos ;). One question though, the UpdatePokemon method in the PokemonRepository, you just passed along the ownerId and categoryId but you have not Update the relations between Pokemon, PokemonOwner (join table) and PokemonCategory (join table), another words the owner and category of the pokemon are not updating. My solution was to simply find the relations between the data and try to update them, but I did face couple of problems regarding updating the join tables, therefore I tried to delete the related records from join tables and insert new relations. Would you please take a look at the following implementation and tell me if there is a better way to update the pokemon records. Many thanks. public bool UpdatePokemon(int ownerId, int categoryId, Pokemon pokemon) { var pokemonOwnerEntity = _context.PokemonOwners. Where(o => o.PokemonId == pokemon.Id).FirstOrDefault(); var OwnerEntity = _context.Owners. Where(o => o.Id == ownerId).FirstOrDefault(); var pokemonCategoryEntity = _context.PokemonCategories. Where(c => c.PokemonId == pokemon.Id).FirstOrDefault(); var categoryEntity = _context.Categories.Where(o => o.Id == categoryId).FirstOrDefault(); if (pokemonOwnerEntity != null && OwnerEntity != null) { _context.Remove(pokemonOwnerEntity); var pokemonOwner = new PokemonOwner() { Owner = OwnerEntity, Pokemon = pokemon, }; _context.Add(pokemonOwner); } if (pokemonCategoryEntity != null && categoryEntity != null) { _context.Remove(pokemonCategoryEntity); var pokemonCategory = new PokemonCategory() { Category = categoryEntity, Pokemon = pokemon, }; _context.Add(pokemonCategory); } else return false; _context.Update(pokemon); return Save(); }
I don't think you should remove the PokemonOwner or the PokemonCategory objects, the right thing to do would be to update them. Also, the checks that you are doing i.e whether the owner entity is null or not should be done in the controller
"There are a lot of people in the UK who watch my videos so let's change the country to Europe! Not everything has to be about America." As a fellow American, this is a brilliant piece of trolling. Well done.
First of all, thank you very much your videos have helped me a lot and secondly I am commenting this before finishing the video, but I want to ask, how to do a dynamic update? if I want to update a single object of the model, some or all.
For UpdatePokemon You get the ownerId and categoryId in the controller
and give them to the repository but don't do anything with them,
so owner and category of the pokemon are not updated.
Can you comment exact line in code? I will go back update the repo + put update in comment. Thanks for commenting.
@@TeddySmithDev In Folder 'Repository' > PokemonRepository > Method 'UpdatePokemon' in line 91 of your repo.
I had the exact same question, thanks
Yes, he fucked up a little. But I guess we dont have to change them updating Pokemon. Because the Pokemon and the Owner are linked by Id. If we change some properties of the Pokemon nothing happens with the Owner or the Category
@@brandonramirez2777 yes i have seen the same thing too
Yeah, I also have the same question too, I think we dont have to use those.
17:28 TOTALLY WRONG WTF
Misty resides in Celadon City, Saffron City is Sabrina's gym *flips table* 1/10 bad API.
jk I liked every video so far huheuhe.
lmao
Thanks for this... Will be adding to my playlist to learn 😊
The error was because the JSON you sent to it was missing the " before the P in Pikatu.
I love how simple this tutorials are. They are basic so it allows us to do a bit more on our own. I have made another dtos without ids. Which is great in post but in put i dont need validation check for update since i just update the string and id is applied to mapping. This project is awesome playground.
One question tough. I have created and abstract class since update, post and save can be done in generic way in repositories (and i dont have to repeat myself :). I mean everything works but is this good practice or bad?
People say generic in repos as bad but I’ve seen them work great. Plus give you something to talk about in interview 👍
@@TeddySmithDev ty for fast response. I didnt do whole repo. Juat stuff that gets repeated. Like that 2 line saving, or thins that are pretty much the same everywhere (update and create)
yeah you got it. Thanks for the comment!
hello, thank you for your teaching but I'm little bit confusing when we use tag ProducesResponseType 404, 400 and 204 but in the code we return return StatusCode(500, ModelState);.
You said you would never say pica pica in real life but you did in real life video!! LOL!! Also, the last error was you were missing the first quotation mark " on the title in swagger
The error at the end was because your JSON payload was malformed. You deleted the first " on property title by accident :)
thans bro!!
why u didn't updating the FK in reviewer
Category and Owner of the Pokemon not updating bro
How to update pokemon Owner and pokemon Category?
Thank you for your lovely and educational videos, I have learned a lot just by watching your videos ;).
One question though, the UpdatePokemon method in the PokemonRepository, you just passed along the ownerId and categoryId but you have not Update the relations between Pokemon, PokemonOwner (join table) and PokemonCategory (join table), another words the owner and category of the pokemon are not updating.
My solution was to simply find the relations between the data and try to update them, but I did face couple of problems regarding updating the join tables, therefore I tried to delete the related records from join tables and insert new relations.
Would you please take a look at the following implementation and tell me if there is a better way to update the pokemon records.
Many thanks.
public bool UpdatePokemon(int ownerId, int categoryId, Pokemon pokemon)
{
var pokemonOwnerEntity = _context.PokemonOwners.
Where(o => o.PokemonId == pokemon.Id).FirstOrDefault();
var OwnerEntity = _context.Owners.
Where(o => o.Id == ownerId).FirstOrDefault();
var pokemonCategoryEntity = _context.PokemonCategories.
Where(c => c.PokemonId == pokemon.Id).FirstOrDefault();
var categoryEntity = _context.Categories.Where(o => o.Id == categoryId).FirstOrDefault();
if (pokemonOwnerEntity != null && OwnerEntity != null)
{
_context.Remove(pokemonOwnerEntity);
var pokemonOwner = new PokemonOwner()
{
Owner = OwnerEntity,
Pokemon = pokemon,
};
_context.Add(pokemonOwner);
}
if (pokemonCategoryEntity != null && categoryEntity != null)
{
_context.Remove(pokemonCategoryEntity);
var pokemonCategory = new PokemonCategory()
{
Category = categoryEntity,
Pokemon = pokemon,
};
_context.Add(pokemonCategory);
}
else
return false;
_context.Update(pokemon);
return Save();
}
I don't think you should remove the PokemonOwner or the PokemonCategory objects, the right thing to do would be to update them. Also, the checks that you are doing i.e whether the owner entity is null or not should be done in the controller