Calling an Azure API in WPF - A TimCo Retail Manager Video

Поделиться
HTML-код
  • Опубликовано: 23 авг 2020
  • We have our API deployed onto Azure (a free instance) using CI/CD. Now, we are going to verify that we can connect to that API using our local WPF application. Then, we will review our database configuration on Azure. Finally, we will get our WPF application from the build process and verify that the API will run on it as well.
    ** TimCo source code now at: www.iamtimcorey.com/courses/b...
    Full Courses: www.iamtimcorey.com
    Mailing List: signup.iamtimcorey.com/
    Full Playlist: • TimCo Retail Manager C...
    One-off tutorials are awesome but they aren't the only thing you should be doing to learn C#. Another vital part of learning is learning how to put it all together. This interactive course is all about putting the pieces together. You can watch each video on its own or you can watch them in order and see a bigger picture. The choice is yours.
    This course focuses on real-world development. As such, we are simulating that we work for TimCo Enterprise Solutions on a brand new product, the TimCo Retail Manager. Just like in the real world, we are starting out with one set of requirements but know that over time they will change.

Комментарии • 56

  • @saadaldulaijan4957
    @saadaldulaijan4957 3 года назад +11

    I swear if I study Software Engineering for 5 years in the best university in the world, I wouldn’t get these skills I learned from this series.
    Thanks Tim, please keep this series going 👍🏻

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +3

      Having taught in the University environment before, I understand. Thanks!

  • @nirajdahal5019
    @nirajdahal5019 3 года назад +1

    Wow the series is going on.. Thank you Tim. (Waiting for Tim Corey's Discord where we C sharpers can help each others out)

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +1

      Keep an eye out for that. I am trying to find the time.

  • @siphenathimpetsheni7565
    @siphenathimpetsheni7565 3 года назад +1

    Thanks Mr Corey.. Keep up the good work 💯

  • @kontrolla1
    @kontrolla1 3 года назад

    Thanks for another excellent video Tim

  • @damienfenton3880
    @damienfenton3880 3 года назад +2

    I just started your new Blazor Assembly course and I agree with that methodology of teaching how to read code. I think university and college courses should have a class with a few weeks focused on reading and debugging code that the student didn't write. For example, they are given code samples that (1) doesn't compile, (2) causes runtime exceptions, (3) runs without error but doesn't adhere to the functional specifications. The students would have to figure out why.
    This could even be a possible future series of videos from you.

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      I agree. I'm glad you are enjoying the teaching methodology. I will definitely be doing more code reading videos. I did do a video on debugging broken code, but I'll probably do more there as well.

  • @hungnguyencanh5013
    @hungnguyencanh5013 3 года назад +1

    Thank you so much

  • @tobiasm999
    @tobiasm999 3 года назад +1

    Hello Tim,
    I am a big fan of your work and have learned alot during this course.
    I was just wondering if there's going to be any testing included in this course?
    In the beginning the first few courses I thought you have mentioned that we will add tests later, to simulate how you would add unit, integration and end to end tests to an already established project in a real working environment.
    Thanks and best regards

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      I will add the suggestion to my list. In the mean time check out this: ruclips.net/video/DwbYxP-etMY/видео.html 'Mocking in C# Unit Tests - How To Test Data Access Code and More'
      and/or
      ruclips.net/video/ub3P8c87cwk/видео.html 'Intro to Unit Testing in C# using XUnit'

  • @mahamoudj3745
    @mahamoudj3745 3 года назад +1

    Thanks

  • @hamedashrafi4885
    @hamedashrafi4885 3 года назад +1

    This course is great thanks. This is great for allowing users to login but how would you sell a product with this app? How do you implement stripe or PayPal? For example you provide a product and clients pay for it online then they login and use the features of the app they have paid for.

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      When it comes to selling the products we have in our shopping cart, you would add the payment processor as part of the checkout process. If you are talking about selling the WPF app itself, that would take packaging it up and using a system for putting some type of product key into your application. I won't be doing either with this project, but I may in the future in other videos.

  • @Contractor48
    @Contractor48 3 года назад

    Tim, there are new fields in AspNetRoles. What do i enter in NormalizedName and ConcurrencyStamp? is concurrency stamp also a guid()?

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      NormalizedName is the name in all capital letters. Concurrency stamp is a GUID.

  • @andywalter7426
    @andywalter7426 3 года назад

    One suggestion I have for an app package is the single file. I know that .net core has a feature where you can choose to make it a single file. That seems to be the best option for deployment because a person just double clicks the file and it just works. I have done that for many of my apps and never had any problems with it.

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      I like that suggestion. It is simple. I'll consider it.

  • @murrayscallywag
    @murrayscallywag 3 года назад

    Hi Tim, thanks for the course so far, really enjoying it. I've hit a snag though and I hope you can point me in the right direction... When trying to connect to Azure API from the WPF login, I get a false result at the _apiClient.GetAsync("api/User") (500 Internal Server Error). I've double checked that the User in AspNetUsers in the Auth database is reflected in User in the TimCoData database, they have matching IDs. I'm not sure what else to check. Another user mentioned tokens in the comments? I'm assuming they mean the ID? Thanks

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      You would need to be passing in the bearer token in order to access the User endpoint, yes.

    • @murrayscallywag
      @murrayscallywag 3 года назад

      @@IAmTimCorey Thanks Tim, the line just before that GET call, the DefaultRequestHeaders.Add method, has the token value, so authentication seems to be working. I've checked the connection string in Azure for the TRMData database and it looks correct too. At a loss where else to look.

  • @yashtarekar3762
    @yashtarekar3762 3 года назад

    Amazing videos ..but not able to find any weekly challenge videos .
    Can you please add those too as they had real word problems to practice

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +1

      I pulled the Weekly Challenge from the channel because of a lack of interest. However, it is coming back as courses soon.

  • @flabberdog
    @flabberdog 3 года назад

    I have spent a lot of time trying to figure out the correct way to handle errors in Entity Framework processes and propagate them to the user. If you try and perform an operation on a user and there is an error thrown (of type IdentityError for this example), it often has more than one error, how do you correctly funnel these to the user?
    The HttpClient expects a HttpResponseMessage so I have tried building a request with the errors in the body that is returned by the API method but it seems you can only pass a string back as content, or can you?
    Or would you handle all the errors in the API and simply return a StatusCode response with an error message?
    Basically should you be returning a list of errors from an API to a UI or should you be handling it completely different?
    Thanks a bunch in advance anybody who can help, I've had a frustrating few days on this.

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +1

      Typically you just show the user an error message (one). You would save the chain of errors for your logs. An API should not tell the user details about how the system works.

  • @wjvelasquez
    @wjvelasquez 3 года назад

    that is the right resolution for visualstudio.

  • @suprithsuppi9535
    @suprithsuppi9535 3 года назад

    Hi Tim
    Automapper is fast or can i use Reflection?

    • @longuinni
      @longuinni 3 года назад +1

      Automapper use reflection to create the maps. The only difference is that automapper create the map only one time at the application startup.

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +1

      Fernando is correct. It is fast. If you did reflection and cached the information, it would be similar in speed but people often get the caching wrong. This way it is done for you.

  • @MasterKrepta
    @MasterKrepta 3 года назад

    Having a strange error and not sure what exactly is causing it. I get a valid bearer token from the Azure API, but I keep getting a 500 Internal server error, after stepping through the code it returns false at this line in APIhelper: HttpResponseMessage response = await _apiClient.GetAsync("/api/User") Continuing to debug now.

    • @MasterKrepta
      @MasterKrepta 3 года назад

      For anyone else having issues, I figured it out, I forgot to copy my token into the user's table on the Azure Side when we set the Databases up on Azure

    • @IAmTimCorey
      @IAmTimCorey  3 года назад

      I am glad you were able to figure it out.

    • @LarryB15
      @LarryB15 3 года назад

      I had a similar problem where I kept getting an Internal Server Error when I tried to access the databases on Azure.
      It turns out I had forgotten the password to the SQL server and changed it's password.
      What I had forgotten was that the password was used in the API configuration for the database connection strings and was now wrong.
      What a waste of a morning trying to debug that issue.

    • @hellyworld9325
      @hellyworld9325 3 года назад

      @@MasterKrepta Can you elaborate on that? I'm having the same issue.

    • @MasterKrepta
      @MasterKrepta 3 года назад

      @@hellyworld9325 it's been awhile so I don't remember exactly how I fixed it but what I would recommend is check your azure db tables and make sure that your token is included in there because that's what I had forgotten to do.
      Hopefully that's helpful.

  • @manuelketisch3752
    @manuelketisch3752 3 года назад

    I am currently experiencing a strange problem with my code.
    After login, in the SalesViewModel, with OnViewLoaded, we try to load products.
    This fails and i end up with our fatal exception message on screen.
    Steeping through the code, the product endpoint gets called. In there, we have our using statement:
    using (HttpResponseMessage response = await _apiHelper.ApiClient.GetAsync("/api/Product"))
    But for some reason, response contains: StatusCode 403, ReasonPhrase 'Forbidden'...
    When i try to do the same request with Postman, i get an error that says:
    Error: connect ECONNREFUSED 127.0.0.1:44367 (which is my server port)
    Trying to get a new Access Token results in OAuth2.0 failed, with the same ECONNREFUSED message.
    When i use the API to get a new Access Token with my user credentials it works just fine.
    Does anyone have any idea what could be the issue here?

    • @manuelketisch3752
      @manuelketisch3752 3 года назад

      Another strange thing is:
      When i run the API from local, then it shows the change we made to the title in the Home Views Index.cshtml,
      but when i run the API from Azure, it does not show this edit even though the code has been pushed to Azure and i can review it in the repos section.

    • @sanyamgupta2065
      @sanyamgupta2065 Год назад

      Hi! Were you able to find a solution?

    • @sanyamgupta2065
      @sanyamgupta2065 Год назад

      @@manuelketisch3752 Found the solution. Mistakingly, I skiiped entering the details of Roles table in the Auth db in Azure. They can be simply copied from the local. Then add matching entries for both the roles and userid in the userRoles table in auth db in azure. And it will start to work.

  • @marcusmaunula5018
    @marcusmaunula5018 3 года назад

    Have you thought of doing some Blazor tests for this? I know you have done Blazor before but it is much better to have real world examples :)

    • @IAmTimCorey
      @IAmTimCorey  3 года назад +1

      I will be adding Blazor to this project at some point. I want to get through the CI/CD process first, though.

    • @marcusmaunula5018
      @marcusmaunula5018 3 года назад

      @@IAmTimCorey Awesome that it is coming though :). Like I wrote in your new course promo. Most examples are todos and non business related stuff. Seeing this work in a realistic real world application makes all the difference. I will get that course later (need to wait for my next year budget).

    • @marcusmaunula5018
      @marcusmaunula5018 3 года назад

      @@IAmTimCorey Also. I have learned alot from your CI videos. I am new to azure devops and this got me up to speed.