Тёмный

Early Refactoring in C# - A TimCo Retail Manager Video 

IAmTimCorey
Подписаться 415 тыс.
Просмотров 16 тыс.
50% 1

Based on your comments, we are going to refactor the application to put a few tweaks in place. The tweaks include foreign keys, better WPF list displays, an Entity Framework database rename, and more.
** TimCo source code now at: www.iamtimcorey.com/courses/b...
Full Courses: www.iamtimcorey.com
Mailing List: signup.iamtimcorey.com/
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.

Опубликовано:

 

7 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 120   
@ahmadkelany
@ahmadkelany 5 лет назад
First and always: Thank you very much for the amazing series. A remark though: @21:00 The issue would have been resolved by first adding a migration then updating the database: 1. pm> add-migration migrationName 2. pm> update-database
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm not an EF expert (I barely use it) so you could be right. Would this have renamed the database? If so, wouldn't we want to make the change before this point, though, since it will still have the old name in the migration path?
@sc100200090
@sc100200090 4 года назад
Definitely an excellent collection of advice and guidance for Refactoring! Thanks again Tim!
@IAmTimCorey
@IAmTimCorey 4 года назад
You are welcome.
@stinefelt
@stinefelt 3 года назад
Refactor fun and thank you for taking the feedback and applying it.
@IAmTimCorey
@IAmTimCorey 3 года назад
You are welcome.
@quentincouissinier8533
@quentincouissinier8533 3 года назад
I'm having such a great time, thanks !
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 года назад
We are glad you are enjoying it.
@harag9
@harag9 5 лет назад
Thanks for that Tim. Coming on great. Going back to the subject of Xamarin from other videos, I think it would be great to do a Xamarin.Forms front end for the Manager using the API we've created. Keep up the excellent work!
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thanks!
@onyebuchiboss
@onyebuchiboss 4 года назад
Hi Harag, my UI to this course is actually a Xamarin forms, using UWP. Caliburn micro and the rest third party toolS that Tim used wouldnt work with Xamarin forms as it is .NETCore and caliburn micro is created for .NETFramwork. I Suggest u use FreshMVVM for Xamarin forms to get DI, singleton and all, it works pretty good.
@aminebenhebba1891
@aminebenhebba1891 3 года назад
the EF was yalling because the AutomaticMigrationsEnable on the Configuration class constructor was set to false set it to true and you will get automatic migrations when u use the : Update-Database or for good practice add a meaningfull name to your migration snapshots with : Add-Migration before using : Update-Database. hope it will help some one.
@IAmTimCorey
@IAmTimCorey 3 года назад
Thanks for sharing.
@mov4736
@mov4736 3 года назад
Thanks :D
@MrJPhardy
@MrJPhardy 5 лет назад
Hello Tim, I really like your channel, you do a great job. Is it possible that you make a tutorial introduction how to make custom controlls in WPF?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I will add it to the list. Thanks for the suggestion.
@dionkllokoqi6981
@dionkllokoqi6981 3 года назад
When enabling migrations, it can be that the default project is set to the UI, which leads to an error in the package manager. Just set back to the retail manager, for anybody who encountered this issue :)
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 года назад
Thanks for sharing that tip.
@szaaary
@szaaary 3 года назад
I was so proud after 5-10 minutes of checking and debugging that I found out, what is wrong with that ID in user table theeeen... you just solved it in on video in 2 secounds xD Feelsbadman.
@IAmTimCorey
@IAmTimCorey 3 года назад
Don't let the video fool you - I don't always figure it out that quickly. I'm not sure I even figured it out this time that fast. Sometimes I pause the video, think, and then restart the video. Debugging is about experience. The more you do it, the more scenarios you will have encountered. So, the better a person is at debugging, the more things they have screwed up in the past. Great job figuring it out.
@mjaguilar923
@mjaguilar923 5 лет назад
Thank you
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are welcome.
@muslimshexany6066
@muslimshexany6066 3 года назад
Thank You
@IAmTimCorey
@IAmTimCorey 3 года назад
You are welcome.
@alexn4217
@alexn4217 3 года назад
I didn't read all the comments and maybe I missed this, but I was just wondering why we refactored the CalculateTax() method and not CalculateSubTotal () which is even a shorter one liner: return Cart.Sum(x => x.Product.RetailPrice * x.QuantityInCart);
@AdamShortSolutions
@AdamShortSolutions 5 лет назад
Hi Tim, Fantastic series thanks. Great to find such an in-depth explanation of MVVM and Caliburn. Being a beginner to C# and WPF I always wanted to learn MVVM, but got so confused by what I saw or read that I kept on putting it off into the TODO basket. Are there any disadvantages to using a with StringFormat at the part where you expand on the SalesView display? For example: This way at least you can combine a whole lot of TextBlocks and don't have to worry about specifying FontSize each time. Your use of StringFormat just triggered it off in my mind. Looking forward to the next installments.
@IAmTimCorey
@IAmTimCorey 5 лет назад
The multibinding would work but it doesn't allow us to be as granular about the formatting of each item.
@grumpydeveloper69
@grumpydeveloper69 5 лет назад
Since the FK naming convention is FK__ the "To" feels redundant. I have seen databases where they had the column names in the FK name as well. It made the name very recognisable but also very long (ie the would have FK_SalesDetail_SaleId_Sales_Id I don't really care for that either even though when there are a lot of FK relations it does stand out more
@IAmTimCorey
@IAmTimCorey 5 лет назад
I understand. I figure that the two letters add a bit of clarity and that is worth it to me. It doesn't hurt anything and it makes things a bit clearer.
@njoeror
@njoeror Год назад
Hi Tim, do you have an example where you show how to call ActivateItemAsync() from another ViewModel than the ShellViewModel ? If you want to change page without clicking in the menu, but by clicking on a button in the content of a view ?
@mov4736
@mov4736 3 года назад
Why do we have two databases? I understand that one is autogenerated by EF to handle Auth while the other is for our data, but I don't understand why didn't we just put our data tables with the autogenerated database
@marklinton4567
@marklinton4567 5 лет назад
Thanks for the video Tim. Regarding the changes to ShellViewModel. Using the IoC static methods. Does that mean the line in the bootstrapper, where we add the container instance to itself, is now unnecessary?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Good question but no, we still need to add the container to itself.
@jeffmaness7242
@jeffmaness7242 5 лет назад
Hi Tim, thanks for another awesome video! I was wondering if you would please consider adding a feature so that when products ListBox gets focus, Remove From Cart is disabled. On the the other end, when you focus Cart ListBox, Add to cart should get disabled. It may be a small thing but it bugs me that the selected item remains in the ListBox after the control loses focus. Its hard to tell something is selected and feels like there is a chance for a user to accidentally remove something instead of adding or visa versa. It took a bit of work but I finally got this working by creating a couple props and methods in the SalesViewModel, and then binding the got focus event in the xaml wiht message.attach.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'll think about it. I'm not sure that the added complexities are warranted based upon the potential gain, but I'll think it through more. Thanks for the suggestion.
@timothywestern6488
@timothywestern6488 4 года назад
Okay I have gone through this 2 or three times to this point. One thing that's got me a couple of times, what happens if say the DB where th elogins was goes poof. FIgured out a way to fix it, but many did I have to wrestle a bit to fix it.
@IAmTimCorey
@IAmTimCorey 4 года назад
That would be an issue since recreating it won't create the same IDs for the same people. That will cause all of your existing records to be orphaned.
@CoderboyPB
@CoderboyPB 3 года назад
Haha, I am in Europe (Germany): But I have Dollar on the left side and Euro on the right side ... I am thinking about to extend the design model with pre formatted string Properties, like we did it in the Sales View Model. Because than I have on both sides the same formatting - and hopefully the same result ...
@IAmTimCorey
@IAmTimCorey 3 года назад
Sounds good.
@CoderboyPB
@CoderboyPB 3 года назад
@@IAmTimCorey Meanwhile I know why that happened: XAML uses the us-engl Culture per default, instead of the ToString function, which uses the preset of the local computer ...
@sergestevens6034
@sergestevens6034 3 года назад
@CoderboyPB You can change this in your XAML. Add "xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib" to the settings of the XAML. Now bind the Text property of the TextBlock etc like this : Text="{Binding Taxes, StringFormat={}{0:c2}, ConverterCulture={x:Static gl:CultureInfo.CurrentCulture}}" Thus way XAML will use the Culture of your operating system
@sebastiandhom7172
@sebastiandhom7172 3 года назад
@@sergestevens6034 thank you!
@nahco3994
@nahco3994 3 года назад
I know I'm a couple of months late to your comment, but you can also set the property Language="de-DE" on your shell window (or on each individual View control) in order to force a specific locale. This is necessary because WPF out of the box doesn't take the system locale into account for things like currency formats. If you don't want to hard-code it this way, I'm sure this property could also be data-bound to some property in the ShellViewModel. That way you could read it in from a settings file or something. Oh, and if you want the € sign displayed in front of the number, you can use "de-AT" instead. Because apparently for some obscure reason, this format is different for Austria than it is for Germany, even though both versions should be correct for both countries. But for consistency's sake it probably would be best to set the WPF controls to the same culture setting as the rest of your application, which will default to your system's settings unless specified otherwise.
@andywalter7426
@andywalter7426 5 лет назад
I have a question about the change you made where the IOC can use a Get command. Is that a static method? Because the only problem I would see with using a static method is its much harder to unit test. I had experiences where when using static variables in unit tests and you have several unit tests, then it gets really hosed.
@IAmTimCorey
@IAmTimCorey 5 лет назад
We don't need to test the IoC method itself but we did make it somewhat harder to unit test our class now, since the dependency comes from IoC. We will need to mock the IoC directly in order to replace that dependency. Otherwise, it should be fine.
@guntbert9709
@guntbert9709 5 лет назад
Good to watch - thank you. Is there a special reason why you didn't remove the obsolete database?
@IAmTimCorey
@IAmTimCorey 5 лет назад
It is a habit of mine to keep an old database around for a bit to be sure I didn't have any other important data in it before I got rid of it. In this case, though, I can delete the database at any time.
@guntbert9709
@guntbert9709 5 лет назад
@@IAmTimCorey makes sense. I'd suggest to rename it though -> something-obsolete... (Saves me from having to play the guessing game again later)
@SuperDre74
@SuperDre74 4 года назад
thanx again for yet another interesting video, but: 1.CashierId should really be CashierUserId so there can't be any confusion. 2.Renaming the EF database to 'TRMDataEF' would have been better, it makes sure both databasenames are next to each other in the SQL Server Object Explorer and more clearly says to which project it belongs. 3.Should have explained how to get to the Package Manager Console, but in the end... see point 4 4.Sorry to say this, but that was a lame try at migration of database.. Easiest (at least in this case) would have been to just rename the database name using the SQL Server Object Explorere and then the database filename under App_Data.. 5.Could have used ContentControl around the StackPanels to set the fontsize once instead of setting it in the TextBox each time. But I'm looking forward to watching the next video's.
@IAmTimCorey
@IAmTimCorey 4 года назад
Naming is one of personal preference in these cases. I'm not a big fan of those names but if they work for you, great. As for Package Manager, I've explained where that comes from a few times before but I'll try to remember to explain it next time. As for the migration, I had some type of bug in the system but I showed a workaround for it, which I'm fine with. It prevented showing a long, drawn-out debugging session. As for renaming the database, that's not a great option because that won't always be an option. If you don't have a database, that doesn't work. I'll add the content controls suggestion to the list for possible future improvements.
@canoKes
@canoKes 3 года назад
To 5: You can set TextElement.FontSize="14" on the first stack panel. All strings in the stack panel will inherit the value. I think they call it attached property, like Grid.Row or Grid.Column.
@andrewbelton6410
@andrewbelton6410 5 лет назад
Thanks for a great series. Had a minor issue on the currency display inside the item list box. Although in other areas my currency was displaying correctly to Rands (South African currency), inside that template it was displaying as dollars. It turns out that I needed to set the Framework language property in the OnStartUp method of the bootstrapper class: protected override void OnStartup(object sender, StartupEventArgs e) { FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage( CultureInfo.CurrentCulture.IetfLanguageTag))); DisplayRootViewFor(); } This seems to have solved the issue. If there is a better technique, please let me know.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thanks for sharing!
@aymanawadallah6948
@aymanawadallah6948 2 года назад
this is very late but first thank you for your great job second you dont need to delete migration you just had to enable migration in Configuration.cs bychnging false to true public Configuration() { AutomaticMigrationsEnabled = true; } and set it to false after finishing
@IAmTimCorey
@IAmTimCorey 2 года назад
Thanks for sharing!
@thegodtwon40
@thegodtwon40 4 года назад
Oh my goodness. Its been so long we since created that userid that I can't remember where to find it. Where can I look up my userid so that I can copy it and paste it into the appropriate table in my TRMData database?
@IAmTimCorey
@IAmTimCorey 4 года назад
You get it from the Entity Framework-created authentication database in the Users table.
@mohamaddjelouah9332
@mohamaddjelouah9332 5 лет назад
hi tim i would love to see some examples of implementing the material design thanks u
@IAmTimCorey
@IAmTimCorey 5 лет назад
It is on the suggestion list. Thanks!
@thegodtwon40
@thegodtwon40 4 года назад
I've got to the point where we run the enable-migrations and update-database commands in visual studio. After I delete the Migrations folder and run the app, everything runs the same for me as it does for you in your video. However, when I migrate to swagger and attempt to create a new access token, I am not getting response code 400 as you do in your example. Instead, I am getting response code 500, with no mention of an invalid grant. I get the exact same response code when I attempt to create my account from scratch in swagger. I've run the app numerous times and looked over my code and I can't figure out what is causing the problems I am having. Any suggestions on how to proceed would be greatly appreciated.
@IAmTimCorey
@IAmTimCorey 4 года назад
It sounds like maybe you have a database issue but I'm not sure. Try debugging the application and capturing the error before it comes back as a 500 (which doesn't tell you much). See what that error tells you.
@estepor
@estepor 4 года назад
I am not sure if I am forgetting something from a prior video, but why does the ShellViewModel use the static class IOC for the LoginViewModel dependency and not for the SalesViewModel? Could constructor dependency injection not be used for both (or the static IOC for that matter)?
@IAmTimCorey
@IAmTimCorey 4 года назад
We had to get multiple instances of the Login form so we couldn't reuse the same instance we get from the constructor.
@estepor
@estepor 4 года назад
@@IAmTimCorey Ah! That's right. Thanks for the quick reply and the great content!
@michaeleichner9797
@michaeleichner9797 4 года назад
Another great video. Tim, after I added the foreign keys to my database I went to the Team Explorer to stage my changes. When I did, I had two changes in my list of changes that you didn't have. One was to my SqlProj file, and the other was a .refactorlog file. I have a vague idea what the .refactorlog file is used for. What I am not sure is why did this file show up as a change for me, but not for you? I was wondering if this was because I am using Visual Studio 2017 instead of 2019? Thanks
@IAmTimCorey
@IAmTimCorey 4 года назад
My guess is that your .gitignore file does not have the same entries that mine does.
@michaeleichner9797
@michaeleichner9797 4 года назад
@@IAmTimCorey That's what's odd, my git ignore file has some minor differences to yours. None that I can explain why I had the refactor log and you didn't. From what I read it seems as if you should have had the refactor log as it's used to track database changes. I hate a mystery, but this is one I will have to live with at least for now. Thanks
@andrewthompson9714
@andrewthompson9714 4 года назад
I have a question - Is it prefable to tightly couple our ShellViewModel to a static call (IoC) instead of a SimpleContainer instance (Which can more easily be swapped out later?)
@IAmTimCorey
@IAmTimCorey 4 года назад
I'm not sure I see the difference.
@andrewthompson9714
@andrewthompson9714 4 года назад
@@IAmTimCorey I think the difference would come if you had an interface for the container
@hellyworld9325
@hellyworld9325 3 года назад
After refactoring, my login doesn't work now. It throws an exception System.InvalidOperationException "Sequence contains no elements". But it says I'm a registered User when I reregistered after database clearing. And gives me an Auth token. Then when I try to pass in that token at User Get /api/User route it also throws that exception.
@IAmTimCorey
@IAmTimCorey 3 года назад
You can fix this, just break it into small steps. If you use version control, back out the refactoring and start over. Either way, break it into small changes and test after each. You got this!
@umblnc
@umblnc 3 года назад
The reason is that after recreating the user in the new EFData database, the new User Id doesn't match the User Id in the existing TRMData Database. It is also fixed later in the video.
@karatekid559
@karatekid559 4 года назад
Hello Tim is the change of "DefaultConnection" to "EFData" just a cosmetic change? I would like to skip it rather than risk breaking anything. Also I swapped the _container for IoC, but is there any benefit performance wise or is that also just cosmetic. Just trying to learn as much as I can. Thank you for any response.
@IAmTimCorey
@IAmTimCorey 4 года назад
Yep, just cosmetic and IoC is cleaner.
@davidmagerman4553
@davidmagerman4553 3 года назад
A tip - Embrace GIT for version control + make changes with confidence. Later, (if the need arises) you can debug by reviewing the delta and (worst case) undo changes that caused you grief.
@ueberbrot5875
@ueberbrot5875 4 года назад
Great series! I have two questions: 1. Did you launch Visual Studio with admin privileges? I had to relaunch Visual Studio with admin privileges for the migration and update command in the Package Manager Console (@20:40). What Max VelDink said i did not try for this problem because using admin rights fixed that for me. 2. The currency in my country is Euro (€). You said that based on your knowledge it should switch to the currency dependent on the information from the machine (@37:10). For the SubTotal, Tax and Total it works. I get the € sign and its formatted properly. But the per item price under the item name is in US-Dollers. How would i change that?
@IAmTimCorey
@IAmTimCorey 4 года назад
Nope, I didn't need to escalate the VS privileges. As for the item price, I think that has to do with the formatting of the box. I believe someone else fixed that here but I can't remember the exact fix.
@ueberbrot5875
@ueberbrot5875 4 года назад
@@IAmTimCorey thanks for the information. Silly me...found it in the comments. Must have read over it. Thanks.
@marekott4432
@marekott4432 4 года назад
Hi Tim, what do you think about TDD in practise? Is applications like this a proper one for that strategy?
@IAmTimCorey
@IAmTimCorey 4 года назад
I find that unit testing is a valuable tool (that I want to get into this project but I purposefully waited to do) but I am not fully sold on TDD.
@Doggeti
@Doggeti 4 года назад
IAmTimCorey Robert Martin once compared unit testing to double-entry bookkeeping. In my opinion writing tests after the fact is dangerous. One might simply forget it once the production code seems to be complete. To me it feels like waiting for adding the second entry in bookkeeping until the end of the week. Every good bookkeeper would laugh at that idea. In the same way a good developer should regard writing production code and unit tests as an atomic process. TDD enforces this. Also it makes you think about your production code from the perspective of a consumer of that code right from the beginning. I would like to hear your thoughts on why you are not fully sold on TDD.
@objectaware5296
@objectaware5296 5 лет назад
@16:58 Changing the connections string name to "EFData" is horrible! It doesn't tell what the connection string is connected to. It should so that anyone looking at the code can have an educated guess as to what data is being referenced. In this case, it is a user login security database. The ORM (EF) being used is not relevant. @28:22 Changing to a Linq statement is a costly change. I used a Stopwatch to measure the ticks required to and got the following on initial display of the cart. Linq: 15740 Foreach: 88 Linq: 201 Foreach: 38 As you can see Linq does get faster but rarely beats out the foreach loop. Linq: 3123 Foreach: 82 Linq: 209 Foreach: 42 The thread 0x18dc has exited with code 0 (0x0). The thread 0x54d4 has exited with code 0 (0x0). Linq: 50 Foreach: 43 Linq: 61 Foreach: 54 I pointed this out once before when a foreach was changed to a Linq statement Linq can be expensive to use.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Good feedback on the database name. I should have chosen something a bit clearer. For me, I only use EF for authentication but I should have called it AuthDB, not EFData. Maybe I'll adjust that in a future video. As for the LINQ speed issue, good point. I try to highlight different ways of doing things but I should also mention the speed issue. My guess is that because I did two extension methods instead of doing one "full" LINQ statement that it was slower. I'll have to look into it.
@99MrX99
@99MrX99 5 лет назад
@@IAmTimCorey Also for the database name, wouldn't it be good if the name would make clear to which application it belongs, e.g. by calling it "TRM_AuthDB"?
@objectaware5296
@objectaware5296 5 лет назад
@@IAmTimCorey I have not looked into it either but the predicate clause has to have a build up and tear down. I expect that to be the case.
@objectaware5296
@objectaware5296 5 лет назад
@@99MrX99 IMHO no. Real world applications normally end up using a central store (Active Directory) or an SSO (single sign-on) using OAuth or SAML (becoming obsolete) so why rename it at all for a dev project.
@thorton70
@thorton70 3 года назад
How could you add EDI using cXML and punch out? Yeah, got that kind of project and can't find info or resources to guide me.
@IAmTimCorey
@IAmTimCorey 3 года назад
I don't have an example of that, sorry.
@thorton70
@thorton70 3 года назад
@@IAmTimCorey thanks, figured it out. Thinking about adding it to TimCo app so it can do EDI.
@roycelithgo3968
@roycelithgo3968 4 года назад
enable-migrations didn't work for me initially. I had to follow the EF re-installation following the solution found here on Stack Overflow: stackoverflow.com/questions/10411529/package-manager-console-enable-migrations-commandnotfoundexception-only-in-a-spe
@IAmTimCorey
@IAmTimCorey 4 года назад
Interesting. Thanks for sharing.
@grumpydeveloper69
@grumpydeveloper69 5 лет назад
I still don't like the nvarchar(128) for User.Id Yes there might be situations that you have to do a lookup in the User table but in most cases you will have already authenticated and the gotten the int Id value and stored that either in a session or cached it some other way. Each time you get back to a server call you could look it up there. There are also instances where you store the Int value from the Timco system in the tables used by the authentication system as a foreign (external) key. But mainly I don't like nvarchar(128) as a primary key, just like using guids is odd from a database perspective. How big will the overhead really be. In most cases yu9 will show a user name or label so you will have to query the User table anyway The only real overhead is if you can't store the int Id somehow and there are several good solutions for that
@IAmTimCorey
@IAmTimCorey 5 лет назад
Caching the userId and passing it along with the ID would be a security risk. If I was authenticated as Tim and got the ID of 1 back, I could just pass in 2 instead (with my valid token) and now all of my actions in the database would be logged as Jane instead of Tim. The token is the only thing you can depend on from the client. You must use that to identify the user each time. You can't trust the user to do the right thing. That means that every single call would need to look up the ID to then use it in any transaction. That will be more expensive than storing a GUID as the primary key for the user.
@grumpydeveloper69
@grumpydeveloper69 5 лет назад
@@IAmTimCorey I meant you could use the gud/nvarchar(128) to get a cached user object that would contain the integer key. I do not see any security risk as now you are using the key directly so using the key to look up a server cached value would decrease security. I did not want the request to also include a separate id, that would be redundant, less secure and not a good practice I agree.
@IAmTimCorey
@IAmTimCorey 5 лет назад
WebAPI is a stateless connection. That means that you can't cache the ID between calls. The only effective way to cache it would be on the client side, which I discussed is not safe. So, your only other option is to do the lookup each time a call is made.
@grumpydeveloper69
@grumpydeveloper69 5 лет назад
​@@IAmTimCorey Based on the key there is nothing to prevent the server running the webapi from caching in either a session state, database or external cache (redis) a session cache might not be usefull for scarsely used api's.
@onyebuchiboss
@onyebuchiboss 5 лет назад
Hi Tim, Any clue clue on why I am getting a Bad request, when I am trying to login from the Desktop UI, but logging in normal from the browser via swagger ?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Maybe you are not passing in the type during authentication or maybe you are calling a GET instead of a POST.
@Dame4Lyf3
@Dame4Lyf3 5 лет назад
@Victor, I had this same issue, ensure that your app is launching the browser. if not check that you have both started: DesktopUI and TRMDataManager. Right click Solution > Properties, check Startup Project for these to be set to Start.
@onyebuchiboss
@onyebuchiboss 5 лет назад
Hi @@IAmTimCorey , I am actually calling a POST method. During debug the password returns an empty string(I thought it should be a hashed value)?, and my fiddler wouldnt even pick up the webApi call. I followed this tutorial religiously, to now lose track like smh.
@ahmadkelany
@ahmadkelany 5 лет назад
@@onyebuchiboss 1. Ensure that on startup BOTH ui and manager project run as @Dame F said. 2. Ensure that the user id in the TRMData database user table is the same as the one in EFData database AspNetUsers table.
@TheDogfighter13
@TheDogfighter13 5 месяцев назад
Hey guys and @iamtimcorey , i could use some help , i was exhausted and managed to screw up the db (actual data in it) , is there a way for a sql project to revert to previous state with data in it , because now when i debug , as soon as api helper grabs the data , the model is empty and authorization is done on the empty instance and therefore fails... is there any way or tutorial on how to fix this or will i have to go from scratch and try to enter all the data in (first trough postman , then swagger and so on) (previous versions using git naturally dont work) Or could i manually enter User Id in both EFData and sql server because thats the place where i screwed up , would really apreatiate some help (btw i have all access pass but i don't just want to copy your code and i'm pretty sure that even that wouldn't actually fill in the data base) , once again please help before i start all over again.
@TheDogfighter13
@TheDogfighter13 5 месяцев назад
It always fails in APIHelper autheniticate it gets in proper username and password and IsSuccessStatusCode is false
@TheDogfighter13
@TheDogfighter13 5 месяцев назад
anyone? i can post entire github repo here but i think the data is the problem and i just don't even know where to start
@TheDogfighter13
@TheDogfighter13 5 месяцев назад
well unless i start from scratch but that's a lot of work and @IAmTimCorey told us multiple times not to delete and start from scratch
@IAmTimCorey
@IAmTimCorey 5 месяцев назад
You cannot roll back the data in a database, no. You will need to fix it manually. My guess, though, is that you could fix it by modifying the actual data directly in SQL rather than trying to start over. Use SSMS to modify the data manually to fix it.
@TheDogfighter13
@TheDogfighter13 5 месяцев назад
@@IAmTimCorey Thank you so much , i'll try using SSMS , i tried manualy to fix it only trough visual studio so far , but the longer i think about it the longer it seem that i copied the wrong id , so i might at least go trough quite a lot , but i'll do my best , if i use swagger(and possibly postman) to create another entry and all the following steps would that possibly fix it because that's what i'm doing right now
Далее
Luiza Rasulova #luizarasulova
00:37
Просмотров 536 тыс.
The Hardest Challenge!
00:37
Просмотров 4,6 млн
Java Functional Programming | Full Course
2:22:15
Просмотров 560 тыс.
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 252 тыс.
Display Product Data - A TimCo Retail Manager Video
1:17:22
Luiza Rasulova #luizarasulova
00:37
Просмотров 536 тыс.