ASP.NET Core Web API - 11. UPDATE & PUT Methods

Тәжірибелік нұсқаулар және стиль

ASP.NET Core Web API 2022 - 6. UPDATE Methods
UML Diagram: drive.google.com/file/d/1EbYY...
Github Repo For This Project: github.com/teddysmithdev/poke...
Twitter: / teddysmithdev
Github: github.com/teddysmithdev
Linkedin: / teddy-smith-015ba61a3

Пікірлер: 30

  • @jeffwoltjen3887
    @jeffwoltjen3887 Жыл бұрын

    "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.

  • @jp_blue9222
    @jp_blue92222 жыл бұрын

    Thanks for this... Will be adding to my playlist to learn 😊

  • @henrik3098
    @henrik3098 Жыл бұрын

    thans bro!!

  • @SerielThriller
    @SerielThriller Жыл бұрын

    The error was because the JSON you sent to it was missing the " before the P in Pikatu.

  • @JoseAlter
    @JoseAlter Жыл бұрын

    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.

  • @at-tf9cc
    @at-tf9cc2 жыл бұрын

    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.

  • @TeddySmithDev

    @TeddySmithDev

    2 жыл бұрын

    Can you comment exact line in code? I will go back update the repo + put update in comment. Thanks for commenting.

  • @brandonramirez2777

    @brandonramirez2777

    Жыл бұрын

    ​@@TeddySmithDev In Folder 'Repository' > PokemonRepository > Method 'UpdatePokemon' in line 91 of your repo. I had the exact same question, thanks

  • @of_youtube

    @of_youtube

    Жыл бұрын

    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

  • @antenehshimelis3369

    @antenehshimelis3369

    Жыл бұрын

    @@brandonramirez2777 yes i have seen the same thing too

  • @LamNguyen-jp5vh

    @LamNguyen-jp5vh

    Жыл бұрын

    Yeah, I also have the same question too, I think we dont have to use those.

  • @quocthong328
    @quocthong328 Жыл бұрын

    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);.

  • @roemer024
    @roemer024 Жыл бұрын

    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.

  • @TeddySmithDev

    @TeddySmithDev

    Жыл бұрын

    lmao

  • @bijayshrestha7843
    @bijayshrestha7843 Жыл бұрын

    How to update pokemon Owner and pokemon Category?

  • @racmanov
    @racmanov6 ай бұрын

    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

    @TeddySmithDev

    6 ай бұрын

    People say generic in repos as bad but I’ve seen them work great. Plus give you something to talk about in interview 👍

  • @racmanov

    @racmanov

    6 ай бұрын

    @@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)

  • @TeddySmithDev

    @TeddySmithDev

    6 ай бұрын

    yeah you got it. Thanks for the comment!

  • @joshuaarmando7765
    @joshuaarmando77654 ай бұрын

    Category and Owner of the Pokemon not updating bro

  • @cryptoeric24
    @cryptoeric24 Жыл бұрын

    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

  • @hmilaam8907
    @hmilaam89073 ай бұрын

    why u didn't updating the FK in reviewer

  • @corykennedy9319
    @corykennedy9319 Жыл бұрын

    The error at the end was because your JSON payload was malformed. You deleted the first " on property title by accident :)

  • @si1icarus
    @si1icarus Жыл бұрын

    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(); }

  • @ianwanjala8621

    @ianwanjala8621

    9 ай бұрын

    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

Келесі