API Service Calls and Async ViewModel Loading - FULL STACK WPF (.NET CORE) MVVM #4

  Рет қаралды 25,996

SingletonSean

SingletonSean

Күн бұрын

Пікірлер: 54
@SingletonSean
@SingletonSean 4 жыл бұрын
The Financial Modeling Prep API now requires an API key. Learn how to set it up here: kzbin.info/www/bejne/hWeQXqKXh6iBeLs
@sebastianluft7441
@sebastianluft7441 3 жыл бұрын
It is limited to US only in free plan aswell now. I just faked my responses with Random() for now, don't wanna search for another API right now
@kadehoward2371
@kadehoward2371 3 жыл бұрын
I realize it is quite off topic but do anybody know of a good site to stream newly released tv shows online ?
@ms8367
@ms8367 4 жыл бұрын
This is so good!! Keep making WPF videos, please!! I'm learning so much!
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks MS204, more on the way of course!
@faraz-online
@faraz-online 4 жыл бұрын
Man! Where had you been hiding? No doubt I had been searching for matchless and comprehensive videos like the same for quite some time, i.e. a WPF with SQL Server plus with an API on ".Net Core" clarifying the binding as well.
@NatHollings
@NatHollings 3 жыл бұрын
Thanks for the videos man. 4 episodes in and learning a heap of new stuff!
@vincentotieno9197
@vincentotieno9197 4 жыл бұрын
Hi SingletonSean. Thanks for the great work you are doing. I went through this episode today and it took me a while to figure out that I had to append my API key to the service Uri in order to get back data. Otherwise I'm learning a lot from this series. Please keep it up.
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks for the heads up Vincent. I added a pinned comment for my tutorial on how to setup the API key.
@sivakumarr28
@sivakumarr28 4 жыл бұрын
Hey, you open my eyes to write a code in perfect way. I am looking forward to this guidance.
@datka89
@datka89 3 жыл бұрын
You are a great man with awesome video tutorials. Thanks a lot!
@sirinebibicha2024
@sirinebibicha2024 Жыл бұрын
A very wonderful course,
@2009baracuda
@2009baracuda 3 жыл бұрын
Thanks for the great course ! Since the API query syntax and results must have recently changed, in case someone wonders how to make tha service work, two things must be done. The model for MajorIndex must have the property 'Change' and not 'Changes' and in the service implementation the API (even for a single query) returns an Array. So we can just change the line with the Deserializer to : List majorIndexes = JsonConvert.DeserializeObject(jsonResponse); var majorIndex = majorIndexes[0]; Also the Uri with the new syntax could be built like this: string uri = $"financialmodelingprep.com/api/v3/quote/{GetUriSuffix(indexType)}?apikey=YOUR_API_KEY_GOES_HERE"; Hope it helps, have fun :)
@akshatube
@akshatube 3 жыл бұрын
Awesome man, this was very helpful, thanks a lot. :)
@unbekannt6111
@unbekannt6111 3 жыл бұрын
I changed the things but I still get an error. It seems that I get the response but cant extract the content of it correctly. So I always receive a empty array. Could u help me?
@imjdo
@imjdo 3 жыл бұрын
@@unbekannt6111 I had same problem, I fixed renaming MajorIndex properties with all lower case, sames a API results
@nbourre
@nbourre 3 жыл бұрын
You're the man!
@Hazem0010
@Hazem0010 2 жыл бұрын
Awesome idea it worked, But the index of majorIndexes[0] always get data of the first Type into all other types !! , so How do I change it dynamically? I tried many ideas but nothing worked with me.
@huynhtruongduy8770
@huynhtruongduy8770 3 жыл бұрын
you are awesome, i have learned a lot from this series, thanks
@harvb5939
@harvb5939 2 жыл бұрын
Sean, thanks for all the fantastic videos. I have learned a huge amount about WPF and other C# concepts. A question about the use of the static load method. Am I right in saying that the constructor is never called directly outside the class (I haven't yet watched the whole series)? In principle, could the constructor of the MajorIndexViewModel be set as private? I am asking to help my understanding. Apologies if you address this elsewhere. Keep up the excellent work.
@SingletonSean
@SingletonSean 2 жыл бұрын
Thanks Harv! That is correct, we could certainly make the constructor private. The only reason to keep it public would be if you wanted to instantiate the view model *without* also loading it, but we never do that in this app. Good question!
@Saleca
@Saleca 4 жыл бұрын
Flawless. great series, I sub in first video I saw, not disappointed, really easy to follow. I started this series after a video I saw where you show how to change views thought it would be good to see the whole process of building the wpf app hope to learn how to reuse objects of Views instead of creating new Views always. at least for my project I wish to fill a textbox maybe go to other page and comeback still with the text on the textbox. Anyway have you noticed that you can pin your favourite type of projects in the new project page? could simplify your life ;)) big Thanks to you!
@aelfar7533
@aelfar7533 3 жыл бұрын
This course is truly GOLD! I've recently started with C# .NET coming from a Java background and even if I'm still rough in my skills your teaching method is very clear to understand and follow. If you have a paid course on C# .NET i'll be glad to buy it so please link it in the comments if you do. I'm gonna be sending a bunch of people to see your videos :) THANKS!
@SingletonSean
@SingletonSean 3 жыл бұрын
That's wonderful to hear Ael Far! I have no paid courses as of now. I like the free content, helping as many people as possible, and growing this community :)
@davidporterrealestate
@davidporterrealestate 4 жыл бұрын
This is great, getting the data from a UI is good, but one thing I am struggling with is getting data from MediarR/Autofac, and having it stay in sync. If you could make a video on that that would be AWESOME!!
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey David, thanks for watching! I've been reading into MediatR a lot recently, but I haven't decided if I want to use it yet. I understand the necessity for CQRS in some cases, but the one thing holding me back from MediatR is exception handling. I assume with MediatR, you really shouldn't throw any exceptions and should use Response objects. Let me know what you think. Keeping data in sync is difficult. You might want to consider implementing a layer between your UI and MediatR/service layer that manages application state. I kinda do this in part 14. To keep user data in sync throughout the application, I have a class in the state layer (I call it an Authenticator in the video) that will retrieve data and update the user state.
@bieleckipawel1
@bieleckipawel1 4 жыл бұрын
When I create task within ContinueWith I get CA2008: Do not create tasks without passing a TaskScheduler. Adding TaskScheduler.Default fixes green squiggly but I'm not sure if this is correct way of dealing with the problem. What is your thougth on that? Many thanks.
@HugoM946
@HugoM946 2 жыл бұрын
Hey Sean, great series, learning a lot of cool stuff here! Sadly it looks like the Financial Modeling Prep is enforcing premium endpoints for the API, Major Index being one of them, so it's no longer available to free users. Do you have any tips on how to follow the course without the financial api? Perhaps with some mock data simulating the calls...
@SingletonSean
@SingletonSean 2 жыл бұрын
Hi Hugo! I would recommend following this tutorial instead (it's much more concise and WPF focused): kzbin.info/aero/PLA8ZIAm2I03hS41Fy4vFpRw8AdYNBXmNm
@HugoM946
@HugoM946 2 жыл бұрын
@@SingletonSean Nice, will do. I kinda jumped the gun and commented without checking your channel for the latest videos. That seems like exactly what I'm looking for. Thanks and keep up the good work! Cheers
@justinallen3037
@justinallen3037 Жыл бұрын
Hugo, It still works. Just sign up for a free account, use the same uri as in the video and add "?apikey=(key)" after the symbol/ticker.
@rajeshbelliwali409
@rajeshbelliwali409 3 жыл бұрын
It's really helped lot..I am struglling because async was blocking thread...
@jirisykora4979
@jirisykora4979 3 жыл бұрын
Great video, thank you. But ... Doesn't Task.Result() block the UI thread?
@SingletonSean
@SingletonSean 3 жыл бұрын
Thanks Jiří! Task.Result does block the UI thread for uncompleted Tasks, but in this case the Task has already been completed since we're using Task.ContinueWith first. Regardless, I end up updating this in a future video because ContinueWith is kind of nasty.
@FuzzyDPozzy
@FuzzyDPozzy 3 жыл бұрын
You know what would have been great if you could show how to go to documentation and use the api, I am struggling a lot with the documentation. Like the other day was reading github api couldn;t make anything worked.
@idnafu
@idnafu 3 жыл бұрын
Hi @SingletonSean first i have to say big thanks your videos are great not only explaining things but also teaching best practices for Coding. I have a question regarding the LoadMajorIndexViewmodel. You call it inside the UpdateCurrentViewModel since i have no HomeviewModel as a container so i put it in the Constructor of the View where i assign the Datacontext Do you see anything wrong with that? public CharOverviewView() { InitializeComponent(); _viewModel = CharOverviewViewModel.LoadCharacterViewModel(); DataContext = _viewModel; }
@jcturpin8737
@jcturpin8737 4 жыл бұрын
I was reviewing some of the code and remembered you asked if there was a 'better' way to write out the LoadMajorIndexes() function. I wouldn't say this way is better, but I tried adding in a ternary statement to make it more concise and it worked for me for both pass and fail scenarios: (seemed to work for me setting DowJones = null, or just putting null by itself at end of ternary) _majorIndexService.GetMajorIndex(MajorIndexType.DowJones).ContinueWith(task => task.Exception == null ? DowJones = task.Result : DowJones = null); //_majorIndexService.GetMajorIndex(MajorIndexType.DowJones).ContinueWith(task => //{ // if (task.Exception == null) // { // DowJones = task.Result; // } //});
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey JC, that does look cleaner. You're really starting to sell me on these one-liners hahaha. I'm not sold on the property changed snippet you mentioned earlier yet, but this definitely looks cleaner. When I return to this view model (it needs some error handling), I'll definitely make this adjustment if I remember.
@jcturpin8737
@jcturpin8737 4 жыл бұрын
@@SingletonSean There's a fine line between concise and cryptic, and as the team I work with has always said, "The best format is the one who doesn't confuse the next programmer who comes along to maintain it." but it is nice to know of the options on a case-by-case scenario. Error handling might need more room than a one liner. :-) Thank you for your thoughts.
@jcturpin8737
@jcturpin8737 4 жыл бұрын
I found an interesting 'new to me' way to do a switch statement, called a switch expression. It's an alternative path to the same functionality and would look like this in the MajorIndexService.cs private string GetUriSuffix(MajorIndexType indexType) { return indexType switch { MajorIndexType.DowJones => ".DJI", MajorIndexType.Nasdaq => ".IXIC", MajorIndexType.SP500 => ".INX", _ => throw new Exception($"GetUriSuffix: Must use a valid index type. Type Used:{indexType}") }; } It also uses a 'Discard character' (the underscore), which I'm having fun figuring out how/when to use as well. :-) just thought I'd share, Thanks SingletonSean!
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey JC, pretty interesting syntactic sugar! I can't tell if I like it or not, hahaha.
@jcturpin8737
@jcturpin8737 4 жыл бұрын
@@SingletonSean I thought it was a little odd at first, but I think I'm sold on it, though it would be on a 'case' by 'case' situation. ;-) I do like the use of lamda's over a keyword and colon. It doesn't look like it allows for 'fall through' though, but I never really do that anyway... Cheers! -Jeremy
@omerkorkut
@omerkorkut 3 жыл бұрын
json data ?
@ivandrofly
@ivandrofly 5 ай бұрын
16:33 - Another video on creating and returning viewmodel before entire init kzbin.info/www/bejne/bpiWZZueos58lbM (more detailed)
Всё пошло не по плану 😮
00:36
Miracle
Рет қаралды 3,4 МЛН
小蚂蚁会选到什么呢!#火影忍者 #佐助 #家庭
00:47
火影忍者一家
Рет қаралды 121 МЛН
Бенчик, пора купаться! 🛁 #бенчик #арти #симбочка
00:34
Симбочка Пимпочка
Рет қаралды 3,6 МЛН
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Async Commands (and Async Relay Command) - EASY WPF (.NET CORE)
14:14
I Rewrote This Entire Main File // Code Review
16:08
The Cherno
Рет қаралды 172 М.
Creating a Card Control - FULL STACK WPF (.NET CORE) MVVM #6
26:13
SingletonSean
Рет қаралды 15 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 429 М.
JWT авторизация. Основы JWT - механизма.
6:45
Хочу вАйти
Рет қаралды 12 М.
Всё пошло не по плану 😮
00:36
Miracle
Рет қаралды 3,4 МЛН