C
C#2y ago
júlio

❔ Understanding project structure - Visual Studio ASP.NET Core

I was assigned a task, to split a big Web Service into smaller independent Web Services. The thing is, I only have the past 3 days of experience with working with C# and Web Services. That being said, I'm slowing learning my way into them, and now I would like to analyse the original project I have to split. The image is a snippet of the solution explorer. Could someone help me understand what each icon means? They all contain a bunch of stuff and files inside, so I'm not really sure if the icons are related to the contents, but I have to start somewhere. :)
2025 Replies
júlio
júlioOP2y ago
Here is the solution explorer expanded one level, maybe it might help to see a the contents.
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
helper and proxy are web projects (the globe symbol) UnitTestProject is a unit test project (contains your unit tests, aka automated code tests) the rest are class libraries
júlio
júlioOP2y ago
So in the web solution, helper and proxy are two separate projects?
Pobiega
Pobiega2y ago
Everything in the top image except web and Solution items are projects. not all projects are runnable on their own. You have two that are (helper, proxy).
Pobiega
Pobiega2y ago
júlio
júlioOP2y ago
Thanks 😅
Pobiega
Pobiega2y ago
So yeah, helper is a web project (just like your new one) its an older one thou, so its not written in the "minimal api" style, but rather using controllers
júlio
júlioOP2y ago
The proxy one is apparently obsolete, and no one really know what it's doing, it was made by some person that is no longer in the group So I''l leave that aside from now
Pobiega
Pobiega2y ago
Sure.
júlio
júlioOP2y ago
The biggest question I have currently is What are the Program.cs and especially the Startup.cs files Since the code in the Program.cs does not reflect the code that the tutorial taught me
Pobiega
Pobiega2y ago
like I said, this is an older project structure and most likely also using older .NET Framework
júlio
júlioOP2y ago
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;

namespace helper
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
//logging.AddConsole();
logging.AddDebug();
logging.AddEventSourceLogger();
logging.AddFile("Logs/helperApi-{Date}.txt");

})
.UseStartup<Startup>()
.Build();
}
}
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;

namespace helper
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
//logging.AddConsole();
logging.AddDebug();
logging.AddEventSourceLogger();
logging.AddFile("Logs/helperApi-{Date}.txt");

})
.UseStartup<Startup>()
.Build();
}
}
Pobiega
Pobiega2y ago
while your new project uses the much more modern .NET
júlio
júlioOP2y ago
I see. So what weirds me out is that, no route is done here All the routing is done is the Controllers
Pobiega
Pobiega2y ago
yes. Thats how controllers work.
júlio
júlioOP2y ago
Well
Pobiega
Pobiega2y ago
If you look in Startup.cs thats where you see most of the configuration including the line that maps the controllers 🙂
júlio
júlioOP2y ago
maybe by this method
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
Pobiega
Pobiega2y ago
the program/startup split is an older pattern that has been merged into a single file in the new ASP.NET versions yup, that method "replaces" your builder.Services... stuff in your new one
júlio
júlioOP2y ago
I see... This might be a silly question but does Dao mean anything special to you?
Pobiega
Pobiega2y ago
Data Access Object?
júlio
júlioOP2y ago
Yep I never really understood that Isnt that the point of a Controller
Pobiega
Pobiega2y ago
¯\_(ツ)_/¯ Its a pretty generic term It may or may not be the same thing as a DTO (Data Transfer Object)
júlio
júlioOP2y ago
I see Looking at code that apparently is very outdated and having to separate everything is weird I never know if I should copy paste everything or re write it to modern code
Pobiega
Pobiega2y ago
A rewrite might take a very long time. you said it was several thousand LOC per library
júlio
júlioOP2y ago
Going back to the structure, inside the helper project, what would the Services folder contain?
Pobiega
Pobiega2y ago
thats not trivial to rewrite, especially not when you are new to C#
júlio
júlioOP2y ago
yep I agree
Pobiega
Pobiega2y ago
Services is one of those words that dont really have a meaning its most likely just a bunch of classes that contain logic
júlio
júlioOP2y ago
So there are 2 weird folders, Logs and wwwroot. They have like a ghost-folder icon thing Does that mean anything?
Pobiega
Pobiega2y ago
means they are empty but force-included in the project or hidden, might be that too you can open the .csproj and see but Logs is likely a placeholder folder to store logs created during execution logging.AddFile("Logs/helperApi-{Date}.txt");
júlio
júlioOP2y ago
<ItemGroup>
<Folder Include="Logs\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Logs\" />
<Folder Include="wwwroot\" />
</ItemGroup>
Pobiega
Pobiega2y ago
wwwroot is a special name
júlio
júlioOP2y ago
Ah yes
Pobiega
Pobiega2y ago
its the "root asset folder" for a webprogram its where your static stuff goes, I'd wager but since this project doesnt have any... its empty
júlio
júlioOP2y ago
Well, we dont reply Razor pages
Pobiega
Pobiega2y ago
I have not done .NET framework development since 2016, so its a bit rusty
júlio
júlioOP2y ago
It's fine, hey you know much more then me thats for sure So they told me here to do something They told me to set up a VM running windows (they want to use kubernets in windows) oh btw, i talked again with the boss and he told me (regarding IIS and Kubernetes) that IIS would not be managed by Kubernetes there would be the IIS and the kubernetes would run bellow it, i think he just forwards tragic to the services? idk would have to read more about it when the time comes Anyways, set up a VM running windwos and to run the Service as is, in it and then to try and idk delete certain parts and see what happens If I installed visual studio in the VM, that would be cheating right? I think the hole point is to have a machine without dependencies If I install vs then... I would have everything there? Actually Would I be able to put the service in a container since the code is kind of old? So many questions going trhu my head.... I need to step back a bit i think Thanks for the patience so far.
Pobiega
Pobiega2y ago
This makes no sense. IIS would then effectively be a single point of entry, kind of like an API Gateway... but much slower than an actual API Gateway. and how would it "contact your kubernetes", the entire plan there was to run the gateway and the load balancers in the cluster so they can handle all that invisibly you CAN remove the gateway, but you will need a load balancer for each service INSIDE the cluster or you will not get any auto scaling running .net framework on windows in a container? I have never done this. I've never worked with windows containers at all.
júlio
júlioOP2y ago
ISnt the ASP.NET Core cross platform? Should be fine I think
Pobiega
Pobiega2y ago
the closest thing Ive done is run Docker for Windows in WSL mode (running on the windows subsystem for linux) Core is. Your old stuff is NOT using core. thats on good ol' windows only specific .NET Framework
júlio
júlioOP2y ago
How can you tell? Just so I know how to show to the people above me So I would have to rewrite the whole thing? panic installs
Pobiega
Pobiega2y ago
I can tell by looking at the structure of the project. You can tell by looking at the .csproj files
júlio
júlioOP2y ago
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
This is bad, isn't it Arent we like on the 7.0 version
Pobiega
Pobiega2y ago
It's.. actually not. It's not the latest, but it's a lot better than framework 4
júlio
júlioOP2y ago
Wait, 3 is better then 4? Dont the numbers go up?
Pobiega
Pobiega2y ago
framework is old. Look up .net version history It's framework 1 - 4, core 1 - 3, then .net 5 to 7
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
That's specifically framework you are watching Anyways, got a meeting, bbl
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I see... good luck and thanks for the help so far :) So, a few questions regarding the target framework When you say this, is there something I can do? Would I have to rewrite the hole code, or would just making a .net core project and pasting existing code solve this issue?
Pobiega
Pobiega2y ago
Well, it looks like it actually is using core, just an old version. You could try updating it to .net 6/7
júlio
júlioOP2y ago
Yeah, I was looking thru the .csproj and some stuff says Core in them This is kind of confusing honestly Evrything is so similar
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="3.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0-dev-00037" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="3.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0-dev-00037" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
From what I saw, only .NET Core 7.0 is cross-platform
júlio
júlioOP2y ago
júlio
júlioOP2y ago
So it is using Core just not the most updated version
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Can it really be this easy? Well, a bunch of errors But It runs regardless?
Pobiega
Pobiega2y ago
Unlikely. There will be breaking changes
júlio
júlioOP2y ago
Severity Code Description Project File Line Suppression State
Error NU1201 Project helper is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Project helper supports: net7.0 (.NETCoreApp,Version=v7.0) UnitTestProject C:\develop\helperApi\web\UnitTestProject\UnitTestProject.csproj 1
Severity Code Description Project File Line Suppression State
Error NU1201 Project helper is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Project helper supports: net7.0 (.NETCoreApp,Version=v7.0) UnitTestProject C:\develop\helperApi\web\UnitTestProject\UnitTestProject.csproj 1
He didnt update the .csproj files hmmmm A lot of things he fails to find with the .NET 7.0
Pobiega
Pobiega2y ago
You need to update all the projects, except maybe the libraries (if they are .net standard)
júlio
júlioOP2y ago
Are all versions of .NET Core cross-platform?
Pobiega
Pobiega2y ago
So first, lets clear up a confusion .NET Core is version 1, 2 and 3.
júlio
júlioOP2y ago
Yes please 😅 I have many
Pobiega
Pobiega2y ago
.NET 5 6 and 7 are NOT called "Core" they are just .NET 5 6 and 7 ASP.NET Core however decided to keep the "Core" suffix... so thats version 1 to 7 All versions of .NET Core (1-3) and .NET (5-7) are cross platform
júlio
júlioOP2y ago
Okay, that makes more sense I mean, the explanation Not the names they used Xd
Pobiega
Pobiega2y ago
Yeah, the names are insane.
júlio
júlioOP2y ago
So speaking in terms of containerizing things Because that is a big factor here Would the version I choose, besides the framework ones, be a issue? Since they are all cross-platform
Pobiega
Pobiega2y ago
Right. Yea you should be able to containerize these, both as .NET Core 3 and post-upgrade (if you do that)
júlio
júlioOP2y ago
Okay okay, that is good, no need to diferentiate from windows containers or linux containers, correct?
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
I have never worked with windows containers. I do not know how they work.
júlio
júlioOP2y ago
but I would need to use windwos cointaners?
Pobiega
Pobiega2y ago
No. You would not.
júlio
júlioOP2y ago
isnt the point of cross'platform to run on every platform? Ah
Pobiega
Pobiega2y ago
Yes, but you dont need to run a program in a container you can run it outside a container on linux, mac or windows you can run it just fine inside a linux container, on a windows, mac or linux OS
júlio
júlioOP2y ago
Well yes, but since the end goal is to have kubernetes orquestrate the applications, i have to containerize them
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I ask alot of things
Pobiega
Pobiega2y ago
Sure. But remember that kubernetes doesnt run windows.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
So if you want to run this on k8s, you need to make sure it builds and runs fine on linux, and it likely will
júlio
júlioOP2y ago
What? Kuberenetes runs on windwos
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
^
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Iºm not trying to doubt what you are saying is just that I read things online and them people tell me otherwise and them my boss tells me otherwise and I just keep going back and forth
Pobiega
Pobiega2y ago
Dont host anything on windows, ever, if avoidable...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
its bad enough that you need to run a "gateway" on IIS already
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
he told me that, regarding IIS, they have more experience with it and want to keep it, and regarding Windwos, people here are more used to work with Windwos, but if I make a good argument he told me heºd consider
Pobiega
Pobiega2y ago
lol
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
But what are the big issues?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Because in Kubernetes website they say they can run on Windows, and that is what my boss sees k8s on windwos
Pobiega
Pobiega2y ago
your boss is an idiot. Period.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Well I still had to do what he tells me, I just have to convince him to change by making good arguments i'd be the maintainer of the windows cluster, if I got it implemented
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Okay, you will get way worse performance, way more node load, a MUCH harder time to find an ops team who can manage the cluster...
júlio
júlioOP2y ago
I have not even learned how to use kuebernetes
Pobiega
Pobiega2y ago
running your own cluster isnt trivial
KhaosVoid
KhaosVoid2y ago
This exactly. Much lighter weight containers, lower cost, can spin up more at a time, speed, security...the list goes on
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
nope He told me to learn kubernetes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
🤣
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Im dying here
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
that is a great question
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
cloud I think
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
fair
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
or just lambdas, since the entire reason behind wanting this in k8s is auto scaling
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
and to be frank here, @dryfish you seem to be quite new to this whole thing. Learning how to USE a k8s cluster is quite the undertaking... learning how to CREATE and MANAGE a cluster on your own is... a whole different story. This would be a big task for a senior devops engineer.
KhaosVoid
KhaosVoid2y ago
and if your company has subscriptions for it, I would definitely recommend looking into some Pluralsight videos to learn how to use/manage clusters
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Okay I went and talked with him I asking him about the cloud he is not using Azure nor Amazon nor Google He is using a cloud from our country network provider Now I have no cluie why that has anything to do with Kubernetes honestly reading all that I dont really know what to think anymore 😅 Im a junior developer I'm about to complete 3 months here, this is my first job So i'm learning things, everything is very new to me I dont believe in a impossible task However everywhere I look it makes it seem like this is impossible Xd This is all new to the boss too They didnt really give me a deadline Since it's a lot to do So maybe if I take things slowly I'll talking with him about using linux and not windows but could you please expand a bit more on what role the cloud provider has to do with Kuberenetes? I though Kubernetes is just something I ran on the computer, that managed containers
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Kubernetes isnt a "program" as such.. its a group of computers (individually called nodes) connected in whats called a cluster. You talk to the master node and tell it that you want 3 instances of some container to be ran. The cluster then runs that on the nodes, according to your specifications. HUGE simplification here, obviously, but thats the gist the cluster takes care of restarting a pod (an instance of a container) that crashes, or if a node crashes etc there are then smart programs that interact with the cluster they are running in, like auto scaling load balancers they will run as a pod on a node, but automatically request more pods as needed if they are seeing high load Running your own cluster is hard, and since you have a local cloud provider, they likely offer "kubernetes as a service" already (my company runs on a similar solution) so we have a private cluster in a private cloud, and they have an entire team of ops/SREs who help manage it, and help us with stuff like k8s upgrades
júlio
júlioOP2y ago
Me too. I meant that I'm working here for 2 months and this month will make it 3. I was referring to the amount of time spend in the company Altice So a Cluster os a group of computers, each called a node, and inside the cluster there is a master node? So, if the cloud provider does not support a Kubernetes cluster, I'm... basically fucked?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
he is a dev and software arquitect
Pobiega
Pobiega2y ago
yes. specifically, each node in a cluster is a computer that runs an "agent" program that makes it part of the cluster. you can ask a cluster what nodes are currently available etc
júlio
júlioOP2y ago
and it would be 1 + the numebr of computers?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
1 being the master node
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
well sure, but computers start and stop.. including the master node so you usually have multiple masters
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I need to have a computer whos only job is to be the master node?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
if you operate your own cluster, yes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
but you really DONT want to operate your own cluster, if you can avoid it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So lets say the cloud provider supplied the cluster, I would just need to creat the machines inside, and tell which is which?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
you dont worry about nodes/masters etc at all, you just worry about deployments and pods
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
you pay for X nodes, usually
júlio
júlioOP2y ago
It would do the autoscaling for me?
Pobiega
Pobiega2y ago
like "I want a cluster with 6 nodes of this size" you can configure autoscaling in multiple ways since this is a HTTP service you want to scale, a load balancer would be a good idea it can keep track of number of requests that are ongoing and how long they are taking etc
júlio
júlioOP2y ago
So just so I can put things in prespective, lets say using kubernetes from scratch is 100% work, how much work would get off my shoulders if the cloud provided handled the cluster? because I'm not sure neither is my boss, that the cloud provider has kubernetes support
Pobiega
Pobiega2y ago
assuming your service is already written, tested and works? somewhere around 5-10% maybe
júlio
júlioOP2y ago
Only?!!
Pobiega
Pobiega2y ago
as in, 90% of the work is gone you have 10% remaining
júlio
júlioOP2y ago
OH okay
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I was scared for a sec
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
👀
Pobiega
Pobiega2y ago
don't worry, its a beautiful thing shared between 2 consenting adults... kubernetes management, that is
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Okay so I definitly need to communicate this with my bosss then I will try and see if I can get a link to it, the thing is its not a public thing iirc
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
https://www.altice-empresas.pt/solucoes/cloud-datacenter/cloud/servidores-privados It is btw this website is not english because this is my country provider
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Well they say they have a hybrid azure thingy and they wrote Kubernetes in a list so maybe Kuberenetes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
This day keeps getting better and better
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I think we need to talk to them and see if they have something for Kuberentes this might be a sily question, but what should I ask for specifically?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
managed kubernetes
júlio
júlioOP2y ago
If I asked "can you manage a kubernetes cluster for us"
Pobiega
Pobiega2y ago
yes
júlio
júlioOP2y ago
is this a silly thing to ask? oh ok
Pobiega
Pobiega2y ago
no
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
thats a good first question. they either can or they cant.
júlio
júlioOP2y ago
Is there some sort of documentation that backs up this cluster thing? Im scared they might ask questions I dont know the anwser to Is that good or bad? I feel so dumb rn
Pobiega
Pobiega2y ago
They might ask how many nodes or what kind of load you expect
júlio
júlioOP2y ago
WOuld I need N clusters, one for each Service?
Pobiega
Pobiega2y ago
no 1 cluster
júlio
júlioOP2y ago
Or N nodes, one for each service?
Pobiega
Pobiega2y ago
not one for each service you might need way more depends on load
júlio
júlioOP2y ago
How will I know how much I need
Pobiega
Pobiega2y ago
if you only run one instance of each service, 2 nodes might be enough. you need to know the average and peak load of your services, more or less
júlio
júlioOP2y ago
what is the units we are talking about here? I could ask for that inforamtion
Pobiega
Pobiega2y ago
whatever makes sense. execution time per request, number of requests per second is there high CPU load, or IO load?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeah, that will tell them I know my stuff XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see, lightly touching the subject
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I didnt pick up aggression from the text honestly
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Noted.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
kekw
júlio
júlioOP2y ago
LMAO
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
THre is another side to this so the company i work in is the second biggest customer they have
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
and we have a close relation with them apparently like we have direct access to the people in charge and whatever I'm afraid that if they dont support Kubernetes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
my boss wont look for alternatives cause he might be too found of them idk
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah xD i did that too
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
so... more dollar?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
yes, probably
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
azure stack is expensive
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
this whole conversation just feel like something outside of my area lmao
Pobiega
Pobiega2y ago
this might all be getting way ahead of yourself tbh
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
make your services.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yep lol I still have to split the godammn things in the first place...
Pobiega
Pobiega2y ago
since you are replacing a single IIS server running all 6 services, you likely dont need that many VMs tbh
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeah and if I solve every problem i'll be king of the world, but do I want that? My goal is to be a teacher, I'm not really a money person. I'll still learn the things tho, it's just not my mindset, to "grow and earn more", it's just to "grow"
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
btw
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
@Pobiega and I were talking the other day, regarding IIS I asked my boss and his idea is the following He wants to use IIS and for that to be external to Kubernetes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
now I dont even know how any of that even works but does that make sense?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I talked with him about using Kestrel but he has a lot of knowledge on IIS and they work with it for a long time thats basically it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well, it would be eventually
Pobiega
Pobiega2y ago
they have a single webservice running on IIS right now
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
its slow. they want to make it faster and split it so it can be scaled individually
júlio
júlioOP2y ago
this
Pobiega
Pobiega2y ago
it currently handles ~6 "subservices"
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
its not chill
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
so, these 6 subservices are to be made standalone asp.net services thats where k8s came into the picture, to be able to scale this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
exactly. BUT
júlio
júlioOP2y ago
yeah, and to allow different kinds of deployment
Pobiega
Pobiega2y ago
here came the boss and said "I dont trust this Kestrel stuff, I like IIS, I want to use IIS" "oh and also, I want a single point of entry to all the services" I had previously suggested using an API gateway inside k8s for this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well actually, the cloud provider would handle that
Pobiega
Pobiega2y ago
how on earth?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
yes
júlio
júlioOP2y ago
if I understood things correctly, the cloud provider actually sends the requests to the correct routes
Pobiega
Pobiega2y ago
So they operate an API gateway
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
He told me not to worry about it, is what im trying to say\
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
there are more then 3 confusions here for sure, atleast on my side
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
The colud provider, assuming it would handle the cluster for us, would also take care of that, correct?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
which I would have to configure?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
HmmNoted it normal to feel like i'm completly lost?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Okay, just making sure
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So that times 6
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
maybe after I figure out how to split the service into smaller ones, I can ask my boss for a team since that is a lot to maintain or atleast seems like a lot
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well atleast its well documented i guess
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the anoying thing is taht you need to understand wtf u're doing
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
right know most of the stuff mentioned here rings no bells, but i'm slowly kind of getting the overall concepts which is nice
Pobiega
Pobiega2y ago
don't worry about k8s right now get your services up and running
júlio
júlioOP2y ago
yes that is probablty the best advice
Pobiega
Pobiega2y ago
once you have 6 individual working services, then you worry about deployment
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
^
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeah I agree, do you recomend someone for this kind of situations? does kubernetes offers some sort of support line for this?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
"to ask about kubernetes, you must know about kubernetes"
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
sad part is that I am
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
He legit just told me this "we will setup a VM for you to run kubernetes in, get it to manage a few containers, and them we will put that online" I was like "damn okay lets do this" now im like ".... :( "
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
im not planning on leaving, I jsut started :P Its my first job actually
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
No time limit so far
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
THe service is alreaddy running
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I just have to split it into smaller services
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the cloud provider hosts the service currently
Pobiega
Pobiega2y ago
probably a VM
júlio
júlioOP2y ago
yes a VM
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yes sir
Pobiega
Pobiega2y ago
its an asp.net core 3.1 monolith
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yep, im also a beginner at C# so this is a bit of a challenge too
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I think I will make a call with the previous maintainer and ask him to help me run the service and show me how to interact
Pobiega
Pobiega2y ago
Just... run the service? its a web service should be just run and make http requests to it
júlio
júlioOP2y ago
Well most of the time i dont really knwo what im doing Can you help me with that? XD i sound ridiculous This is what I know how to do I know how to use Postman
Pobiega
Pobiega2y ago
open visual studio, click run?
júlio
júlioOP2y ago
to send requests Just like that? wont that like mess with the alreaddy running service? this question sounds so dumb
Pobiega
Pobiega2y ago
no its running on your computer
júlio
júlioOP2y ago
localhost right? ok ok I get it now i forgot about that
Pobiega
Pobiega2y ago
localhost refers to your computer at all times, yes or well, its technically the loopback network interface... but its close enough 🙂
júlio
júlioOP2y ago
Okay I actually was messing with the configs and now idk wtf I did but i broke the whole thing Ill make another clone and delete this one one sec i guess this is the embarassing weeks of the junior developer journey dont know shit, always screwing up network isnt really my speciallity tho im a c++, algorithms, low level guy im just learning about this whole web deal in more detail now funny thing is im actualy enjoying it its a fun challenge so far plus so far the community as been nothing but amayzing, you guys are the living proof i was honestly not expecting this much help and paciense from anyone really I have to thank you guys for that, alot
Pobiega
Pobiega2y ago
eh, you've been given quite the "junior task" this is way bigger than what is reasonable
júlio
júlioOP2y ago
originally I came here to program in Delphi
Pobiega
Pobiega2y ago
dodged a bullet there
júlio
júlioOP2y ago
it was also a language i never eard about frist 2 months were doing things in Delphi now they moved me to this project also new language for me, but way better documentation online Okay, I have a question
júlio
júlioOP2y ago
júlio
júlioOP2y ago
When I open the solution It alreaddy says IIS here when I create a new project, it says something like http or something Why does it say IIS here, what does it mean? does the solution come with the IIS? I didnt install anything besides visual studio
FusedQyou
FusedQyou2y ago
I believe IIS Express (not IIS!) is build in and is a way to host your application. I don't have much knowledge on it but it's very different to IIS You can check your launchsettings.json for the various profiles to use. If it's IIS, IIS Express, http, whatever, it will be defined there
júlio
júlioOP2y ago
IIS Express apparently
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So Iºm having a weird problem I run the thing
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I click on the green arrow that say IIS Express
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
It starts running When I try to communnicate with it I get error 500
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I think so I asked the previous maintainer what I was doing wrong He told me to debug lol so yeah not really sure what to do now is there something I could try? How do I even debug this thing 😩
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
So the link he gave me I asked him about what port was the service using, he didnt know, he sent me a link and the link works? idk But it gives me 500
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
The target framework of the project is .NET Core 3.0 I think Does that have anything to do with the problem?
júlio
júlioOP2y ago
Stack Overflow
HTTP Error 500.31 - Failed to load ASP.NET Core runtime
I'm having issues deploying .NET Core applications to IIS on a Windows 10 machine. When I deploy to IIS and navigate to the site I recieve the message: "HTTP Error 500.31 - Failed to load ASP....
júlio
júlioOP2y ago
What is a Hosting Bundle?
FusedQyou
FusedQyou2y ago
Why? You can set up IIS on your local pc. You just don't have valid certification. I used to have it so that my websites could be tested on an actual "valid" host
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
SSL certification
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
change the value of <TargetFramework></TargetFramework> in your appsettings.json file to <TargetFramework>net7.0</TargetFramework>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
"dont need" and "you never want to put IIS on your computer" are two completely different things Then don't begin with it 😄
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
Because I would love to actually understand why you're saying that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
wont that break things?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
It will, you tried it already
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Oh yeah right Well I tried changing the project not in the file directly
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
just try it and see, you can always change back to the other version if anything breaks
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
lol, what it worked?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
What is going on
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
All i did was refresh the browser
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Run In debug configuration
Florian Voß
Florian Voß2y ago
o.O
Pobiega
Pobiega2y ago
Not release
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oke
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Diferent kind of error now
Florian Voß
Florian Voß2y ago
show us
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
What does it say here?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
Because you probably have release there
júlio
júlioOP2y ago
FusedQyou
FusedQyou2y ago
And not debug
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
one second
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
FusedQyou
FusedQyou2y ago
The problem is fixed when you select debug instead of release. No need to select anything other than IIS Express
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
FusedQyou
FusedQyou2y ago
Do you have the .NET 7 SDK installed?
Florian Voß
Florian Voß2y ago
he does
FusedQyou
FusedQyou2y ago
I keep forgetting 7 is released
júlio
júlioOP2y ago
I do? Okay lol
FusedQyou
FusedQyou2y ago
Welp idk
júlio
júlioOP2y ago
I have no clue man I installed visual studio
MODiX
MODiX2y ago
tebeco#0205
share your full csproj
React with ❌ to remove this embed.
Florian Voß
Florian Voß2y ago
we saw that on an earlier screenshot
FusedQyou
FusedQyou2y ago
I'm guessing it's not able to load a .NET 7 feature
Florian Voß
Florian Voß2y ago
.
FusedQyou
FusedQyou2y ago
But idk
júlio
júlioOP2y ago
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Version>2.0.0</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="CGMiddleware\**" />
<Content Remove="CGMiddleware\**" />
<EmbeddedResource Remove="CGMiddleware\**" />
<None Remove="CGMiddleware\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="SSController.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Logs\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="3.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0-dev-00037" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Version>2.0.0</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="CGMiddleware\**" />
<Content Remove="CGMiddleware\**" />
<EmbeddedResource Remove="CGMiddleware\**" />
<None Remove="CGMiddleware\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="SSController.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Logs\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="3.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0-dev-00037" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GestcontactParser\GestcontactParser.csproj" />
<ProjectReference Include="..\HelperAt\HelperAt.csproj" />
<ProjectReference Include="..\HelperExtra\HelperExtra.csproj" />
<ProjectReference Include="..\HelperFCT\HelperFCT.csproj" />
<ProjectReference Include="..\HelperSS\HelperSS.csproj" />
<ProjectReference Include="..\HelperViaCtt\HelperViaCtt.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GestcontactParser\GestcontactParser.csproj" />
<ProjectReference Include="..\HelperAt\HelperAt.csproj" />
<ProjectReference Include="..\HelperExtra\HelperExtra.csproj" />
<ProjectReference Include="..\HelperFCT\HelperFCT.csproj" />
<ProjectReference Include="..\HelperSS\HelperSS.csproj" />
<ProjectReference Include="..\HelperViaCtt\HelperViaCtt.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
:(
FusedQyou
FusedQyou2y ago
You're kind of behind on versioning mate
júlio
júlioOP2y ago
I didnt write any code myself, this is the current service code
Pobiega
Pobiega2y ago
This is a core3.1 program
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Just like that? I can just delete things?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
As long as it works, i dont even care anymore
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
if you wanna update all of these to the latest version you can either use nuget update YourSolution.sln or Update-Package
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
just do this instead of looking for each package seperately
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
I don't think that will get rid of all these obsolete packages
júlio
júlioOP2y ago
I got code errors after applying the changes
Pobiega
Pobiega2y ago
Ofc you did
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Severity Code Description Project File Line Suppression State
Error CS1061 'IApplicationBuilder' does not contain a definition for 'UseResponseBuffering' and no accessible extension method 'UseResponseBuffering' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?) helper C:\develop\helperApi\web\helper\Startup.cs 113 Active
Severity Code Description Project File Line Suppression State
Error CS1061 'IApplicationBuilder' does not contain a definition for 'UseResponseBuffering' and no accessible extension method 'UseResponseBuffering' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?) helper C:\develop\helperApi\web\helper\Startup.cs 113 Active
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2y ago
tebeco#0205
Microsoft.AspNetCore.Buffering is dead and never ever got released
React with ❌ to remove this embed.
FusedQyou
FusedQyou2y ago
Looks like a reference to what TeBe mentioned
júlio
júlioOP2y ago
I dont know, I didnt make the code
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
What was its use? Before you remove something important lol
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I wanna cry
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So what now.... I can't run this?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseResponseBuffering();

app.UseRouting();
app.UseCors();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseResponseBuffering();

app.UseRouting();
app.UseCors();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
It was used here In the Startup.cs file
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
integrality?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
misty
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
How would I know how to answer that...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
there are some hardcoded sus things to share, yes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
sure
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
God damn it
júlio
júlioOP2y ago
I think i didnt leak anything
FusedQyou
FusedQyou2y ago
hardcoded connection string 🥹
júlio
júlioOP2y ago
Imma go on a small break, ill be back in 15 minutes, all this stuff im making me hungry brb brb
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
I'm oh phone, summarize it for me plz 🙂
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Hahaha
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
so, tiny summary about what this app is
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
its an asp.net page that "creates and uses APIs" for webpages that dont have them, that dryfish's team needs to interact with including stateful sessions their delphi app sends requests here, the app does some http calls and uses HAP to parse the html and extract the values it needs, then returns a json response to their delphi app
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
kinda, but on demand ie, it doesnt scrape, it just... uses a non-api webpage to do things its not just GET stuff
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
I've not seen any more code than you have, just talked with dryfish a lot lately :p
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
also, poor dude is a junior dev, brand new to C# and .NET and been handed this .NET Core 3.1 monolith and asked to split it up
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh no sorry you told me to hide sensitive information So i did a funny and used facebook there
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
my bad
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
ntp04.oal.ul.pt this is the original link
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Hmmm Not really, just the declaration atleast that I see Program.cs doesnt use that either so idk
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oh wait the constructor sets the variable
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I dont know :( I can do a word search in all files
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
BaseControllers.cs
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
get ready to depress
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
So
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
its 300 line of code
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I think so
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
That would be something I should know how to answer Im going to say no wait
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
let me first explain to you what people explained to me that this did Delphi client sends a request to the service the services gets the html reply of some website, does some parsing and return in JSON format thats it in essence So id say no Razor buisness
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
remember, this is .netcore3.1
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeah we dont have Views here They called it BaseController
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Hey man I also wish they did things right expesially since everything i find here is differente then the things i find online and everything is outdated
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
and also i dont understand most things that are here honestly after all this talk i have no clue how this is running
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the biggest file i have to split is a 6k lines of code file its also the most important one its also the one I undestand zero about i just wanted it to run so that I could see how it works by interacting with it apparently cant even do that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I removed the oens you marked red and updated the ones with green this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
O I'll try that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Its runnig
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
It did a bunch of things runnig just Update-Package
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
It's okay, not a problem!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
that looks good
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I though about that but
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So I add file by file? Eventually reaching full code? on a fresh .net 7.0 project okay Wont that be bad? To replicate old code on a modern .net idk
Pobiega
Pobiega2y ago
that wont really work, thats not how code works files refer to other files
júlio
júlioOP2y ago
So what did TeBeConsulting mean?
Pobiega
Pobiega2y ago
create a new .net 7 project and "translate" the code from your startup.cs into the new format, then try and get it running. It will need a few packages.
júlio
júlioOP2y ago
Ohhhhhh okay, that seems better but i'm going to be honest, I'm going to need help for thtat
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
so I have a new project in it I have a Controllers folder you are saying to move the code that was on the previous project Controllers folder, into the new project Controllers folder, correct?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the jsonserive in the Services folder? (im just trying to understand where te thigns you mentioned are)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
that sounds alien to me honestly bad thing about this is they did not make any documentation about the service and the original person that made it is gone so theres that
Pobiega
Pobiega2y ago
time to get your hands dirty
júlio
júlioOP2y ago
yep XD
Pobiega
Pobiega2y ago
open up the file, and get going
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
using Microsoft.AspNetCore.Mvc;

namespace helper.Services
{
public class JsonService
{

// private JsonSerializerSettings _jss = new JsonSerializerSettings {
// NullValueHandling = NullValueHandling.Include
// };

public JsonResult ToJson(object obj)
{
//return JsonConvert.SerializeObject(obj, _jss);
return new JsonResult(obj);
}

}

}
using Microsoft.AspNetCore.Mvc;

namespace helper.Services
{
public class JsonService
{

// private JsonSerializerSettings _jss = new JsonSerializerSettings {
// NullValueHandling = NullValueHandling.Include
// };

public JsonResult ToJson(object obj)
{
//return JsonConvert.SerializeObject(obj, _jss);
return new JsonResult(obj);
}

}

}
cloud provider
júlio
júlioOP2y ago
Okay fresh start here we go
júlio
júlioOP2y ago
I'm hyped :D feeling confident
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
of the JsonService.cs file, yes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
xd is it bad?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Ctrl+Shitf+F time
Pobiega
Pobiega2y ago
dear god this is cursed
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Its used in a few places i guess
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
thats it pretty much Its used in some controllers I think that Some websites alreaddy reply in JSON format so maybe its for the ones that dont? or do? I dont know :( I'm asking the previous maintainer maybe he has something to say about it
Florian Voß
Florian Voß2y ago
json is THE data interchange format of the internet if you will. Most API will give you json back. XML is still more widely used as of right now iirc but that will change soon
júlio
júlioOP2y ago
yes, but some of the websites do not reply in JSON and we need to craft a JSON responce after parsing the HTML responce
Florian Voß
Florian Voß2y ago
its for your own responses that your controller endpoint sends when it gets called probably
júlio
júlioOP2y ago
but if that was the case, every controller should have a JsonService, no? only 2 have out of
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
11
Florian Voß
Florian Voß2y ago
do those other 9 controllers return json too? cuz if not then why should the JsonService be used by them?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
enjoy!
Pobiega
Pobiega2y ago
no, because you dont need it to return json see what it does
júlio
júlioOP2y ago
what is "it"?
Pobiega
Pobiega2y ago
its literally just a return JsonResult(object)
júlio
júlioOP2y ago
o
Pobiega
Pobiega2y ago
júlio
júlioOP2y ago
Yes
Pobiega
Pobiega2y ago
that service is 100% pointless it looks like at some point it was only mostly pointless, from the commented out code
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Wait, I dont specify a constructyor Is this a c# thing?
Pobiega
Pobiega2y ago
C# has implicit parameterless constructors
júlio
júlioOP2y ago
but hes passing it a object, whatever that means
Florian Voß
Florian Voß2y ago
no constructor == invisbible default constructor
júlio
júlioOP2y ago
Im talking about return new JsonResult(obj); Its constructing a JsonResult with a object but I dont define anny constructor that takes in a object
Florian Voß
Florian Voß2y ago
JsonResult is not a type from you, its from .net / asp.net
júlio
júlioOP2y ago
Ohhh Lol so yeah this is pointless tf ugh lmao the maintainer just replyed "It's useless" ahahaha sO whY is It sTilL herE
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
XD So the positive thing iiiis I can skip over this file! One less file to worry about The next one is MadExceptParses.cs but i think I need that one oh well actually its not used anywhere in the project just in the file where its declared omg imagine if I went thru the files and in the end only like 10 files actually did something, the rest 40 files where useless XD It's used in unittest project not in the helper one, so I wont need it for this Okay, this is great, the Services folder is done... Maybe I can start with the Controllers now?
Florian Voß
Florian Voß2y ago
ehhhm I would suggest the order repositories > services > controllers because services depend on repositories and controllers depend on services
júlio
júlioOP2y ago
the services folder is done tho it had 2 files, one was useless and the other was not behing used lol i smirked writting this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Database?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
i dont think this is using a database
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
i... do?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
entity framework core entity means database okay but I dont make any crud here
Florian Voß
Florian Voß2y ago
no
júlio
júlioOP2y ago
i just handle requests and parse
Florian Voß
Florian Voß2y ago
entity means, an object that is defined by it's identifier (id)
júlio
júlioOP2y ago
oh, usually entity means database stuff so i assumed
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
the word entities is commonly used in context of databases but the definition what an entity is is unrelated to databases
júlio
júlioOP2y ago
I see So how can I see the database Im apparently using?
Florian Voß
Florian Voß2y ago
anyway, i dont see any repositories in your solution explorer so i dont think a db is used in this project
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeah i dont think so either
Florian Voß
Florian Voß2y ago
i assume the author just added EFCore dependency without needing it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
where are you guys even seeing efcore?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Oh okayu
júlio
júlioOP2y ago
Florian Voß
Florian Voß2y ago
yes there is a reason to use repositories xd you seem to missunderstand the purpose of a repository. A repository abstracts CRUD operations against ANY data source. Whether that data source is an EF Core dbcontext or a file in the local file system is completely irrelevant
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Hmmmm
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yep
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Ill ask around
Pobiega
Pobiega2y ago
this is not the place or the time, but you are SO FUCKING wrong its not even funny
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
OKay I asked to the previous maintainer He told me the DB connection is for logging
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
He told me its loggs exceptions and to check BaseController
Florian Voß
Florian Voß2y ago
@Pobiega do you plan to enlighten me or not? You just call me out for being SO FUCKING wrong and leave it like that? Any place or time
júlio
júlioOP2y ago
sure, but hehe where is that?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
this is a help thread. you are not helping. But yeah,as tebe said, DbSet<> is a repo
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
and the take "there are no repos, thus there must be no database" is one hell of a take
júlio
júlioOP2y ago
using helper.Dao;
using Microsoft.EntityFrameworkCore;

namespace helper.Models
{
public class HelperContext : DbContext
{
private DaoNif _daoNif;

public HelperContext(DbContextOptions<HelperContext> options)
: base(options)
{

_daoNif = new DaoNif(this);
}

public DbSet<Nifs> Nifs { get; set; }
public DbSet<Analitycs> Analitycs { get; set; }

public DaoNif DaoNif
{
get { return _daoNif; }

}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}
}
using helper.Dao;
using Microsoft.EntityFrameworkCore;

namespace helper.Models
{
public class HelperContext : DbContext
{
private DaoNif _daoNif;

public HelperContext(DbContextOptions<HelperContext> options)
: base(options)
{

_daoNif = new DaoNif(this);
}

public DbSet<Nifs> Nifs { get; set; }
public DbSet<Analitycs> Analitycs { get; set; }

public DaoNif DaoNif
{
get { return _daoNif; }

}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
See, this is why I said "this is not the time or the place"
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
the EF Core repo debate is so tiring
Florian Voß
Florian Voß2y ago
right and thats the whole point behind Repository Pattern from my understanding... You create an interface that holds methods for CRUD operations. Then one implementation of your IRepository<T> where T : Entity might be using a dbcontext<T> as its data source. Another might be using local file system as its data source
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
... you dont get my point
Pobiega
Pobiega2y ago
why do you need an abstraction over your abstracted database?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
its fine to use repo over a file system
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
its fine to use it over... whatever. but not EF Core its already a repo
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
But srsly, take it elsewhere
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Stop it with the EF Repo shit
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
THIS IS A HELP THREAD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
take it to #database and never bring it up again thank you
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
You're going to cringe beware
júlio
júlioOP2y ago
using System;
using System.ComponentModel.DataAnnotations;

namespace helper.Models
{
public class Analitycs
{
[Key]
public long Id { get; set; }
public string Produto { get; set; }
public string Licid { get; set; }
public string Tipo { get; set; }
public string Versao { get; set; }
public string Versaoerp { get; set; }
public string Browser { get; set; }
public string Starttime { get; set; }
public string Username { get; set; }
public string Nempresa { get; set; }
public DateTime InsertDateTime { get; set; }
public string Location { get; set; }
public string Mensagem { get; set; }
public string Stack { get; set; }
public string Apikey { get; set; }
public string Ip { get; set; }

}

}
using System;
using System.ComponentModel.DataAnnotations;

namespace helper.Models
{
public class Analitycs
{
[Key]
public long Id { get; set; }
public string Produto { get; set; }
public string Licid { get; set; }
public string Tipo { get; set; }
public string Versao { get; set; }
public string Versaoerp { get; set; }
public string Browser { get; set; }
public string Starttime { get; set; }
public string Username { get; set; }
public string Nempresa { get; set; }
public DateTime InsertDateTime { get; set; }
public string Location { get; set; }
public string Mensagem { get; set; }
public string Stack { get; set; }
public string Apikey { get; set; }
public string Ip { get; set; }

}

}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh I can split
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
its 100 lines of code, its not that big 1 sec
using GestcontactParser;
using System;
using System.ComponentModel.DataAnnotations;


namespace helper.Models
{
public class Nifs
{
[Key]
public string Nif { get; set; }

public string Entidade { get; set; }
public string SituacaoActual { get; set; }
public string Morada { get; set; }
public string Localidade { get; set; }
public string CodigoPostal { get; set; }
public string Telefone { get; set; }
public string Telemovel { get; set; }
public string Fax { get; set; }
public string Email { get; set; }
public string PaginaWeb { get; set; }
public string Distrito { get; set; }
public string Concelho { get; set; }
public string Freguesia { get; set; }
public DateTime InicioDeActividade { get; set; }
public Decimal CapitalSocial { get; set; }
public Int32? Empregados { get; set; }
public string Cae { get; set; }
public string AreaDeActividade { get; set; }
public string Categoria { get; set; }
public string Socio1 { get; set; }
public DateTime LastUpdate { get; set; }
public string Apresentacao { get; set; }
public string ProdutosServicos { get; set; }
public string Marcas { get; set; }
public string PalavrasChave { get; set; }
using GestcontactParser;
using System;
using System.ComponentModel.DataAnnotations;


namespace helper.Models
{
public class Nifs
{
[Key]
public string Nif { get; set; }

public string Entidade { get; set; }
public string SituacaoActual { get; set; }
public string Morada { get; set; }
public string Localidade { get; set; }
public string CodigoPostal { get; set; }
public string Telefone { get; set; }
public string Telemovel { get; set; }
public string Fax { get; set; }
public string Email { get; set; }
public string PaginaWeb { get; set; }
public string Distrito { get; set; }
public string Concelho { get; set; }
public string Freguesia { get; set; }
public DateTime InicioDeActividade { get; set; }
public Decimal CapitalSocial { get; set; }
public Int32? Empregados { get; set; }
public string Cae { get; set; }
public string AreaDeActividade { get; set; }
public string Categoria { get; set; }
public string Socio1 { get; set; }
public DateTime LastUpdate { get; set; }
public string Apresentacao { get; set; }
public string ProdutosServicos { get; set; }
public string Marcas { get; set; }
public string PalavrasChave { get; set; }
public Nifs()
{
Nif = "";
Entidade = "";
SituacaoActual = "";
Morada = "";
Localidade = "";
CodigoPostal = "";
Telefone = "";
Telemovel = "";
Fax = "";
Email = "";
PaginaWeb = "";
Distrito = "";
Concelho = "";
Freguesia = "";
InicioDeActividade = DateTime.MinValue;
CapitalSocial = 0;
Empregados = 0;
Cae = "";
AreaDeActividade = "";
Categoria = "";
Socio1 = "";
LastUpdate = DateTime.MinValue;
Apresentacao = "";
ProdutosServicos = "";
Marcas = "";
PalavrasChave = "";
}
public Nifs()
{
Nif = "";
Entidade = "";
SituacaoActual = "";
Morada = "";
Localidade = "";
CodigoPostal = "";
Telefone = "";
Telemovel = "";
Fax = "";
Email = "";
PaginaWeb = "";
Distrito = "";
Concelho = "";
Freguesia = "";
InicioDeActividade = DateTime.MinValue;
CapitalSocial = 0;
Empregados = 0;
Cae = "";
AreaDeActividade = "";
Categoria = "";
Socio1 = "";
LastUpdate = DateTime.MinValue;
Apresentacao = "";
ProdutosServicos = "";
Marcas = "";
PalavrasChave = "";
}
public void Assign(Gestcontact info)
{
if (Nif != info.Nif)
{
Nif = info.Nif;
}

if (!string.IsNullOrEmpty(info.Entidade)) Entidade = info.Entidade;
if (!string.IsNullOrEmpty(info.SituacaoActual)) SituacaoActual = info.SituacaoActual;
if (!string.IsNullOrEmpty(info.Morada)) Morada = info.Morada;
if (!string.IsNullOrEmpty(info.Localidade)) Localidade = info.Localidade;
if (!string.IsNullOrEmpty(info.CodigoPostal)) CodigoPostal = info.CodigoPostal;
if (!string.IsNullOrEmpty(info.Telefone)) Telefone = info.Telefone;
if (!string.IsNullOrEmpty(info.Telemovel)) Telemovel = info.Telemovel;
if (!string.IsNullOrEmpty(info.Fax)) Fax = info.Fax;
if (!string.IsNullOrEmpty(info.Email)) Email = info.Email;
if (!string.IsNullOrEmpty(info.PaginaWeb)) PaginaWeb = info.PaginaWeb;
if (!string.IsNullOrEmpty(info.Distrito)) Distrito = info.Distrito;
if (!string.IsNullOrEmpty(info.Concelho)) Distrito = info.Concelho;
if (!string.IsNullOrEmpty(info.Freguesia)) Freguesia = info.Freguesia;
if (info.DataInicioActividade != DateTime.MinValue) InicioDeActividade = info.DataInicioActividade;
if (!string.IsNullOrEmpty(info.Cae)) Cae = info.Cae;
if (!string.IsNullOrEmpty(info.AreaDeActividade)) AreaDeActividade = info.AreaDeActividade;
if (!string.IsNullOrEmpty(info.Apresentacao)) Apresentacao = info.Apresentacao;
if (!string.IsNullOrEmpty(info.ProdutosServicos)) ProdutosServicos = info.ProdutosServicos;
if (!string.IsNullOrEmpty(info.Marcas)) Marcas = info.Marcas;
if (!string.IsNullOrEmpty(info.PalavrasChave)) PalavrasChave = info.PalavrasChave;
LastUpdate = DateTime.Now;
}
}
}
public void Assign(Gestcontact info)
{
if (Nif != info.Nif)
{
Nif = info.Nif;
}

if (!string.IsNullOrEmpty(info.Entidade)) Entidade = info.Entidade;
if (!string.IsNullOrEmpty(info.SituacaoActual)) SituacaoActual = info.SituacaoActual;
if (!string.IsNullOrEmpty(info.Morada)) Morada = info.Morada;
if (!string.IsNullOrEmpty(info.Localidade)) Localidade = info.Localidade;
if (!string.IsNullOrEmpty(info.CodigoPostal)) CodigoPostal = info.CodigoPostal;
if (!string.IsNullOrEmpty(info.Telefone)) Telefone = info.Telefone;
if (!string.IsNullOrEmpty(info.Telemovel)) Telemovel = info.Telemovel;
if (!string.IsNullOrEmpty(info.Fax)) Fax = info.Fax;
if (!string.IsNullOrEmpty(info.Email)) Email = info.Email;
if (!string.IsNullOrEmpty(info.PaginaWeb)) PaginaWeb = info.PaginaWeb;
if (!string.IsNullOrEmpty(info.Distrito)) Distrito = info.Distrito;
if (!string.IsNullOrEmpty(info.Concelho)) Distrito = info.Concelho;
if (!string.IsNullOrEmpty(info.Freguesia)) Freguesia = info.Freguesia;
if (info.DataInicioActividade != DateTime.MinValue) InicioDeActividade = info.DataInicioActividade;
if (!string.IsNullOrEmpty(info.Cae)) Cae = info.Cae;
if (!string.IsNullOrEmpty(info.AreaDeActividade)) AreaDeActividade = info.AreaDeActividade;
if (!string.IsNullOrEmpty(info.Apresentacao)) Apresentacao = info.Apresentacao;
if (!string.IsNullOrEmpty(info.ProdutosServicos)) ProdutosServicos = info.ProdutosServicos;
if (!string.IsNullOrEmpty(info.Marcas)) Marcas = info.Marcas;
if (!string.IsNullOrEmpty(info.PalavrasChave)) PalavrasChave = info.PalavrasChave;
LastUpdate = DateTime.Now;
}
}
}
Thats it
Pobiega
Pobiega2y ago
@Florian Voß I apologize for the harsh tone, just really tired of the EF Core repo "debate". Sorry.
Florian Voß
Florian Voß2y ago
@Pobiega no worries. Just hoping you're gonna explain it to me... Any place and time you wish
júlio
júlioOP2y ago
guys, im going home now, (im at workplace) buuut ill turn on the computer and reply from there regardless, thanky uo for the time and patience so far I'm really glad that you guys are helping me understand all this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
I believe TeBe just did. If that didnt satisfy you, a simple google search should put it better than I can. If that STILL doesnt satisfy you, go ask in #database why repo over EF is not only not needed but a bad idea.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
good morning, I took your advice actually, I got home, turned computer, saw that and was like "he's right" did some exercise, watched a movie, and took a sleep, now im woke and ready to face c# again ikr, dont they get that by default? i see
Pobiega
Pobiega2y ago
no, they will be null by default, not "empty string"
júlio
júlioOP2y ago
Oh I see By the way the connection string isnt really a link its just a word
Pobiega
Pobiega2y ago
Not being a link is expected, but literally just a single word?
júlio
júlioOP2y ago
well
Pobiega
Pobiega2y ago
or something like... Data Source=.;Initial Catalog=asd;User Id=sa;Password=asd
júlio
júlioOP2y ago
2 things happen yes that happens if var cs = Configuration.GetConnectionString("magicword"); returns null
Pobiega
Pobiega2y ago
magicword is just the connstr identifier for your configuration file
júlio
júlioOP2y ago
Ohh
Pobiega
Pobiega2y ago
and you apparently have a fallback for it which is weird imho, you shouldnt be able to start a program with a faulty configuration
júlio
júlioOP2y ago
var cs = Configuration.GetConnectionString("MagicWord");
if (String.IsNullOrEmpty(cs)) cs = @"MagicWords";
services.AddDbContext<HelperContext>(options => options.UseSqlServer(cs));
var cs = Configuration.GetConnectionString("MagicWord");
if (String.IsNullOrEmpty(cs)) cs = @"MagicWords";
services.AddDbContext<HelperContext>(options => options.UseSqlServer(cs));
This is the code flow
Pobiega
Pobiega2y ago
then again, this seems to be hacked in, and its "only for logging" yeah.
júlio
júlioOP2y ago
Logging exceptions apparently
Pobiega
Pobiega2y ago
that second string is your actual connstr that is used when nothing was written in the config file
júlio
júlioOP2y ago
but that string doesnt really have a link
Pobiega
Pobiega2y ago
why would it have a link?
júlio
júlioOP2y ago
its has a Server=BlaBlaBla\BlaBlaBla
Pobiega
Pobiega2y ago
it has a hostname most likely yes the Data Source usually in a SqlServer connstr
júlio
júlioOP2y ago
I dont have a Data Source
Pobiega
Pobiega2y ago
thats the contact details of your actual sql server
júlio
júlioOP2y ago
The tags I have are these
Pobiega
Pobiega2y ago
ok, Server is similar if not the same, it seems
júlio
júlioOP2y ago
Server=... Initial Catalog=... Persist Security Info=... User ID=... Password=...
Pobiega
Pobiega2y ago
júlio
júlioOP2y ago
I see
Pobiega
Pobiega2y ago
so the value you have there, that is the protocol/hostname/port of your sql server protocol and port are optional
júlio
júlioOP2y ago
yeah, no port is specified
Pobiega
Pobiega2y ago
you said it was x\y?
júlio
júlioOP2y ago
yes it feels like not sensitive information tbh but i have no clue
Pobiega
Pobiega2y ago
x is your hostname, y is your instance name
júlio
júlioOP2y ago
So to make a backup of the database (no clue how big it is btw), how could I access it? cant I just get the XML and make my own
Pobiega
Pobiega2y ago
you'd use something like SSMS or datagrip
júlio
júlioOP2y ago
are those built in VS?
Pobiega
Pobiega2y ago
nope and nope they are database management tools SSMS is the official one for sql server, and its free
júlio
júlioOP2y ago
oh lol turns out its in my computer alreaddy the ssms one login is alreaddy set...okay So I'm looking at the databases now out of curiosity, if i fuck around here, will I get fired or something? are these the live stuff?
Pobiega
Pobiega2y ago
could be, no way for us to know but likely not
júlio
júlioOP2y ago
or are these the local ones oh ok
Pobiega
Pobiega2y ago
depends on the hostname like, how much do you know about computers in general? it seems you are... very new to most things.
júlio
júlioOP2y ago
I know a lot about memory, algorithms, datastructures, and how the computer operates network wise I know how packets work but I never really learned a lot about network stuff database wise... I know CRUD operations, and how to create databases
Pobiega
Pobiega2y ago
but stuff like what a hostname is?
júlio
júlioOP2y ago
the computer name in the network?
Pobiega
Pobiega2y ago
correct.
júlio
júlioOP2y ago
That what i think it is Oh nice 😅
Pobiega
Pobiega2y ago
so given that you have the hostname of the db server, you should hopefully be able to know some stuff about it like, is it local (localhost, 127.0.0.1, .), on your local network (local. or .local (usually)), or external
júlio
júlioOP2y ago
.\MAGICWORD
Pobiega
Pobiega2y ago
there are no strict rules for naming, but hopefully it isnt just a random string . means its your local machine so this is a local database running on your computer
júlio
júlioOP2y ago
THat makes sense, because I regonize a bunch of databases here I interact with Delphi, and they were all local ones So if its local I can mess with it, no need to backup right? the thing is the magicword\magicword in the c# service didnt have a dot it wasnt like .\magicword but
Pobiega
Pobiega2y ago
you probably dont want to edit your structure, but the data should be safe to mess with
júlio
júlioOP2y ago
I think there is a easier way to address this I'll just ask someone XD 1 sec
Pobiega
Pobiega2y ago
You have quite the task ahead of you, but to be honest you can't really expect us to hold your hand throughout the entire thing, that should be your senior dev, mentor or similar - not a bunch of strangers on the internet.
júlio
júlioOP2y ago
Yes I agree
Pobiega
Pobiega2y ago
Your task should however be fairly straight forward, if somewhat complicated by the fact that the current version doesn't run. I don't think its that much work to get it running, but your lack of basic C# and ASP.NET knowledge is blocking you. So imho, try and learn enough C# so you can read the code. This will involve writing C# and experimenting with your API. Then, you can either try and get the existing thing running, or slowly porting it by reading+rewriting/copying parts as you go.
júlio
júlioOP2y ago
Yeah, its why I wanted to get the service running in the first place so that I could start experimenting with it to the thing keeps giving me 500 error
Pobiega
Pobiega2y ago
do you know what 500 stands for?
júlio
júlioOP2y ago
fast forward to now, im making a copy of a database? Xd stands for... error :p
Pobiega
Pobiega2y ago
"internal server error"
júlio
júlioOP2y ago
ohh So thats why
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
^
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
btw the database I cant mess with it, its not local I need to make a copy if I want to mess with it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
yeah so dont. change the conn str you have a local one set up so connect to that
júlio
júlioOP2y ago
I do?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
yes, you said so? when you started ssms
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I understand that the thing is In my local databases I didnt found one with the name in the conenction string
Pobiega
Pobiega2y ago
its just a log table iirc serilog creates it for you, if it doesnt exist so likely, its enough to make a blank db and change your connstr
júlio
júlioOP2y ago
how do I do a blank db? ugh
Pobiega
Pobiega2y ago
Come on
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
sorry I'll search online
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
ah right, the nif and stuff was in the context
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I do have a Audits folder inside a Security folder No clue if thats related to anything tho
Pobiega
Pobiega2y ago
not related
júlio
júlioOP2y ago
:/ wait In the tutorial I followed they used a memory database thingy like the database stayed in memory
Pobiega
Pobiega2y ago
You need to learn a bunch of stuff. Like how databases work, what EF Core is and its basics, etc
júlio
júlioOP2y ago
cant I use something like that?
Pobiega
Pobiega2y ago
in theory. change your context registration to use in memory db instead of sqlserver but like, porting a .netcore31 app to .net 7, without knowing C# or .NET at all, will be rough as you are seeing did you try getting it running as a .netcore31 app first?
júlio
júlioOP2y ago
yes, error 500
Pobiega
Pobiega2y ago
and you used a debugger to see why?
júlio
júlioOP2y ago
no
Pobiega
Pobiega2y ago
so do that
júlio
júlioOP2y ago
where do I p[ut the break point? in the place with the connection string?
Pobiega
Pobiega2y ago
"error 500" just means "something went wrong" program.cs, first line or just nowhere but run it in debug mode, and it should stop at first exception
júlio
júlioOP2y ago
okay
Pobiega
Pobiega2y ago
you need to get a rough idea of WHAT is going wrong
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
sure, it booted enough to start the http pipeline at least
júlio
júlioOP2y ago
no break there is a weird thing happening tho in previous services when I started the execution a tab poped up in my browser this one nothing pops up
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
because thats a recent addition
júlio
júlioOP2y ago
I have to manually open a tab
Pobiega
Pobiega2y ago
not a problem just do that.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I had that alreaddy I think
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
omg
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
When are we getting added to your company payroll btw?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Okay, im sorry, you dont have to help me
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see, thanks for explaining that Is it normal to have many exceptions in these kinds of programs?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
nothing stoped it just run as normal I give up I'll read some more stuff and follow your previous tips Thanks for the help so far I really appreciated it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
It's fine lol, maybe the problem is me
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I just feel like its a lot of stuff and then I feel bad asking you guys stuff cause I understand its like you guys are being teachers I dont want to anoy anyone honeslty i just wanted this Service to run so that I could experiment with it Maybe I'll try and ask the previous maintainer if he can help me, he told me to debug, but debug we saw that doesnt stop anywhere maybe ill try the breakpoint thing
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
It's kind anoying to ask him for help tbh, he never really explains anything, plus never gives documetnation on anything, he usually just says "read the code"
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the original creator left, the project was passed to this guy that I refer to as "the previous maintainer", and now they pass it to me. He still works on it, but after I split the service its me
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
problem was that nothing was documented, no one knows what documentation was used to make anything, there is stuff about the service the guy before me also donest know, etc
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I basically "found out" it was a web service, originally I was making Backgourng Services thinking that I was making progress xd Noted I'll start with that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I prefer reading then videos, but ill take a look definitly! THank you for sharing
júlio
júlioOP2y ago
Also, is this a good place to starthttps://learn.microsoft.com/en-us/ef/ ?
Entity Framework documentation
Learn to use Entity Framework Core, a modern object-database mapper for .NET that supports LINQ queries, change tracking, updates, and schema migrations. Browse tutorials, sample code, fundamentals, API reference and more.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yes, but I thouhg a little and I also lack knowledge on EF
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oh okay Noted
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So it follows the .NET version
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I'll read all that and watch the video and I'll return when I understand EFCore I promise Thank you for the patience so far I very much appreciate it, now it's time for me to put in the work
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I wont be fopcusing much on code tbh I just want the theory
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Out of curiosity, I see a lot of things that go in the []'s before declarations thoes that have a name I can look for?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Noted
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
That is all new to me, the annoptations consept, I'll catch up on that too
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see, its a way to mark functionalities to the otisde
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah that makes sense why its a bad idea XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I'm honestly kind of hyped to learn all this, I was always intimidated by database stuff so I stuck to learning things that were more comfortable to me But now after talking with you and seeing that stuff is well documented I think I can learn alot
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see I wont touch the service for now until I understand EFCore So I did some reading and now I'm following the video you posted above I ran into a issue
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I installed the NuGet packages regarding EntityFrameworkCore yet he is not recognizing the things The suggeested options tell me to install a EntityFramework package but EntityFramework is the old one, right? Am I missing some step?
Pobiega
Pobiega2y ago
if you check the "quick actions" on either of those errors, does it suggest "Import missing types" or similar?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
The thing is Install package 'EntityFramework' I dont think this is Entity Freamework Core I think it could be the old one, right?
Pobiega
Pobiega2y ago
yeah, you dont wanna do that
júlio
júlioOP2y ago
Maybe Im missing some using? the video deosnt show the usings part of the code hmmm
Pobiega
Pobiega2y ago
VS should suggest the usings if they are available are you sure the nuget is installed in this project?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I installed the ones the video showed
Pobiega
Pobiega2y ago
that should be enough yep
júlio
júlioOP2y ago
I'm using .NET 7.0, could that be the problem? maybe there is no DbContext in .net 7.0?
Pobiega
Pobiega2y ago
using Microsoft.EntityFrameworkCore;
júlio
júlioOP2y ago
I tried that but
Pobiega
Pobiega2y ago
DbContext comes from there not from .NET itself it comes from that nuget, that namespace
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) EntityFrameworkCoreMWE
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) EntityFrameworkCoreMWE
EntityFrameworkCoreMWE is the name of my project
Pobiega
Pobiega2y ago
it cant find the nuget for some reason if you run "dotnet restore" in a terminal in your project root, what does it say?
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
okay... thats weird.
júlio
júlioOP2y ago
:(
Pobiega
Pobiega2y ago
only one project in the solution?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Maybe it's the project type? I created a
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
empty was a bit overkill, but not a problem in itself and if you expand the "dependencies" there and then "packages"
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
no EF core
júlio
júlioOP2y ago
:O but I installed?
Pobiega
Pobiega2y ago
open your csproj
júlio
júlioOP2y ago
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
</ItemGroup>

</Project>
They are here
Pobiega
Pobiega2y ago
hm ok, restart VS
júlio
júlioOP2y ago
ok
Pobiega
Pobiega2y ago
it must have an invalid state
júlio
júlioOP2y ago
Same issue after restarting
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Why does nothing that I do work i swear to god
Pobiega
Pobiega2y ago
wait a second thats showing "program.cs" show your program.cs
júlio
júlioOP2y ago
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;


namespace EntityFrameworkCoreMWE
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();
}
}

public class DataBase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// The Connection Strings Reference: https://www.connectionstrings.com/sql-server/
optionsBuilder.UseSqlServer("Server=localhost;Database=EntityFrameworkCoreMWE;Trusted_Connection=True");
}

// We tell EF about Messages, this means we now have, in the EntityFrameworkCoreMWE database,
// a table called Messages
public DbSet<Message> Messages { get; set; }

}

// this would go into the Model folder
// Message is a Entity
public class Message
{
[Key]
public int Id { get; set; } // primary key: unique identifier for each row
public string? Title { get; set; }
public string? Body { get; set; }
}
}
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;


namespace EntityFrameworkCoreMWE
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();
}
}

public class DataBase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// The Connection Strings Reference: https://www.connectionstrings.com/sql-server/
optionsBuilder.UseSqlServer("Server=localhost;Database=EntityFrameworkCoreMWE;Trusted_Connection=True");
}

// We tell EF about Messages, this means we now have, in the EntityFrameworkCoreMWE database,
// a table called Messages
public DbSet<Message> Messages { get; set; }

}

// this would go into the Model folder
// Message is a Entity
public class Message
{
[Key]
public int Id { get; set; } // primary key: unique identifier for each row
public string? Title { get; set; }
public string? Body { get; set; }
}
}
I was following the video
Pobiega
Pobiega2y ago
I'm thinking you are mixing top level statements... ah ok you are not mixing it but its unusual to mix things like this. and please use file scoped namespaces 😄
júlio
júlioOP2y ago
So, make a file, open namespace EntityFrameworkMWE and type there? So the end goal would be more separated code?
Pobiega
Pobiega2y ago
you should have a quick action on the namespace EntityFrameworkCoreMWE line that says "convert to file scoped namespace"
júlio
júlioOP2y ago
Okay I did that
Pobiega
Pobiega2y ago
good. Now check the quick action on DataBase you should have a "Move to Database.cs"
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Yes Okay i will do that
Pobiega
Pobiega2y ago
great.
júlio
júlioOP2y ago
OKay it created a new file and moved the things to that file
Pobiega
Pobiega2y ago
yup!
júlio
júlioOP2y ago
I did the same to Message
Pobiega
Pobiega2y ago
normally you only have one type per file, but its not a hard requirement if two classes strongly belong together, I let them be in the same file
júlio
júlioOP2y ago
I see The issues all come from the DataBase file now question If I manually create de Models folder and move Message.cs there Would that be good or bad?
Pobiega
Pobiega2y ago
you'll need to update the namespace but thats fine
júlio
júlioOP2y ago
Oh ok
Pobiega
Pobiega2y ago
namespaces should reflect folder structure
júlio
júlioOP2y ago
Oh I see
Pobiega
Pobiega2y ago
Im really not sure what the error is here thou, you clearly have an EF reference but it doesnt work in VS for some reason try dotnet build in the terminal see what it says
júlio
júlioOP2y ago
júlio
júlioOP2y ago
a lot of red
Pobiega
Pobiega2y ago
its still saying Program.cs
júlio
júlioOP2y ago
Odd
Pobiega
Pobiega2y ago
did you leave a using behind there?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I dont thing so oh
Pobiega
Pobiega2y ago
look at the very top lol its right there :p
júlio
júlioOP2y ago
omgefnskfd
Pobiega
Pobiega2y ago
still, no idea why its not working
júlio
júlioOP2y ago
júlio
júlioOP2y ago
maybe c# dislikes me maybe I'll just see the video without making code and believe that it works XD
Pobiega
Pobiega2y ago
no, you should fix your issues nugets are resolved as dll files does your output directory contain the EF Core dlls?
júlio
júlioOP2y ago
i dont even fully understand EFCore, how am I suposed to fix something that I dont even understand why its breaking 💀 let me see
Pobiega
Pobiega2y ago
its not breaking, its not even starting this isnt a code issue, its a tooling problem somewhere
júlio
júlioOP2y ago
This?
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
no, up one step then "bin"
júlio
júlioOP2y ago
nothign there i searched in the binaries frist but i didnt find anything
Pobiega
Pobiega2y ago
hm... comment out your dbcontext for now
júlio
júlioOP2y ago
so i tried the obj one ok
Pobiega
Pobiega2y ago
so that your project builds dotnet build verify that it actually builds
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
ok
júlio
júlioOP2y ago
Progress!
Pobiega
Pobiega2y ago
now go bin/debug/ etc and check the dlls
júlio
júlioOP2y ago
júlio
júlioOP2y ago
There is one
Pobiega
Pobiega2y ago
thats yours
júlio
júlioOP2y ago
Yes I think it has the project name
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
you are missing these. the EF dlls
júlio
júlioOP2y ago
that's alot of files :/
Pobiega
Pobiega2y ago
so we need to figure out why dotnet restore isnt working right you're sure all files are saved properly?
júlio
júlioOP2y ago
I think so yes
Pobiega
Pobiega2y ago
like, your csproj isnt actually empty on disk?
júlio
júlioOP2y ago
let me check
Pobiega
Pobiega2y ago
if you open it wiht say notepad, it has the package references?
júlio
júlioOP2y ago
yes it is not empty and has the packages references
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
dotnet nuget list source run that.
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
ok, thats the expected result... wtf
júlio
júlioOP2y ago
xd I can try making anew project
Pobiega
Pobiega2y ago
try this dotnet nuget locals all -c then dotnet restore
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
okay, now your cache is clear so try a dotnet restore
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
ok, and dotnet build, then check your bin folder
júlio
júlioOP2y ago
the code is still commented, correct? the database one
Pobiega
Pobiega2y ago
should be ya
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Still missing :/ very weird
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
try this
júlio
júlioOP2y ago
ok ill trya nd see if it fix I noticed something
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Is it normal to have the yellow thing?
Pobiega
Pobiega2y ago
nope
júlio
júlioOP2y ago
I think its because they are unused
Pobiega
Pobiega2y ago
no shouldn't be.
júlio
júlioOP2y ago
júlio
júlioOP2y ago
They appear selected when I click on "remove Unused References"
Pobiega
Pobiega2y ago
Hm, thats a new window. Never seen taht before. But lets not remove them.
júlio
júlioOP2y ago
ok
Pobiega
Pobiega2y ago
go to database.cs again and try manually typing using Microsoft and using the autocomplete, does it not suggest EntityFrameworkCore?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Nope
Pobiega
Pobiega2y ago
¯\_(ツ)_/¯ I have no idea.
júlio
júlioOP2y ago
C#, the C is for Cursed I will try a new project Maybe I did something wrong when creating this one idk LOL fixed it @Pobiega I unnistalled the packets and re-installed them and now it works hehehe thank you for showing me how to approach this issues!
Pobiega
Pobiega2y ago
That makes no sense.
júlio
júlioOP2y ago
I noted down the process
Pobiega
Pobiega2y ago
Did anything change in the csproj?
júlio
júlioOP2y ago
nope its the same mystery So I wasnt able to get the database running xd I got error 40 and after some research I was kinda lost then I went and read alot about migrations and damn its a very clear thing, i liked knowing about them now Im back to the video and have a question
júlio
júlioOP2y ago
júlio
júlioOP2y ago
This is a screen shot of a part of the video the line await using var db = new Database(); ignoring the part about await using var cause i dont know about any of that yet, but what is he doing here? is db a Session? what I think its doing, is basically "connecting" us to the database? so basically, we can then mess with the Database object like if we were doing CRUD stuff, is that it?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
:(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I think he was just showing stuff around 30:00 actualy around 24:00 sorry i need to go to college now i have classes after work but ill be on discord there I also have a second question I didnt really understand from teh video
júlio
júlioOP2y ago
júlio
júlioOP2y ago
What would happen if the query gave no results? Would we get an exception? or nothing would happen?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
yep
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
@TeBeConsulting I wonder how we could change the default value to something other than null? I guess we could use null coalescing operator:
people.FirstOrDefault(person => person.Name == "TeBeConsulting") ?? new Person("TeBeConsulting");
people.FirstOrDefault(person => person.Name == "TeBeConsulting") ?? new Person("TeBeConsulting");
anything nicer we can do?
Pobiega
Pobiega2y ago
could do something like that, but its not a very common case, since this is fetching from a database.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
so you'd want to add the new entity to your tracking
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
and the GetOrAdd() method would be using null coalescing operator?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
cool, thank you
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
mhm okay
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
could even register the returned object with the dbset before returning it, if you wanted
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
yep, that would work
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
if you are really fancy, you'd ofc provide a non-async factory version too. overloads are nice 🙂
Florian Voß
Florian Voß2y ago
couldnt this be refactored to:
public static T GetOrCreateAsync(this DbSet<T> dbSet, IQueryable<T> query, Func<Task<T>> factory)
{
var entity = await dbSet.FirstOrDefaultAsync(query);
return entity ??= await factory();
}
public static T GetOrCreateAsync(this DbSet<T> dbSet, IQueryable<T> query, Func<Task<T>> factory)
{
var entity = await dbSet.FirstOrDefaultAsync(query);
return entity ??= await factory();
}
Pobiega
Pobiega2y ago
??= wouldn't work there but ?? would
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
oh, then
public static T GetOrCreateAsync(this DbSet<T> dbSet, IQueryable<T> query, Func<Task<T>> factory)
{
return await dbSet.FirstOrDefaultAsync(query) ?? await factory();
}
public static T GetOrCreateAsync(this DbSet<T> dbSet, IQueryable<T> query, Func<Task<T>> factory)
{
return await dbSet.FirstOrDefaultAsync(query) ?? await factory();
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
almost codegolf at that point :p
Florian Voß
Florian Voß2y ago
why not tho?
Pobiega
Pobiega2y ago
because thats an assigment ??is just "take right value if left is null" ??= is "assign right value if left is null, else do nothing"
Florian Voß
Florian Voß2y ago
this should work right?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
yeah I understand 🙂
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2y ago
tebeco#0205
REPL Result: Success
var a = 5;
Console.WriteLine(a = 3);
var a = 5;
Console.WriteLine(a = 3);
Console Output
3
3
Compile: 539.566ms | Execution: 27.839ms | React with ❌ to remove this embed.
MODiX
MODiX2y ago
tebeco#0205
REPL Result: Failure
var a = 5;
if(a = 3) {Console.WriteLine(true);}
else {Console.WriteLine(false);}
var a = 5;
if(a = 3) {Console.WriteLine(true);}
else {Console.WriteLine(false);}
Exception: CompilationErrorException
- Cannot implicitly convert type 'int' to 'bool'
- Cannot implicitly convert type 'int' to 'bool'
Compile: 589.724ms | Execution: 0.000ms | React with ❌ to remove this embed.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
public static async T GetOrCreateAsync<T>(this DbSet<T> dbSet, IQueryable<T> query, Func<Task<T>> factory)
{
return await dbSet.FirstOrDefault(query) is T t ? t : await factory();
}
public static async T GetOrCreateAsync<T>(this DbSet<T> dbSet, IQueryable<T> query, Func<Task<T>> factory)
{
return await dbSet.FirstOrDefault(query) is T t ? t : await factory();
}
how about this one xD goddamn I love c#, there are so many cool ways to write this but also kinda makes it hard to choose one
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
i just took what you had as the method's definition but yeah makes sense right, edited xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
A model is made up of entity classes and a context object that represents a session with the database. Isn't a Model just a class? I don't get the "context object that represents a session with the database" part Wait, do I have to have a Context for each Model? So for example
public class PersonContext : DbContext {...}
public class Person {...}

public class BookContext : DbContext {...}
public class Book{...}

public class CarContext : DbContext {...}
public class Car{...}
public class PersonContext : DbContext {...}
public class Person {...}

public class BookContext : DbContext {...}
public class Book{...}

public class CarContext : DbContext {...}
public class Car{...}
?
Pobiega
Pobiega2y ago
no
júlio
júlioOP2y ago
Or only if I have a database for each?
Pobiega
Pobiega2y ago
you usually have one context for an entire project
júlio
júlioOP2y ago
I see, yeah this is what I though
Pobiega
Pobiega2y ago
it contains multiple DbSets
júlio
júlioOP2y ago
DbSet meaning a table in the database right?
Pobiega
Pobiega2y ago
something like that one dbset corresponds to one entity but that entity may potentially span more than one table usually thou, its fairly 1-to-1
júlio
júlioOP2y ago
I see Makes sense, thanks
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Denis
Denis2y ago
hot damn this thread has almost 2k comments
Pobiega
Pobiega2y ago
don't bother reading it, its really not that interesting
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
But it would make sense if I wanted to connect to other database, for example I think Since form what I understand, a Context is relative to a database
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yes, I agree I gave tat example to make clear since in the documentation the gave a name to a context that was related to a Entity
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah okay o7 Also, I see code like this
using (var db = new BloggingContext())
{
var blog = new Blog { Url = "http://sample.com" };
db.Blogs.Add(blog);
db.SaveChanges();
}
using (var db = new BloggingContext())
{
var blog = new Blog { Url = "http://sample.com" };
db.Blogs.Add(blog);
db.SaveChanges();
}
In he video he also used using ... and assgned objects to it What is the meaning of using in this situations? Is it just to force destruction of a object? Does it mean the object wont be managed by garbage collector? Or just that that instance will be invalid after the scope ends?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah I understand that part now
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So I assume its good for the context to use using, correct?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
because we want to have more control over when it will be disposed right?
Pobiega
Pobiega2y ago
if you use it like this, yes. but normally you dont use it like this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
O
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah, i though about "damn do I have to write this every time" xd
Pobiega
Pobiega2y ago
especially in a web app, you will never ever see new BloggingContext() you inject it instead
júlio
júlioOP2y ago
thats a new thing Ill have to learn aswell
Pobiega
Pobiega2y ago
and that means the service provider takes care of object lifetimes, and in a web project that would be the request scope
júlio
júlioOP2y ago
Okay, thanks for explaining, back to reading 📖
Denis
Denis2y ago
The using statement is basically syntax sugar for closing connections, disposing of instances wrapped in the using statement. E.g., you wrap a File writer in a using statement. This ensures that the file is closed, once you are done writing to it. Without a using statement you'd have to write that yourself
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
To me syntactic sugar means an easier alternative to write certain behaviour, which ends up being lowered into the same thing. Considering using is lowered into a try-finally, I would call it the syntactic sugar of that, since it's an easier way to write it.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
That's whole different behaviour altogether which would not be related to the using block lel
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Is it the equivalent of doing siomething like
{
{
var foo = SomeConnection();
}
}
{
{
var foo = SomeConnection();
}
}
?
Pobiega
Pobiega2y ago
?
Denis
Denis2y ago
This thread is still going Smadge
Pobiega
Pobiega2y ago
what exactly would this hypothetically be equivalent to? the outer scope does nothing here, and the inner one simply limits the scope of foo, just like all scopes do.
júlio
júlioOP2y ago
end of scope forces a stack unwind so it would dispose of the stuff inside oh wait c# doesnt put objects in the stack i keep forgetting
Pobiega
Pobiega2y ago
it wouldnt dispose either way if an object goes out of scope, it will eventually be picked up by GC
júlio
júlioOP2y ago
wait no, it would work cause no other ref was holding the obj
Pobiega
Pobiega2y ago
but that is not the same as disposing IDisposable.Dispose() is a specific method
júlio
júlioOP2y ago
Isnt Disposing what happens when the objects gets collected by the GC?
Pobiega
Pobiega2y ago
no
júlio
júlioOP2y ago
Oh
Pobiega
Pobiega2y ago
not everything can be cleaned up nicely by the GC anyways unmanaged resources, like window handles, file handles etc for example thats why IDisposable exists, so you can handle that stuff yourself
júlio
júlioOP2y ago
Yeah i know does implementing IDisposable mark the object as unmanaged? it should honestly
Pobiega
Pobiega2y ago
it doesnt.
júlio
júlioOP2y ago
cause if Dispose isnt called in destruction I have to make it call Dispose, right?
Pobiega
Pobiega2y ago
not have to. but in most cases, should HttpClient is a good exception. you should not be using var client = new HttpClient(), ever
júlio
júlioOP2y ago
what I mean is, if I dont explicitly call Dispose, or do the funny using thingy, will something call it for me? why not? ever?
Pobiega
Pobiega2y ago
look here for how to implement IDisposable if you have native resources
júlio
júlioOP2y ago
native resources are resources I make, right?
Pobiega
Pobiega2y ago
no its unmanaged stuff like IntPtr in this case
júlio
júlioOP2y ago
why are they called native resources? kinda weird name unmanaged resources would be more clear
Pobiega
Pobiega2y ago
its native because it belongs to the OS managed resources are managed by the CLR but tbh, stop worrying about this lol this is so beyond what you are doing
júlio
júlioOP2y ago
managed resources are managed by the GC tho CLR starts the GC
Pobiega
Pobiega2y ago
the GC is part of the CLR why are you splitting hairs?
júlio
júlioOP2y ago
GC was the topic i read the most about when I knew about c# a few days ago its very interesting the way it works
Pobiega
Pobiega2y ago
Sure, but unrelated to your current problems and tasks.
júlio
júlioOP2y ago
it helps me understand things if i have a clear definiton of what hings are I know but if I dont know how things work, do I really know the things?
Pobiega
Pobiega2y ago
Sure. But do you need to know quantum physics to ride a bike?
júlio
júlioOP2y ago
No :)
Pobiega
Pobiega2y ago
You already have a huge task ahead of you, don't make it larger 😛 you can learn the details on GC and managed/unmanaged stuff later
júlio
júlioOP2y ago
maybe its just my brain trying to detour from the main task cause im stuck again oh well back to reading
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I only have one project here i think Why cant I add a migration? omg the goddamn backup file
Pobiega
Pobiega2y ago
yarp
júlio
júlioOP2y ago
todday is the day I try to get a migration working yesterday i tried but I got error 40
Pobiega
Pobiega2y ago
I don't know what error 40 is. I know most http status codes by heart, but not everything else :p
júlio
júlioOP2y ago
it was a error not in the browser but like in the command shell lwt me see if I can reproduce
Pobiega
Pobiega2y ago
likely a SQL server error?
Error 40: Could Not Open a Connection to SQL Server
yeeep.
júlio
júlioOP2y ago
It was when I tried to update the database
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
The command was dotnet ef database update So yeah, I was unable to follow the video from there
Pobiega
Pobiega2y ago
seems pretty clear to me what the error is
júlio
júlioOP2y ago
buuuut my connection string is good i think
Pobiega
Pobiega2y ago
its not, or your server is offline
júlio
júlioOP2y ago
optionsBuilder.UseSqlServer("Server=localhost;Database=EntityFrameworkCoreMWE;Trusted_Connection=True");
optionsBuilder.UseSqlServer("Server=localhost;Database=EntityFrameworkCoreMWE;Trusted_Connection=True");
I'm going to make a very noob beginner question Microsoft SQL Server Managment Studio
Pobiega
Pobiega2y ago
SSMS, yep
júlio
júlioOP2y ago
Is that my SQL server?
Pobiega
Pobiega2y ago
nope.
júlio
júlioOP2y ago
Its just a program that manages databases?
Pobiega
Pobiega2y ago
its a program that connects to SQL server and lets you do stuff in it yes.
júlio
júlioOP2y ago
So I have a local SQL server? lLike in my computer?
Pobiega
Pobiega2y ago
probably? maybe? I dont know?
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
looks like it
júlio
júlioOP2y ago
it has a IP in front that isnt 127.0.0.1
Pobiega
Pobiega2y ago
wdym in front
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
thats not an IP thats the version
júlio
júlioOP2y ago
Oh.... hehe
Pobiega
Pobiega2y ago
júlio
júlioOP2y ago
oh okay
júlio
júlioOP2y ago
júlio
júlioOP2y ago
This is mine So if it was local I should see a icon in bottom left corner right?
Pobiega
Pobiega2y ago
no, it is local how do I know? because the hostname is .
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
nah, it likely runs as a service press ctrl+shift+esc go to services (the plugin icon) see if you find it in your services list
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Any of these?
Pobiega
Pobiega2y ago
I run mine in a docker container on WSL, so its slightly different well, those are related to it for sure
júlio
júlioOP2y ago
those are the only ones I have that have the text SQL
Pobiega
Pobiega2y ago
okay, well it doesnt really matter change your connstr to Server=.\SQLSERVER give that a spin.
júlio
júlioOP2y ago
SAme output error 40\
Pobiega
Pobiega2y ago
when you start SSMS, what do you put in the "server name" field?
Pobiega
Pobiega2y ago
júlio
júlioOP2y ago
.\SQLSERVER
Pobiega
Pobiega2y ago
then that is what your connstr should have
júlio
júlioOP2y ago
Ohh okay, noted
Pobiega
Pobiega2y ago
wait, is that your entire connstr above? or did you remove the userid/password fields?
júlio
júlioOP2y ago
do thaths it ohhhh omg I forgot about the password sorry Ill add that and see Goddamnit Same issue
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
hm, it cant even get to the login part your computer seems a bit cursed tbh first the weird dotnet nuget restore, now this
júlio
júlioOP2y ago
true everyuthing i tried so far as failed with erros sucks to be me
Pobiega
Pobiega2y ago
But SSMS can connect and manage the server just fine?
júlio
júlioOP2y ago
I mean... yes Iºmn not understanding something Why is it that the original project (the service), doesnt have a DbCOntext he uses theconenction string in the Startup.cs file
Pobiega
Pobiega2y ago
It did thou
júlio
júlioOP2y ago
public void ConfigureServices(IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
in this function not in a class that inherits from DbCOntext
Pobiega
Pobiega2y ago
Thats how you usually do it
júlio
júlioOP2y ago
So why are the tutorials using a class? ohhhh it used to be in the class HelperContext but its commented there #warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings. So maybew it was originally in the class but it was changed to the Startup.cs file maybe for security reasons? I mean the string is still there so idk how that would improve security but ok
---> System.ComponentModel.Win32Exception (67): The network name cannot be found.
---> System.ComponentModel.Win32Exception (67): The network name cannot be found.
So this line appears in that big output from the console maybe its a clue?
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
How can I verify that the SQL Server is configured to allow remote connections? I mean its local tho i dont know :(
Pobiega
Pobiega2y ago
SSMS working is the key bit You need to figure out why
júlio
júlioOP2y ago
Is there a way to "ping" the sqlserver? just to see if its alive I want to see if I can reach my local server before assuming the problem is in the connection string I mean, sure if the SSMS can connect, it should be alive Login works fine and it shows the dates and whatever but like outside of SSMS
Pobiega
Pobiega2y ago
You don't ping a server, you ping a host. The equivalent is connecting to it
júlio
júlioOP2y ago
so I would run the command "ping <hostname>"? in this case
Pobiega
Pobiega2y ago
But the hostname is . Aka localhost
júlio
júlioOP2y ago
ping ./SQLSERVER
Pobiega
Pobiega2y ago
That's not your hostname Hostnames don't contain slashes
júlio
júlioOP2y ago
I see Okay i used my hostname and it replied so that is good i think
Pobiega
Pobiega2y ago
.... Did you ping localhost?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
that is my computers hostname I dont get why my connection string is <hostname/SQLSERVER> and not just <hostname>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well yes but
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I have N databases SQLSERVER is a database of databases?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
in this case, my local mahcine
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So if I can ping my hostname and i get a reply, it means the server is alive
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
in the server (my machine), I have 1 or more SQLSERVER instances, and each instance can have 1 or more databases, is that it?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see....
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
This is the problem im having since yesterday I try to run the command dotnet ef database update I made the migration successfully but it cant connect to the database my conenction string looks like this Server=JULIOPACHECO/SQLSERVER;Database=EntityFrameworkCoreMWE;User Id=sXXXX;Password=XXXX; oh wait the password is incorrect wtf 1 sec
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
no the password is corerct.... I tried giving the connection string in the command
dotnet ef database update --connection "......"
dotnet ef database update --connection "......"
Still failed
Pobiega
Pobiega2y ago
and you have tried Server=.\SQLSERVER;Database=EntityFrameworkCoreMWE;User Id=sXXXX;Password=XXXX;?
júlio
júlioOP2y ago
username and password are correct Yes still faild
Pobiega
Pobiega2y ago
with the . and the backslash?
júlio
júlioOP2y ago
omg wait it faild but difernt error
júlio
júlioOP2y ago
júlio
júlioOP2y ago
omg my hopes are back up i was starting to question my existence
Pobiega
Pobiega2y ago
have you been using a forward slash the entire time?
júlio
júlioOP2y ago
yes :(
Pobiega
Pobiega2y ago
NGL, getting a bit tired of you not paying attention to details I suggested .\SQLSERVER from the very start and you said several times you tried it and it didnt work
júlio
júlioOP2y ago
sorry... So SSL is a cerificate
Pobiega
Pobiega2y ago
SSL is .. a lot more than that but it uses certificates
júlio
júlioOP2y ago
so SQL uses a SLL certificate and the certificate is not trustetd? i asked GPT is tehre a way to check the certificates?
Pobiega
Pobiega2y ago
TrustServerCertificate=true; in your connection string since this is for a local machine, this is fine its not fine for a remote connection
júlio
júlioOP2y ago
OMG it worked
Pobiega
Pobiega2y ago
Also, please stop using GPT as a google replacement its not a google replacement it doesnt know facts
júlio
júlioOP2y ago
I didnt! I was just for the errors i was getting :( I dislike GPT
Pobiega
Pobiega2y ago
it predicts text sequences
júlio
júlioOP2y ago
I know :( But desperate times make desperate measures
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
that top link contained the answer
júlio
júlioOP2y ago
O yeah GPT wasnt very helpful here
Pobiega
Pobiega2y ago
So why are you defaulting to it over google?
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
or bing, or DDG
júlio
júlioOP2y ago
I DiNt I literally just used it for this now i didnt touch gpt for the past days i talked here
Pobiega
Pobiega2y ago
okay, your connstr is finally fixed, so now you can get started with EF
júlio
júlioOP2y ago
yes, finally... thank you for the patience sorry i annoyed you i didnt mean to mess up
Pobiega
Pobiega2y ago
beacuse you don't normally have a fallback connstr hardcoded in your application, as I mentioned before. You read from the config, if it isnt there, you crash (intentionally). because that means your app is not configured correctly
júlio
júlioOP2y ago
this would be the appsettings.json?
Pobiega
Pobiega2y ago
sort of. not really, is the real answer
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
because that file is usually checked in to source control and you dont want your secrets in source control you'd use user secrets or similar locally, and when deployed you'd use environment variables or a keyvault or something
júlio
júlioOP2y ago
Noted One question Lets say that I have 3 classes in my program and I only put one of them in a forthe class (the context class)
Pobiega
Pobiega2y ago
?
júlio
júlioOP2y ago
So in it I would only have one DbSet<A>
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
?
júlio
júlioOP2y ago
When I made a migration, would It only create one table in the database for class A? fourth*
Pobiega
Pobiega2y ago
"put them in", you mean by making a DbSet property for it?
júlio
júlioOP2y ago
My question is, will the migration only make the tables for the stuff I register in the Context?
Pobiega
Pobiega2y ago
yes
júlio
júlioOP2y ago
yes ahh okay that is nice
Pobiega
Pobiega2y ago
however, if you make a DbSet<A> and A has a list of B in it then it will create tables for both since B is required for A to make sense
júlio
júlioOP2y ago
this would be a 1-N relation?
Pobiega
Pobiega2y ago
yes
júlio
júlioOP2y ago
I see So We use lists for that
Pobiega
Pobiega2y ago
or many to many, if B also has a list of A
júlio
júlioOP2y ago
okay Some kinds of relations require a third table to be created tho would It do that? Or would I have to help it?
Pobiega
Pobiega2y ago
yes no
júlio
júlioOP2y ago
okay okay
Pobiega
Pobiega2y ago
EF will figure it out on its own, most of the time but we can help it or guide it to do things the way we want thats done in the OnModelCreate override
júlio
júlioOP2y ago
I see, thats a bit more advanced tho, ill get to that eventually, just curious :) Ill go back to the video and the documentation im happy now finally got something to work after 4 days
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Left side is my project, right side is the original project I'm slowly adding file by file I installed the NewtonJSON package but the IDE is not recognizing it I have the same usings The only thing that is differente is the .NET version the original project (right) is using .NET Core 3 and my project (left) is using .NET 7 Any thing I can try? The quick actions dont solve anything
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I also have a similar issue with logging.AddFile in the Program.cs file Maybe the .NET version is the issue?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
not sure is ASP.NET Core 7.0 is just a fancy way of saying .NET 7.0 but idk
Pobiega
Pobiega2y ago
ASP.NET Core 7 is the latest version of ASP .NET is the CLR , asp.net core is the web framework I would recommend you try not using NewtonsoftJson in the new one .NET has a new JSON library called System.Text.Json since a few versions ago, and its much faster and modern. It doesnt have all the features of newtonsoft just yet, but it does handle most everyday usecases.
júlio
júlioOP2y ago
Well the things is, I dont really know enought to replace existing code using Newton with that well actually its only used there in that situation in the public void ConfigureServices(IServiceCollection services)
Pobiega
Pobiega2y ago
well, it does a lot more than that.
júlio
júlioOP2y ago
maybe I can try using that neew one
Pobiega
Pobiega2y ago
that AddNewtonsoftJson(); thing registers newtonsoft as the default serializer but tbh, you likely wont notice a differnce, since there are no newtonsoft specific configurations being applied there and without those, they behave more or less the same you'll just need to look out for [JsonProperty] (newtonsoft) vs [JsonPropertyName] (STJ) and the likes
júlio
júlioOP2y ago
the project doesnt use [JsonProperty] anywhere So I think its fine?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Is this one the equivalent?
Pobiega
Pobiega2y ago
even if it did, you'd just need to add a Property and you'd be done.
júlio
júlioOP2y ago
I installed the System.Text.Json
Pobiega
Pobiega2y ago
yes, but if you dont specify any options its there by default you dont need to STJ is part of the .net base library
júlio
júlioOP2y ago
O So its the default? okay I see So i just delete the Newton and delete the line cause the error okay
júlio
júlioOP2y ago
júlio
júlioOP2y ago
So I remember we talked about this some time ago But I didn't really understand anything
Pobiega
Pobiega2y ago
dont use it just skip that line entirely.
júlio
júlioOP2y ago
just straight up delete okay
Pobiega
Pobiega2y ago
its most likely an attempt at optimizing the api
júlio
júlioOP2y ago
"Enables full buffering of response bodies. "
Pobiega
Pobiega2y ago
but just from going to .NET 7 you will likely increase the request/second rate by a singnificant rate and from using STJ instead of newtonsoft too
júlio
júlioOP2y ago
Okay, out of curiosity, what is the default behaviour?
Pobiega
Pobiega2y ago
wdym?
júlio
júlioOP2y ago
Or, same question but from another angle, what does it mean to "full buffering of response bodies"
Pobiega
Pobiega2y ago
I have no idea.
Pobiega
Pobiega2y ago
it was an experimental package that never left prerelease
júlio
júlioOP2y ago
Oh Maybe that's why in .net 7.0 i cant find it in ide maybe it doesnt exist anymore
Pobiega
Pobiega2y ago
it only ever existed for a very short time I had never heard of it before you and tebe brought it up
júlio
júlioOP2y ago
Xd same Xd btw what do you think about my plan my plan is to make a migration since I have no clue about the tables but I do have the objects Im going to try and make a migration and then make EF make the database locally so that I can mess with the service and have a working database is this a good idea?
Pobiega
Pobiega2y ago
yes
júlio
júlioOP2y ago
FINALLY I say something that makes sense I'm learning :D I'm down to one last error
júlio
júlioOP2y ago
júlio
júlioOP2y ago
This happens herer in Program.cs
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
//logging.AddConsole();
logging.AddDebug();
logging.AddEventSourceLogger();
logging.AddFile("Logs/helperApi-{Date}.txt");

})
.UseStartup<Startup>()
.Build();
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
//logging.AddConsole();
logging.AddDebug();
logging.AddEventSourceLogger();
logging.AddFile("Logs/helperApi-{Date}.txt");

})
.UseStartup<Startup>()
.Build();
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Is this also something that deosnt exist anymore? Also, how can I tell if something no longer exists? BEcasue i might encounter this issue again eventually since the code is really old
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
júlio
júlioOP2y ago
I see Ill save that link for future
Pobiega
Pobiega2y ago
anytime you see a package, check it up on nuget.org if its an official microsoft package, and its version isnt 7.xxxx then you should take an extra look when a new .net version comes out, all core packages are released with the same major version
júlio
júlioOP2y ago
júlio
júlioOP2y ago
This one is still alive But I get error? This is regarding the .AddFile
Pobiega
Pobiega2y ago
that is definitely still alive
júlio
júlioOP2y ago
Pobiega
Pobiega2y ago
you are using it the wrong way the API has likely changed since .netcore31
júlio
júlioOP2y ago
Oh
júlio
júlioOP2y ago
So they removed file support
Pobiega
Pobiega2y ago
looks like the file based methods were either removed or moved to another package to google we go! "LoggingBuilder add file"
júlio
júlioOP2y ago
How do I know what to search for? I ask this because this is being done in a specifi place in a configuration how do I know that something "will fit"?
Pobiega
Pobiega2y ago
check the type of logging
júlio
júlioOP2y ago
ILoggingBuilderr
Pobiega
Pobiega2y ago
no wrong yes correct start with "C# <type name> <your thing>"
júlio
júlioOP2y ago
Serilog.Extensions.Logging.File or FileLoggerProvider in Orleans.TestingHost.Logging
Pobiega
Pobiega2y ago
Serilog absolutely can write to a file, but that is a different logging framework. from what I've found, it looks like M.E.Logging has entirely dropped file support
júlio
júlioOP2y ago
Well
Pobiega
Pobiega2y ago
However, serilog is... amazing
júlio
júlioOP2y ago
cant I just log to console
Pobiega
Pobiega2y ago
so you could just use that sure you can or you add serilog in "adaptor" mode where it wraps M.E.L and takes over logging but your applicationcode still use M.E.Logging, but you can log to console, file etc
júlio
júlioOP2y ago
Logging is a pretty new concept to me yet if I do
Pobiega
Pobiega2y ago
Add it to your list of stuff to investigate 🙂
júlio
júlioOP2y ago
logging.AddCOnsole(); will it log to console? Will do!
Pobiega
Pobiega2y ago
Serilog is considered "best practice" and industry standard tbh yup
júlio
júlioOP2y ago
So it means that, when I start my application, it will open up a console and start dumping things threr, right? even if my project is not a console application?
Pobiega
Pobiega2y ago
kinda. it would open the console anyways. no it only works on console apps. But luckily for you, web apps are console apps.
júlio
júlioOP2y ago
They are? oh
Pobiega
Pobiega2y ago
ofc they are.
júlio
júlioOP2y ago
i though they were browser pages or smthng since I access then with a link
Pobiega
Pobiega2y ago
jfc my guy you lack some serious basic computer knowledge >_> a backend web app listens to web requests and responds it isnt a browser, or a page its the thing that answers the requests
júlio
júlioOP2y ago
Ohh i see
Pobiega
Pobiega2y ago
its still a program, so it needs to run somewhere
júlio
júlioOP2y ago
So its output is stdout I mean
Pobiega
Pobiega2y ago
sure.
júlio
júlioOP2y ago
the console
Pobiega
Pobiega2y ago
yes
júlio
júlioOP2y ago
ok ok
Pobiega
Pobiega2y ago
but inside the app is a HTTP listener where it accepts http requests, and returns http responses
júlio
júlioOP2y ago
i see well myu boss just came near and told me i cant use discord smh imma die im going to read documentation and write down my questions :( when I get home I will aks things sorry i have to leave apparently goddamn it :(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
"Since no one at the company is helping me with anything at all, I got these french and swedish dudes teaching me everything from C#, networking, databases, asp.net, ef core, how computers work, how to troubleshoot and much more."
Denis
Denis2y ago
@dryfish please try and find a new employer
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
Discord is pretty commonly disabled due to causing procrastination Blame other servers that are not helpful 🤷
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
ideally the goal is to make sure everyone has what they need to move forward with their tasks, ie not be blocked by something, and other people pitch in to say "I can help with that". usually its just used to say what you did/are doing so the PM feels that they are involved 😦
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Hey guys I'm using discord on phone I'm on a food break They can't control what I do on my breaks So I managed to do a bunch of things actually I'm having a few problems tho When I navigate in browser to a route I get an exception and the breakpoint doesn't stop in the controller I suspect it's cause I'm not registration the Json service properly in the program.cs Anyways, in my lunch break I'll dump here some questions I have maybe someone can help I have to go now they are coming Brb
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Okay guys Imma dump some question I noted down, ill read them when I get home
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
1- Why are methods in Controllers not marked as async? Are they implicitly asnychronous? 2- What are the methods in the Controllers supposed to return? and what is a Task<IResult>? 3- Is it enough to jsut change the return type to a JsonResult if I want them to return JSON? It works if I do that, but I dont get what kind of magic is happening 4- Why is the connection string behing used in the ConfigureServices in the Startup.cs file? What do Services have to do with connecting to the database? 5- also, why do they call Services to the helper classes? Its just a class that does soemthing? 6- what should I return if I get a invalid input, of a method in the COntroller that returns a JSON? is there some standard I can fallback to or just return null? 7- What are the future implications of not having a Model that deosnt directly represent the database? For example, I found out the model has more fields then the database we are using, and when We convert to JSON the extra fields get the value null. I mentioned this and they told me maybe the database changed?No one really knows wtf is going on so Yeah, I wrote down some thing I think might be bad in the future but idk appreciate someone who knwos better to explain this Also I solved the issue I was having and managed to get the thing running However I did some things that I think could be done better,. For the Service problem, the registartion was giving me the execption. I was using the MS type JsonResult like tihs: //builder.Services.AddSingleton<JsonResult>(); I solved by doing this:
using Microsoft.AspNetCore.Mvc;

namespace helper.Services
{
public class JsonService
{
public JsonService() { }
public JsonResult ToJson(object obj) {
return new JsonResult(obj);
}
}
}
using Microsoft.AspNetCore.Mvc;

namespace helper.Services
{
public class JsonService
{
public JsonService() { }
public JsonResult ToJson(object obj) {
return new JsonResult(obj);
}
}
}
And in the Program.cs I did this:
builder.Services.AddTransient<JsonService>();
builder.Services.AddTransient<JsonService>();
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I saw a video in the .net yt channel that shwoed something similar and I tried it and worked but this is wwhat the previous guys did in the code and the viode is 3 years old So is tehre a better approach for this so taht I dont have to use the useless type JsonService>? Okay guys I gotta run now before I get caught Illr ead everythigng wehn I get home I rpomise gotta run
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
1. Nothing is async unless specified with the async key. Controller methods are synchronous by default but you can make them async by adding the async keyword and returning Task. .NET will then invoke it asynchronously. 2. This really depends on use case. Mostly you can return IActionResult, but you can also return ActionResult<T> where T is the type you return. This is useful for programs like Swagger to understand what an endpoint returns. When returning an (I)ActionResult, you need to specify the status code. NoContent() returns a 201, and Ok(T) returns a 200 with a returned object for example. There are a lot. You can also just return any Type, which means that you have no control over specific status codes, and you're not required to pass Ok(T) or something. 3. Yes, I believe if you make it an (I)ActionResult you can return Json(T) and your endpoint will also indicate JSON is returned. 4. I didn't read the convo, but you inject a database context into the list of services the application can use. This is called dependency injection. The idea is that you specify your settings once, for this collection, and anything supporting dependency injection can then request a transient, scoped or singleton instance of a dependency, which is then used there. In this case, a scoped database context is used for each request to communicate with the database. I strongly recommend you learn about dependency injection. 6. Same as point 2 and 3 I guess. You can return json(T) for a valid result. Otherwise you can return badRequest(), assuming the user did something wrong and assuming you're returning an (I)ActionResult. By default, your API will return an InernalServerError if something goes wrong, and you did not handle it.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Heyo guys I'm back Imma go thru each anwser, thanks for the replies btw fcken have to do this on the weekends cause no other change to use discord while im there during the week xd well, atleast i'm enjoying learning all this honestly, so it's fine :) yeas, both I think So, currently I have this:
[HttpGet("{nif}")]
public JsonResult Get(string nif)
{ //...
[HttpGet("{nif}")]
public JsonResult Get(string nif)
{ //...
So you're saying that, If I don't specify the async, it's not async?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
(This code is inside the Controller)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yes Input Output
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Blocking
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
:(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yes all that is a form of I/O
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
reading from console too but thats a stream
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
you areladdy menitoned stream
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh really? interesting
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Some streams could be just for I and others for O, is that what you mean?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
okay i will
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
This is also some thing that after I read async for C# i didnt really understand, so I get that its a language level asynchornization thingy, but what does that actually mean? does it start a thread if I do something async? and what if I use the thing I asynced before, does it wait there until that imaginary thread finish?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2y ago
TLDR on async/await: * every .net API that is suffixed with Async (eg: .Read() and .ReadAsync()) => use the Async version * if the API name ends with Async => await it * if the API returns a Task => await it * if you have to await in a method: * that method must have the async keyword (you could even suffix your function name with Async, up to you) * if it was returning T (eg:string) => it should now return Task<T> (eg: Task<string>) * APIs to ban and associated fix:
var r = t.Result; /* ===> */ var r = await t;
t.Wait(); /* ===> */ await t;
var r = t.GetAwaiter().GetResult(); /* ===> */ var r = await t;
Task.WaitAll(t1, t2); /* ===> */ await Task.WhenAll(t1, t2);
var r = t.Result; /* ===> */ var r = await t;
t.Wait(); /* ===> */ await t;
var r = t.GetAwaiter().GetResult(); /* ===> */ var r = await t;
Task.WaitAll(t1, t2); /* ===> */ await Task.WhenAll(t1, t2);
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Well, but why? I get that the goal is to not get stuck on I/O, but what is actually happening when I use a async thing? Does the main thread start a new thread and pass that new thread the context (not talking about BD context here) and the new thread now deals with the request, freeing up the main thread to listen to other requests?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So I should only mark functions as Async when I do I/O in them, else its overkill or bad use of resources?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2y ago
TLDR on async/await: * every .net API that is suffixed with Async (eg: .Read() and .ReadAsync()) => use the Async version * if the API name ends with Async => await it * if the API returns a Task => await it * if you have to await in a method: * that method must have the async keyword (you could even suffix your function name with Async, up to you) * if it was returning T (eg:string) => it should now return Task<T> (eg: Task<string>) * APIs to ban and associated fix:
var r = t.Result; /* ===> */ var r = await t;
t.Wait(); /* ===> */ await t;
var r = t.GetAwaiter().GetResult(); /* ===> */ var r = await t;
Task.WaitAll(t1, t2); /* ===> */ await Task.WhenAll(t1, t2);
var r = t.Result; /* ===> */ var r = await t;
t.Wait(); /* ===> */ await t;
var r = t.GetAwaiter().GetResult(); /* ===> */ var r = await t;
Task.WaitAll(t1, t2); /* ===> */ await Task.WhenAll(t1, t2);
júlio
júlioOP2y ago
That doesn't explain my question I think I was asking about how I should decide to mark the function as async
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
From what you explain, I think that I mark a function as async if I do I/O inside it, is this correct? Hmmm The thing is Im looking at the existing code now The function is not assync but in it they query the database and no Async used
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah this is what they are doing, a .FirstOrDefault, but no await used
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2y ago
tebeco#0205
let's take SaveChanges/Async
React with ❌ to remove this embed.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Out of curiosity, if Async is the one that should be used, why do they support the non-Async version? A better question is, in what situations would I want to use the non-Async version?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah, I was actually wondering in schenarios with alot of trafic, if I really wanted to use async, or would waiting for I/O be prefered
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see So what I registered from this topic: If I do I/O on a function, I mark it as asyn and return a Task<Return Type> and I use await for stuff that end with Async
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Noted Iºm trying out the things we talked bout
júlio
júlioOP2y ago
júlio
júlioOP2y ago
oh wait i think its in the wrong place
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
nvm yeap my bad
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Yeah so I keep getting these kind of stuff
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
"X" is not null here
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I added the Task but forgot the async 😅
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
But isnt the controller only called by the browser, when I nagivate to the route? I mean, not the brwoser but like when I make a request to that endpoint isnt that the only place?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
have a nice meal sir So I have now corrected the function
[HttpGet("{nif}")] // /api/nifs/<nif>
public async Task<JsonResult> Get(string nif)
{
Nifs? first = null;
_logger.LogInformation(LoggingEvents.GetNif, $"Getting nif {nif}", nif);
try
{
if (IsValidNif(nif))
{
first = await _context.Nifs.FirstOrDefaultAsync(n => n.Nif == nif);
}
}
catch (Exception ex)
{
_logger.LogCritical(LoggingEvents.GetNifException, ex, $"nif({nif}) Error", nif);
}
return _json.ToJson(first);
}
[HttpGet("{nif}")] // /api/nifs/<nif>
public async Task<JsonResult> Get(string nif)
{
Nifs? first = null;
_logger.LogInformation(LoggingEvents.GetNif, $"Getting nif {nif}", nif);
try
{
if (IsValidNif(nif))
{
first = await _context.Nifs.FirstOrDefaultAsync(n => n.Nif == nif);
}
}
catch (Exception ex)
{
_logger.LogCritical(LoggingEvents.GetNifException, ex, $"nif({nif}) Error", nif);
}
return _json.ToJson(first);
}
This is what It looks like now (this code is from the Controller btw) The next thing I wanted to try and fix todday was the Json part Cause you guys told me a lot of times that I didnt need to have a class for this This is what I currently have rn
// JsonService.cs
using Microsoft.AspNetCore.Mvc;

namespace helper.Services
{
public class JsonService
{
public JsonService() { }
public JsonResult ToJson(object obj) {
return new JsonResult(obj);
}
}
}
// JsonService.cs
using Microsoft.AspNetCore.Mvc;

namespace helper.Services
{
public class JsonService
{
public JsonService() { }
public JsonResult ToJson(object obj) {
return new JsonResult(obj);
}
}
}
//Program.cs
//...
builder.Services.AddTransient<JsonService>();
//...
//Program.cs
//...
builder.Services.AddTransient<JsonService>();
//...
And then I request a instance in the controller, like so:
//ControllerThing.cs
public NifsController(HelperContext context, JsonService json, ILogger<NifsController> logger)
{
_context = context;
_json = json;
_logger = logger;
}
//ControllerThing.cs
public NifsController(HelperContext context, JsonService json, ILogger<NifsController> logger)
{
_context = context;
_json = json;
_logger = logger;
}
If I try the mentioned approaches:
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
So I'm clearly didn'd understand I think you guys told me I read in the internet that I need to Register my Services Is something that converts Objs to Json not a service? Or is it a Service that ASP.NET offers for free? Do I need to request it in the Ctor of my Controller?
Monsieur Wholesome
Didnt we already establish that you should delete your jsonservice Make your endpoint method return whatever type first is (Task<Whatever>)
júlio
júlioOP2y ago
Well You told me but I didnt really understand why So I woulndt say its "established" technically Oh Well It's reaturning a JsonResult Isnt this the Json type?
Monsieur Wholesome
Wait no, im dumb You should solely return an IActionResult :P An IActionResult is a catch-all for all kinds of responses Ok(), NotFound(), BadRequest(), etc. etc. By passing in your object to the Ok(first) call, you're telling it what to return to the requester By default it is always returned as json. It will handle that for you
júlio
júlioOP2y ago
Ohhhh I was lacking this part of information you told me "An IActionResult is a catch-all for all kinds of responses" So hold up One thing I dont understand I was not returning a IAPlicationResult but it was still working I was getting a response Why is that? What kind of magic was happening?
Pobiega
Pobiega2y ago
IActionResult is the untyped interface for all http responses so if you have return Ok(); thats a valid IActionResult but so is BadRequest() and all the other helpers (including JsonResult)
júlio
júlioOP2y ago
So Everything I return from a HTTP method is implicitly converted to a IActionResult?
Pobiega
Pobiega2y ago
not converted IActionResult is an interface
júlio
júlioOP2y ago
Oh right So wait That would mean that I can only retun types that implement IActionResult, correct? (in the HTTP methods) It workss Damn I had no Idea I mean you guys told me i know but only now i understand
Pobiega
Pobiega2y ago
Well, in an API controller you can return anything and it gets serialized by default to json
júlio
júlioOP2y ago
And I assume that Json implements the IAplicattionresult, right thats why it works
Pobiega
Pobiega2y ago
not really Like, if I return a MyClass that has no baseclass or interfaces implemented, it gets serialized to json by the http pipeline in asp its not related to JsonResult or the other result types.
júlio
júlioOP2y ago
So I assume that the advantage Of returning a IActionREsult is that I can specify the return error? Ok BAd, etc
Monsieur Wholesome
By default it [a result object] is always returned as json. It will handle that for you
Ye
Pobiega
Pobiega2y ago
yep
júlio
júlioOP2y ago
I seeeee
Pobiega
Pobiega2y ago
if your only returns are 200 (with content), 400 (bad req) (by the model binder) or 500, then you dont need to use IActionResult
júlio
júlioOP2y ago
And If I dont return a IActionResult, the result will always be Ok() ?
Pobiega
Pobiega2y ago
but if you want more direct control over the returned code, you do no it will be 400 if the model binder fails, or 500 if you throw an exception
Monsieur Wholesome
It's a no brainer default tbh
júlio
júlioOP2y ago
O So I was following some documentation to help me migrate to .net 7.0 and Alot of things I did and are way more clean now I only have the Program.cs file now, no more Startup.cs class but there are something I didnt knew how to migrate
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I fixed the code I hope its not :(
public bool IsValidNif(string nif)
{
if (nif.Length != 9) return false;
if (!int.TryParse(nif, out _)) return false;
int checkSum = 0;

for (int index = 0; index < 9 - 1; ++index) {
checkSum += (nif.ElementAt(index) - '0') * (9 - index);
}
int checkDigit = 11 - checkSum % 11;
if (checkDigit > 9) checkDigit = 0;

return checkDigit == nif.ElementAt(9 - 1) - '0';
}
public bool IsValidNif(string nif)
{
if (nif.Length != 9) return false;
if (!int.TryParse(nif, out _)) return false;
int checkSum = 0;

for (int index = 0; index < 9 - 1; ++index) {
checkSum += (nif.ElementAt(index) - '0') * (9 - index);
}
int checkDigit = 11 - checkSum % 11;
if (checkDigit > 9) checkDigit = 0;

return checkDigit == nif.ElementAt(9 - 1) - '0';
}
This is my version I'm new to C# so be gentle :( The previous version was AIDs and I didnt even need to know C# to tell it was bad, I had to remake it
júlio
júlioOP2y ago
Is it bad? Xd sorry
Monsieur Wholesome
idk what it does on first sight, so that's already meh for me
júlio
júlioOP2y ago
It calculates a checksum basically nif is a special number you can tell if its valid by that formula
Pobiega
Pobiega2y ago
index < 9 - 1 so... index < 8? 😄
júlio
júlioOP2y ago
I did that to make it clear the intent Its common on code with magic numbers
Pobiega
Pobiega2y ago
I prefer just naming my magic numbers
júlio
júlioOP2y ago
9 every one knows its the length of the nif
Pobiega
Pobiega2y ago
so do that const int NIF_LENGTH = 9;
Monsieur Wholesome
public bool IsValidNif(string nif)
{
const int NifLength = 9;

if (nif.Length != NifLength ) return false;
if (!int.TryParse(nif, out _)) return false;
int checkSum = 0;

for (int index = 0; index < NifLength - 1; ++index) {
checkSum += (nif.ElementAt(index) - '0') * (9 - index);
}
int checkDigit = 11 - checkSum % 11;
if (checkDigit > 9) checkDigit = 0;

return checkDigit == nif.ElementAt(9 - 1) - '0';
}
public bool IsValidNif(string nif)
{
const int NifLength = 9;

if (nif.Length != NifLength ) return false;
if (!int.TryParse(nif, out _)) return false;
int checkSum = 0;

for (int index = 0; index < NifLength - 1; ++index) {
checkSum += (nif.ElementAt(index) - '0') * (9 - index);
}
int checkDigit = 11 - checkSum % 11;
if (checkDigit > 9) checkDigit = 0;

return checkDigit == nif.ElementAt(9 - 1) - '0';
}
Screaming case gasp
Pobiega
Pobiega2y ago
idk, used to it for constants.
júlio
júlioOP2y ago
Will do :) thanks for the sugestion kinda wierd the name tho, i might use a differnt one since the parameter is called nif people could read it and thing its the size of the parameter idk
Monsieur Wholesome
public bool IsValidNif(string nif)
{
const int NormedNifLength = 9;

if (nif.Length != NormedNifLength)
return false;
if (!int.TryParse(nif, out _))
return false;

int checkSum = 0;

for (int i = 0; i < NormedNifLength - 1; i++)
{
checkSum += (nif[i] - '0') * (9 - i);
}

int checkDigit = 11 - checkSum % 11;
if (checkDigit > NormedNifLength)
checkDigit = 0;

return checkDigit == (nif[NormedNifLength - 1] - '0');
}
public bool IsValidNif(string nif)
{
const int NormedNifLength = 9;

if (nif.Length != NormedNifLength)
return false;
if (!int.TryParse(nif, out _))
return false;

int checkSum = 0;

for (int i = 0; i < NormedNifLength - 1; i++)
{
checkSum += (nif[i] - '0') * (9 - i);
}

int checkDigit = 11 - checkSum % 11;
if (checkDigit > NormedNifLength)
checkDigit = 0;

return checkDigit == (nif[NormedNifLength - 1] - '0');
}
No need for ElementAt, you can index strings
júlio
júlioOP2y ago
Oh right Do I need to mark this function as async? Since it will be called by a async function?
Pobiega
Pobiega2y ago
no
júlio
júlioOP2y ago
nah probably not yep just wondering dont make sense
Monsieur Wholesome
A function only needs to be async, if its contents are async
Pobiega
Pobiega2y ago
async code can call sync sync cant call async
júlio
júlioOP2y ago
I see noted! Btw the thing I was mentioning migrating some things I didnt know how to do and one thing I didnt understand the meaning even after some search so ill start with that
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I'm not sure I need this if i understand what it did exaclty I think this is to say that my application will make requests to other websites? idk This service wont
Monsieur Wholesome
Cors allows sending requests from the frontend (browser) to other sites If it was there before, you will likely still need it
júlio
júlioOP2y ago
from the frontend? SO like
Monsieur Wholesome
Yes
júlio
júlioOP2y ago
locally?
Monsieur Wholesome
No?
júlio
júlioOP2y ago
browser is local :( I didnt understand
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Monsieur Wholesome
You can only send a request from the javascript side if the server allows Cross-origin resource sharing (CORS) If a frontend wants resources from your asp.net core server, while not being strictly under your domain, you will need to allow cors on your asp.net core server
júlio
júlioOP2y ago
SO it's to allow, for example, some javascript somewhwhere to request to my API?
Monsieur Wholesome
I think, now I am double doubting myself
júlio
júlioOP2y ago
Xd sorry Oh wait I think its the other way around
Monsieur Wholesome
Yes. Yes it also counts for apis
júlio
júlioOP2y ago
I think its to allow my backend to access other peoples stuff
Monsieur Wholesome
just remembered my latest use case of cors configuration no
júlio
júlioOP2y ago
SO you are saying that If I make some random javascript that tries to get info from my api if in my api I dont allow CORS the requests wont go thru? Cause by default only my frontend can talk to my backend? something like this?
Monsieur Wholesome
Yes
júlio
júlioOP2y ago
this is only for frontend? weird the other people backend also dont share my domain so CORs would apply to them too, right?
Monsieur Wholesome
Yes
júlio
júlioOP2y ago
So like, its for the whole exterior that has its own domain
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
logging somewheere? no clue, the code alreaddy was made like that, i didnt change much
FusedQyou
FusedQyou2y ago
Yup, no explicit indication will just make it synchronous (you can manually make threads instead but let's not talk about that). To make it async, change the method declaration to this:
public async Task<JsonResult> Get(string nif)
public async Task<JsonResult> Get(string nif)
Your actual method does not need to change, but it won't do anything asynchronous if there's no actual asynchronous code that is awaited.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
But I'm probably late as fuck with my answer
júlio
júlioOP2y ago
a bit, but I still appreciate you! thanks why?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Monsieur Wholesome
right, that $ shouldnt be there happens tho
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
using Microsoft.Extensions.Logging;

namespace helper.Controllers
{
public static class LoggingEvents
{
public static EventId GetNif = 1000;
public static EventId GetNifException = 1001;
}
}
using Microsoft.Extensions.Logging;

namespace helper.Controllers
{
public static class LoggingEvents
{
public static EventId GetNif = 1000;
public static EventId GetNifException = 1001;
}
}
Monsieur Wholesome
@TeBeConsultingis slowly digging up our mate's company codebase and internals
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
whats the issue? i wanna understand :(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Its all crap code tho XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
will do
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Monsieur Wholesome
why you disturbing our victim's migration time catsip
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2y ago
tebeco#0205
replace:
- _logger.LogInformation(LoggingEvents.GetNif, $"Getting nif {nif}", nif);
+ _logger.LogInformation(LoggingEvents.GetNif, "Getting nif {nif}", nif);
- _logger.LogInformation(LoggingEvents.GetNif, $"Getting nif {nif}", nif);
+ _logger.LogInformation(LoggingEvents.GetNif, "Getting nif {nif}", nif);
React with ❌ to remove this embed.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
What was the original issue? Im curious! And what does this fix? wait but like this I wont log the nif or will i?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I dont know C# enought to tell what its doing with the string
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Honeslty, this is the only place in the project wherer they log anything If i had to guess, its obsolete
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see... that's nice yeah
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Ill definitly read documentation on that, i wrote it down
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oh I can query
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Do you recomend any particular documentation on this?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see... Noted
builder.Services.AddLogging(loggingBuilder => {
loggingBuilder.AddConsole();
loggingBuilder.AddDebug();
});
builder.Services.AddLogging(loggingBuilder => {
loggingBuilder.AddConsole();
loggingBuilder.AddDebug();
});
This makes the logs go to the console, correct?
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Also, the last thing I dont get regarding this logging topic Why do I need to request ILogger<Type>? Why does it need to know the type of the thing? Im not even logging it
Monsieur Wholesome
The logger will add the origin (that type) to the logs, so you can filter aftewrwards
júlio
júlioOP2y ago
Ohhhhhhh Thats smart yeah Didnt though about that at all
Monsieur Wholesome
Kinda like [Date] [Time] [Origin] [Severity]: [Message] something like that
júlio
júlioOP2y ago
I see :) Well i need to write down alot of stuff mentioned here thanks for the patience so far guys
Monsieur Wholesome
What a thorough thread explaining how asp.net core projects are structured
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
thisis actually the otehr thig i wanted to address because not only there are some stuff I'm sure I don't need to do, I don't know which ones, and there are some stuff I didn't do that are done in the original project This is what my Program.cs lloks like currently:
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablablabla")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddCors();
builder.Services.AddMvc();
builder.Services.AddControllers();

builder.Services.AddLogging(loggingBuilder => {
loggingBuilder.AddConsole();
loggingBuilder.AddDebug();
});

var app = builder.Build();

if (!app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}

app.UseRouting();
app.UseCors();
app.MapControllers();

app.Run();
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablablabla")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddCors();
builder.Services.AddMvc();
builder.Services.AddControllers();

builder.Services.AddLogging(loggingBuilder => {
loggingBuilder.AddConsole();
loggingBuilder.AddDebug();
});

var app = builder.Build();

if (!app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}

app.UseRouting();
app.UseCors();
app.MapControllers();

app.Run();
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Just like that?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oke
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oke
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablablabla")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddCors();
builder.Services.AddControllers();

var app = builder.Build();

if (!app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}

app.UseCors();
app.MapControllers();

app.Run();
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablablabla")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddCors();
builder.Services.AddControllers();

var app = builder.Build();

if (!app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}

app.UseCors();
app.MapControllers();

app.Run();
The Json stuff part I'll also remove becasue I wont need that anymore
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
what do you mean by re-testing?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
It was in the orioginal project
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
that is from the original one
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
isnt it to allow external domains to use my api?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
what code do you want me to run? like start the service?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
can I just do that on the live one? the service is running as we speak in the cloud the original one i tried running the service in my computer but its buggy
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
can Postman do it?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
rip wait
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
cant I do it?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
in my current service? oh ok
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
PLAYCODE.IO
Javascript Playground (Sandbox, Repl)
The #1 JavaScript playground and sandbox to write, run and repl it. JavaScript playground is perfect for learning and prototyping javascript sandboxes. Fast. Easy to use.
júlio
júlioOP2y ago
Can I test with this?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
It replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Actually it failed the first time I tried on the live one and that worked but on mine it failed didnt even remove anything
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the link to the one running the api idk the endpoint
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I did this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}

var a = httpGet("link here");

console.log(JSON.stringify(a))
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}

var a = httpGet("link here");

console.log(JSON.stringify(a))
in the link, if I put the one in prod it gets a reply if I put mine in localhost it fails
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
JSFiddle - Code Playground
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
ok ill do that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I didnt show everything the firtst time
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeap i think this is why tehy told me the cloud provider dealt with all that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablabla")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddControllers();

var app = builder.Build();

if (!app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
else {
app.UseCors(options => {
options.AllowAnyHeader();
options.AllowAnyMethod();
options.AllowAnyOrigin();
});
}

app.UseCors();
app.MapControllers();

app.Run();
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablabla")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddControllers();

var app = builder.Build();

if (!app.Environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
else {
app.UseCors(options => {
options.AllowAnyHeader();
options.AllowAnyMethod();
options.AllowAnyOrigin();
});
}

app.UseCors();
app.MapControllers();

app.Run();
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Probably XD yep its a bug
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Hold up they have this code in the original project
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Noo, why?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
that sucks infinite loading
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So many dogs :o I played a game once called lost ark it was similar to that clip but it got hard and I had to quit xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
im pretty bad at games ngl Xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablabal")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddControllers();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();

app.UseCors(options => {
options.AllowAnyHeader();
options.AllowAnyMethod();
options.AllowAnyOrigin();
});
}

app.MapControllers();

app.Run();
using helper.Models;
using helper.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<HelperContext>(
options => options.UseSqlServer(@"Server=blablabal")
);

//builder.Services.AddSingleton<JsonResult>();
builder.Services.AddTransient<JsonService>();
builder.Services.AddControllers();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();

app.UseCors(options => {
options.AllowAnyHeader();
options.AllowAnyMethod();
options.AllowAnyOrigin();
});
}

app.MapControllers();

app.Run();
okay now its good
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Why do I want to use swagger?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I thnik I dont need it becasue the original project didnt have it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I am! :d It that all I need to do to haev it?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh, ill add it then to try!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
imma do that rn to see
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Ok
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:XXXX"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:XXXX;http://localhost:XXXX"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"nativeDebugging": true
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:XXXX",
"sslPort": XXXX
}
}
}
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:XXXX"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:XXXX;http://localhost:XXXX"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"nativeDebugging": true
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:XXXX",
"sslPort": XXXX
}
}
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

</Project>
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see.... I do this for all the profiles?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I was wondering that actually xd I see, okay thats good
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Ohhh That makes sense, I though it had to do with the Debug dropdown like running in debug or not
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeah after these changes I think I broke something cause its not replying the json when I go to the endpoint Ill have to look into what whent wrong
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Weirddd Its complaining about IsValidNif
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Monsieur Wholesome
All endpoints need an explicit http verb like [HttpGet], [HttpPost], ...
júlio
júlioOP2y ago
BUt its not ment to be a endpoint Its a helper function
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
indeeed I didnt know that actually that the public stuff was visible form the outisde
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Took a while tho
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
but its working now! this is so cool Its a very nice UI thank you for showing it to me!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
i agrre xd at first i wasnt understanding why it wasnt let me type values Ah... had to click... xd So the last thing Im missing from the startup was the thing that I didnt put in my current startup becasue I didnt understand any of that so i just... ignored it It works finetho so maybe i dont need? anyways this is the part of the code i'm missing i just want to understand why they did it its basically getting time from somewhere? idk
private DateTime GetNetworkTime(string ntpServer = "ntp02.oal.ul.pt")
{
var ntpData = new byte[48];
ntpData[0] = 0x1B; //LeapIndicator = 0 (no warning), VersionNum = 3 (IPv4 only), Mode = 3 (Client Mode)

var addresses = Dns.GetHostEntry(ntpServer).AddressList;
var ipEndPoint = new IPEndPoint(addresses[0], 123);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

try
{
socket.ReceiveTimeout = 5000; //sec
socket.Connect(ipEndPoint);
socket.Send(ntpData);
socket.Receive(ntpData);
socket.Close();

ulong intPart = (ulong)ntpData[40] << 24 | (ulong)ntpData[41] << 16 | (ulong)ntpData[42] << 8 | (ulong)ntpData[43];
ulong fractPart = (ulong)ntpData[44] << 24 | (ulong)ntpData[45] << 16 | (ulong)ntpData[46] << 8 | (ulong)ntpData[47];

var milliseconds = (intPart * 1000) + ((fractPart * 1000) / 0x100000000L);
var networkDateTime = (new DateTime(1900, 1, 1)).AddMilliseconds((long)milliseconds);

return networkDateTime;
} catch
{
if (ntpServer == "ntp04.oal.ul.pt")
{
return DateTime.Now;
} else
{
return GetNetworkTime("ntp04.oal.ul.pt");
}
}

}
private DateTime GetNetworkTime(string ntpServer = "ntp02.oal.ul.pt")
{
var ntpData = new byte[48];
ntpData[0] = 0x1B; //LeapIndicator = 0 (no warning), VersionNum = 3 (IPv4 only), Mode = 3 (Client Mode)

var addresses = Dns.GetHostEntry(ntpServer).AddressList;
var ipEndPoint = new IPEndPoint(addresses[0], 123);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

try
{
socket.ReceiveTimeout = 5000; //sec
socket.Connect(ipEndPoint);
socket.Send(ntpData);
socket.Receive(ntpData);
socket.Close();

ulong intPart = (ulong)ntpData[40] << 24 | (ulong)ntpData[41] << 16 | (ulong)ntpData[42] << 8 | (ulong)ntpData[43];
ulong fractPart = (ulong)ntpData[44] << 24 | (ulong)ntpData[45] << 16 | (ulong)ntpData[46] << 8 | (ulong)ntpData[47];

var milliseconds = (intPart * 1000) + ((fractPart * 1000) / 0x100000000L);
var networkDateTime = (new DateTime(1900, 1, 1)).AddMilliseconds((long)milliseconds);

return networkDateTime;
} catch
{
if (ntpServer == "ntp04.oal.ul.pt")
{
return DateTime.Now;
} else
{
return GetNetworkTime("ntp04.oal.ul.pt");
}
}

}
They call that in the Startup constructor
Monsieur Wholesome
Do you not have any colleagues you could ask this
júlio
júlioOP2y ago
nope :( the original maintainer left he did most of the code
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
and left no documentation
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Monsieur Wholesome
captured and never released
júlio
júlioOP2y ago
they basically do all that just to do this in the Ctor
try
{
OALDateTime = GetNetworkTime();
if (OALDateTime == null)
{
OALDateTime = DateTime.Now;
}
} catch
{
OALDateTime = DateTime.Now;
}
try
{
OALDateTime = GetNetworkTime();
if (OALDateTime == null)
{
OALDateTime = DateTime.Now;
}
} catch
{
OALDateTime = DateTime.Now;
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
thats it plus the BaseCOntroller thing is AIds Its very bad they basically made a type called ControllerBase that conflicts with MS ControllerBase and they make the ControllerBase inherit from Controller Phaahhaha Controller is a MS type that inherits from MS ControllerBase type its a mess
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
hell no I have multiple 3k + lines files Im separating piece by piece and fixing one at a time I have one working so far 10 left
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
on file is 6k lines long 367 lines
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the consttructor and nothing else
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
protected and private
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
not sure because its a bit weird
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
it seems like they are hand encrypting and decrpyting sha1 stuff
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Try again 😎 XD I joke ofc No clue what encryption this is decrpyting but
júlio
júlioOP2y ago
júlio
júlioOP2y ago
this is a thing? idk
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yep is in my profile
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
i think
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I know its form sharing code n stuff, right?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
no clue
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
O oke
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Ok ill try not to mess up :(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
o7
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Good morning! Every method as at least 1 reference The version parts are kinda weird I might be able to clean it up alot
júlio
júlioOP2y ago
júlio
júlioOP2y ago
It gets the version from this no clue where this is going tho
Pobiega
Pobiega2y ago
That's th request query string accessor
Jayy
Jayy2y ago
Jesus Christ why does this thread have 3.5 k
Pobiega
Pobiega2y ago
Tldr: brand new to C#, asked to split a .netcore31 monolith to .net 7 microservices, gets no help from anyone at his job
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Monsieur Wholesome
instant run
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Gist
BaseController.cs
GitHub Gist: instantly share code, notes, and snippets.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Exactly that :p yes!
júlio
júlioOP2y ago
júlio
júlioOP2y ago
AtController inherits from ControllerBase (not the MS type, the one in BaseController.cs)
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
the think I dont get is where is it getting the version from Wait hold up
júlio
júlioOP2y ago
júlio
júlioOP2y ago
what is the meaning of this? Try to get the version, if fail it gets the value in ApiVersion?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Sorry I dont undertand The only controller that calls the functions is the AtController
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
This is exactly what I was going to talk with you about XD Btw, I will send you something in the DMs The answer is no, I can't change that unfortunately Because a lot of code is already using the things like that elsewhere It would be very costly to scan thru all and change The version is related to the clients version I must support older versions, I can't change that part, and the version comes in the URL, so not sure if I can use the think you mentioned about ASP.NET being able to manage that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
No problem!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I can't change the website/API/controller/whatever/idk part
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Is something like this endpoint/v2 or endpoint/v3
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
it was waht i was told
júlio
júlioOP2y ago
júlio
júlioOP2y ago
one of the methods that use the version stuff gets it like this I see what you mean thonkpad ask the guy again Okay so the service is getting in the query string not in the fortmat I showed above
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
why? I alreaddy have a bunch Xd i created some to experiment a bit
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
ohh XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yep i idnt think about that XD but we will make code fromm scratch there?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see Are you sure? Im going to create a public repo in github 1 sec
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
so the issue is i have a work git and a personal git and the computer uses the work git it came set up I can do that when I get home tho in my personal computer becasue I have no clue how to chenge github accounts locally im scared to break everything else XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I have the repo I created in the browser but its empty
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
or that yeah I asked chatgpt XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
and it wont change the global config, right=?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
so your comand is fine
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I seee Ill try 1 sec the command you made created me a directory with the name user.email=whateveremailIused XD oph wait im dumb I forgot a -c lets ignore this 4 messages IT WORKED this is so cool!! i wanted to do this is a long time but I was scared id mess up I will do the dotnet things now? creat a new project etc
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
same error same error
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
vbut i did them
júlio
júlioOP2y ago
júlio
júlioOP2y ago
yes sorry meanwhile i was trying to see how I can serialize and vice versa from XML xd cause one place is returning a xml and the way the service deals with it is kinda ugly? idk trying to make it prettier
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So a different route to different versions? Interesting Woulndt that repeat alot of code? because few things change Or is there a way to put only the thing that change inside the folders and then lets it handle that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see I will try to get the github thing working when I get home work computer is being weird
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So the ConsoleApp project will make a HttpClient, and that Client will make a request to the other project? The LearnApiVErsiojn one?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see ok
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
You guessed correctly! :)) Wait cant we usee Postman for this? btw I did this on my own:
using System.Xml.Serialization;

namespace helperPostal.Models
{
[XmlRoot("OK")]
public record class XMLPostal
{
[XmlElement("Criterio")] public Criterio? _Criterio;
[XmlElement("Result")] public Result? _Result;
[XmlElement("Localidade")] public Localidade? _Localidade;
}
public record class Criterio
{
[XmlElement("inDistrito")] public string? inDistrito;
[XmlElement("inConcelho")] public string? inConcelho;
[XmlElement("inLocal")] public string? inLocal;
[XmlElement("inRua")] public string? inRua;
[XmlElement("inPorta")] public string? inPorta;
[XmlElement("inCodPos")] public string? inCodPos;
[XmlElement("inCliente")] public string? inCliente;
[XmlElement("inIdLocal")] public string? inIdLocal;
[XmlElement("inIdRua")] public string? inIdRua;
[XmlElement("inEp")] public string? inEp;
[XmlElement("inApartado")] public string? inApartado;
[XmlElement("inIdEp")] public string? inIdEp;
[XmlElement("inPag")] public string? inPag;
[XmlElement("inMaxPag")] public string? inMaxPag;
[XmlElement("Id_Pesq")] public string? Id_Pesq;
}

public record class Result
{
[XmlElement("Pagina")] public string? Pagina;
}

public record class Localidade
{
[XmlElement("Designacao")] public string? Designacao;
[XmlElement("Distrito")] public string? Distrito;
[XmlElement("Concelho")] public string? Concelho;
[XmlElement("Freguesia")] public string? Freguesia;
[XmlElement("CodPos")] public CodPos? _CodPos;
}

public record class CodPos
{
[XmlElement("CP4")] public string? CP4;
[XmlElement("CP3")] public string? CP3;
[XmlElement("Designacao")] public string? Designacao;
[XmlElement("Geo")] public string? Geo;
}
}
using System.Xml.Serialization;

namespace helperPostal.Models
{
[XmlRoot("OK")]
public record class XMLPostal
{
[XmlElement("Criterio")] public Criterio? _Criterio;
[XmlElement("Result")] public Result? _Result;
[XmlElement("Localidade")] public Localidade? _Localidade;
}
public record class Criterio
{
[XmlElement("inDistrito")] public string? inDistrito;
[XmlElement("inConcelho")] public string? inConcelho;
[XmlElement("inLocal")] public string? inLocal;
[XmlElement("inRua")] public string? inRua;
[XmlElement("inPorta")] public string? inPorta;
[XmlElement("inCodPos")] public string? inCodPos;
[XmlElement("inCliente")] public string? inCliente;
[XmlElement("inIdLocal")] public string? inIdLocal;
[XmlElement("inIdRua")] public string? inIdRua;
[XmlElement("inEp")] public string? inEp;
[XmlElement("inApartado")] public string? inApartado;
[XmlElement("inIdEp")] public string? inIdEp;
[XmlElement("inPag")] public string? inPag;
[XmlElement("inMaxPag")] public string? inMaxPag;
[XmlElement("Id_Pesq")] public string? Id_Pesq;
}

public record class Result
{
[XmlElement("Pagina")] public string? Pagina;
}

public record class Localidade
{
[XmlElement("Designacao")] public string? Designacao;
[XmlElement("Distrito")] public string? Distrito;
[XmlElement("Concelho")] public string? Concelho;
[XmlElement("Freguesia")] public string? Freguesia;
[XmlElement("CodPos")] public CodPos? _CodPos;
}

public record class CodPos
{
[XmlElement("CP4")] public string? CP4;
[XmlElement("CP3")] public string? CP3;
[XmlElement("Designacao")] public string? Designacao;
[XmlElement("Geo")] public string? Geo;
}
}
Is this a noob thing? I basically figured out the XML body of the reply i get So I make a class for it so that I can just deserialize into a object and avoid weird parsing things that the original code was doing is this a bad idea? i did some testing and with dummy data its working fine! :D
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oke
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
O xd my only scary though is if the XML changes buuuuut it it would change there would be also problems with the orinial code so i think its ok?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Ohhhh didn't think about that!! Yeah it's starting to make a lot of sense Well maybe for this no But like overall
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Out of curiosity, why do they add that annotation? https://learn.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-5 I was looking thru this and they add the annotation [ResponseType(typeof(BookDetailDto))] in the Get method What does that do? Isnt the return type enoughf?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Okay im home im in a mac computer but i think since projects are cross platfor its fine ill try the git repo now Ok everything when finee :D https://github.com/juliodryfish/ASP.NET-C-Web-Service.git i can then just clone this is work computer and it will be fine i think
MODiX
MODiX2y ago
tebeco#0205
services.AddApiVersioning(options =>
{
options.ApiVersionReader = new UrlSegmentApiVersionReader();
});
services.AddVersionedApiExplorer(options =>
{
options.GroupNameFormat = "VV";
options.SubstituteApiVersionInUrl = true;
options.SubstitutionFormat = "VV";
});
return services;
services.AddApiVersioning(options =>
{
options.ApiVersionReader = new UrlSegmentApiVersionReader();
});
services.AddVersionedApiExplorer(options =>
{
options.GroupNameFormat = "VV";
options.SubstituteApiVersionInUrl = true;
options.SubstitutionFormat = "VV";
});
return services;
React with ❌ to remove this embed.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Good morning So I'm having a weird issue I redid a part of the code And it's not returning a JSON when I go to the endpoint The object has the correct values in memory But I might have messed up somewhere
public class CodigoPostalDTO
{
[JsonPropertyName("codpostal")] public string? CodPos;
[JsonPropertyName("designacao")] public string? Designacao;
[JsonPropertyName("distrito")] public string? Distrito;
[JsonPropertyName("concelho")] public string? Concelho;
[JsonPropertyName("freguesia")] public string? Frequesia;
[JsonPropertyName("rua")] public string? Rua;
}
public class CodigoPostalDTO
{
[JsonPropertyName("codpostal")] public string? CodPos;
[JsonPropertyName("designacao")] public string? Designacao;
[JsonPropertyName("distrito")] public string? Distrito;
[JsonPropertyName("concelho")] public string? Concelho;
[JsonPropertyName("freguesia")] public string? Frequesia;
[JsonPropertyName("rua")] public string? Rua;
}
This is what I did
júlio
júlioOP2y ago
júlio
júlioOP2y ago
This is what I do result is a CodigoPostalDTO I always get a {} in the response even if the object has values in the fields I have the NuGet packege System.Text.Json the method looks like this:
public async Task<IActionResult> GetAsync(string pesq)
public async Task<IActionResult> GetAsync(string pesq)
Its returning a IActionResult Anything I can try? O right I forget about that
FusedQyou
FusedQyou2y ago
I'm guessing you need to specify properties rather than fields. I don't think fields can be serialized.
public class CodigoPostalDTO
{
[JsonPropertyName("codpostal")]
public string? CodPos { get; set; }
public string? Designacao { get; set; }
public string? Distrito { get; set; }
public string? Concelho { get; set; }
public string? Frequesia { get; set; }
public string? Rua { get; set; }
}
public class CodigoPostalDTO
{
[JsonPropertyName("codpostal")]
public string? CodPos { get; set; }
public string? Designacao { get; set; }
public string? Distrito { get; set; }
public string? Concelho { get; set; }
public string? Frequesia { get; set; }
public string? Rua { get; set; }
}
You also don't need JsonPropertyName because the JSON is serialized as pascal case by default.
júlio
júlioOP2y ago
I will try that in a moment, thank you!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
That was it! thank you, i didntk know it was becasue of the get set thingy missing
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
im currently not using the newton json thingy I change to the System.Text.Json
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

</Project>
No its the one im making
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Im currently trying to clean a part of another code that i think it can be better
public class JsonResponse
{
public bool success = true;
public string errorMessage = "";
public dynamic data;
public string stack = "";
public bool sendReport = false;
public dynamic metadata;
public HttpStatusCode serverCode = HttpStatusCode.OK;

public JsonResponse(Type dataClass = null)
{
if (dataClass != null)
{
data = Activator.CreateInstance(dataClass);
}
else
{
data = new JObject();
}
}

public JObject ToJson()
{
JObject json = new JObject();
json["success"] = success;
json["errorMessage"] = errorMessage;
if (data is Stream)
{
StreamReader reader = new StreamReader((data as Stream));
json["data"] = reader.ReadToEnd();
}
else
{
json["data"] = data;
}
json["stack"] = stack;
json["sendReport"] = sendReport;
return json;
}
}
public class JsonResponse
{
public bool success = true;
public string errorMessage = "";
public dynamic data;
public string stack = "";
public bool sendReport = false;
public dynamic metadata;
public HttpStatusCode serverCode = HttpStatusCode.OK;

public JsonResponse(Type dataClass = null)
{
if (dataClass != null)
{
data = Activator.CreateInstance(dataClass);
}
else
{
data = new JObject();
}
}

public JObject ToJson()
{
JObject json = new JObject();
json["success"] = success;
json["errorMessage"] = errorMessage;
if (data is Stream)
{
StreamReader reader = new StreamReader((data as Stream));
json["data"] = reader.ReadToEnd();
}
else
{
json["data"] = data;
}
json["stack"] = stack;
json["sendReport"] = sendReport;
return json;
}
}
They have this object That they use all thru the project I dont know enought to tell if its okay to have this or if there are microsoft stuff for this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
xdd the scary part is
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I posted the whole
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Well They use it as a JSON result but with extra fields?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Yeah lemme see if i can find a small one
júlio
júlioOP2y ago
it loadede btw
júlio
júlioOP2y ago
this is going to be a pain to clean
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
it did, just after a while it showed 500 xd idk
Denis
Denis2y ago
Might I suggest to modify the public fields of the JsonResponse into properties, to easily see whether they are even used
júlio
júlioOP2y ago
goddamn it every method is so goddamn huge
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Denis
Denis2y ago
Question is why
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
public async Task<JsonResponse> WASD(long docId)
{
JsonResponse ret = new JsonResponse();

HttpResponseMessage response = await abReq.Get(new Uri(SOME_SECRET_STUFF));

if (response.StatusCode == HttpStatusCode.OK)
{

response = await abReq.Get(new Uri(string.Format(SOME_SECRET_STUFF, docId)));

if (response.StatusCode == HttpStatusCode.OK)
{
Stream bodyResponse = await response.Content.ReadAsStreamAsync();
if (await IsPDFHeader(bodyResponse))
{
ret.data = bodyResponse;
}
else
{
ret.success = false;
ret.stack = await response.Content.ReadAsStringAsync();
ret.errorMessage = ErrorStreamIsNotPdf;
}
}
else
{
ret.success = false;
}
}
return ret;
}
public async Task<JsonResponse> WASD(long docId)
{
JsonResponse ret = new JsonResponse();

HttpResponseMessage response = await abReq.Get(new Uri(SOME_SECRET_STUFF));

if (response.StatusCode == HttpStatusCode.OK)
{

response = await abReq.Get(new Uri(string.Format(SOME_SECRET_STUFF, docId)));

if (response.StatusCode == HttpStatusCode.OK)
{
Stream bodyResponse = await response.Content.ReadAsStreamAsync();
if (await IsPDFHeader(bodyResponse))
{
ret.data = bodyResponse;
}
else
{
ret.success = false;
ret.stack = await response.Content.ReadAsStringAsync();
ret.errorMessage = ErrorStreamIsNotPdf;
}
}
else
{
ret.success = false;
}
}
return ret;
}
Found one
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
most likely I completly removedf the previous DAO stuff Since they were useless
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
STJ meaning... :p
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
ohh ok
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
:(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
they told me the code was never reviewed
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
XD So is using it as is, will be bad for future? in not sure if the way it was made is bad or if the logic behind + the way it was made is bad
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh thats bad... its not i think I will get someplace where its used so you can see
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
Its only used for UnitTesting
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Nope, never used
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
correct xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
will do!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Btw I should have mentioned this the code 'im cleaning is inside AppBase AppBase is the base class for Apps (whatever that means) So looking at the structure
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
The thing in red They told me That the controllers use the functions thata are here so the Controllers have the endpoints and the things in red have extra code the AppBase.cs have 4 classes inside
júlio
júlioOP2y ago
júlio
júlioOP2y ago
So this is a thing... of these 4 classes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
only AppBase is used for inheritage
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oh right
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
The changes im making are in the test project
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oke
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
public class ValidationResult
{
public bool isValid = true;
public string errorMessasge = "";
}
public class ValidationResult
{
public bool isValid = true;
public string errorMessasge = "";
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
bad?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oke SO I make another class just for the ToJson?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well im having a issue JObject is from the Newton thiingy but Im nto using that anymore im using the System.Text.Json
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oh You just care to see if it compiles correctly?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
ok
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
oh wait i think i know the issue it was the ;
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oh my bad
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
I think so
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
i cant run the tests because it will try to connect to production database
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
corect
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I do that on the original? or now i move to my version? Because my version is not using Newton
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
good i think
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yep i figured
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
júlio
júlioOP2y ago
A bunch is used like this lemme see if i can find a small one
public async Task<JsonResponse> WASD(int year)
{
JsonResponse ret = new JsonResponse(typeof(JArray));
HttpRequestMessage request = new HttpRequestMessage();
HttpResponseMessage response = await abReq.Get(new Uri(SECRET_STUFF_I_THINK));
await ATAuthProcessLogin(await response.Content.ReadAsStreamAsync());

Uri _url = new Uri(string.Format(SECRET_STUFF_I_THINK, year));
response = await abReq.Get(_url);

if (response.StatusCode == HttpStatusCode.OK)
{
try
{
dynamic json = JObject.Parse(await response.Content.ReadAsStringAsync());
if (json.fieldErrors == null)
{
ret.data = json.declaracoes as JArray;
foreach (dynamic item in ret.data)
{
DateTime d = DateTime.Parse((string)item["SECRET_STUFF_I_THINK"]);
item["SECRET_STUFF_I_THINK"] = d.ToString("s");
}

}
}
catch
{
//
}
}

return ret;
}
public async Task<JsonResponse> WASD(int year)
{
JsonResponse ret = new JsonResponse(typeof(JArray));
HttpRequestMessage request = new HttpRequestMessage();
HttpResponseMessage response = await abReq.Get(new Uri(SECRET_STUFF_I_THINK));
await ATAuthProcessLogin(await response.Content.ReadAsStreamAsync());

Uri _url = new Uri(string.Format(SECRET_STUFF_I_THINK, year));
response = await abReq.Get(_url);

if (response.StatusCode == HttpStatusCode.OK)
{
try
{
dynamic json = JObject.Parse(await response.Content.ReadAsStringAsync());
if (json.fieldErrors == null)
{
ret.data = json.declaracoes as JArray;
foreach (dynamic item in ret.data)
{
DateTime d = DateTime.Parse((string)item["SECRET_STUFF_I_THINK"]);
item["SECRET_STUFF_I_THINK"] = d.ToString("s");
}

}
}
catch
{
//
}
}

return ret;
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
xd tell me i wanan laugh too Xd is bad?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
goddamn it the more i find out about this code the more I regret XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yes but you will cringe
júlio
júlioOP2y ago
júlio
júlioOP2y ago
júlio
júlioOP2y ago
they look the same cause they are the same but they come from different files same code in the body of the function but in differernt files idk man they did the virtual thing but they used the same code
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
its only called with either null or JArray
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
fck no XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
O right
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the first one is from the atrocious BaseController.cs, the second one inherits from the base controlelr
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
maybe some methods dont write to data idk ill try to find out
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
oboy
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I will do that o7
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
not yet one moment i am drinking iogurt
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
i see ok, good luck!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Sorry i've been away Yesterday I pulled a wisdom tooth out not been having a good time, can't really eat anything that isnt cold soup or stare at the computer without feeling a bit sick :(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
gush3l
gush3l2y ago
4208 messages
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ACiDCA7
ACiDCA72y ago
what is the highscore?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
4211, I'd like to be part of this piece of history
ACiDCA7
ACiDCA72y ago
so this is the thread with the highest amount of messages ever on this server.. wow
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sossenbinder
Sossenbinder2y ago
Why the hell does this help thread have so many responses Are you guys solving p np in here
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Oh lord
júlio
júlioOP2y ago
júlio
júlioOP2y ago
@TeBeConsulting might I suggest a different approach? I think I have a more sane solution to changin all that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Change all memebrs to private of the JsonResponse class and got to each error and comment and some other thing in the ToJosn thingy call ctor with values and not new and then fill values i think that was it make the construction in the return statement
public class JsonResponse
{
public bool success = true;
public string errorMessage = "";
public dynamic data;
public string stack = "";
public bool sendReport = false;
public dynamic metadata;
public HttpStatusCode serverCode = HttpStatusCode.OK;


public JsonResponse() : this(typeof(JObject)) { }

public JsonResponse(Type dataClass)
=> data = Activator.CreateInstance(dataClass);
}
public class JsonResponse
{
public bool success = true;
public string errorMessage = "";
public dynamic data;
public string stack = "";
public bool sendReport = false;
public dynamic metadata;
public HttpStatusCode serverCode = HttpStatusCode.OK;


public JsonResponse() : this(typeof(JObject)) { }

public JsonResponse(Type dataClass)
=> data = Activator.CreateInstance(dataClass);
}
My idea is first, rewrite this so that it uses System.Text.Json and now the NewtonJson thingy and theeeen as I split the things correct the small diferences Because Changing in the whole thing at once its insane I would be 100% lost all the time because I dont know the code that well right now I alreaddy succesfully split 2 services the one Im splitting and the next ones are the ones that use that JsonResult thing so I think this is a good oportunity to fix it before splitting and when I split ill correct the code in the other places, no?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well in the original project yes but im changing to sysmte.text.jsno
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yeah that is dones everywhere we use a JsonResult
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Every JsonResult has something in the data
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
OhNo
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Isnt there something out there that does this? Cause I feel like they tried to reinvent some wheel
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I dont understand why it would impact the front end :( maybe i dont undertstand the problem
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well crap why didnt they review the code that was going to be part of such a crucial part of the company i swear to god small panic okay so just so I understand we are working with this crap, but what are the changes you suggest going to do? make it less crap? because i forgot
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
because I asked and I was told "you must keep the version support, because some customers have older versions or don't want to update to newer version" I would assume the customer i think? I donno :(
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Well both I think because we are changing Usually client has the program in Delphi and that program talks with us
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
us being the service and stuff
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
but now they are doing like stuff in browser that in the future will replace the desktop
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
no that will stay
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
fuck do I know man I just do that they tell me to do XD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
there is a Rest made in Delphi
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
and there is the client made in Delphi
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
you mena, does the delphi client talk with this service? sorry i get confused with words sometimes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
good question
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I will ask
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
TS meaning...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Well
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
That would be good, thing is I dont run the company
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
The people that do, they want to keep having support for all kinds of clients
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
:( I dunno man
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I'm just a junior developer
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I agree with what you say but I have no power herer
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I ask the guys before me "What interacts with the service" "the delphi cliente or only the cloud" he replyed "it doesnt matter" so either he deosnt know or im not supposed to make assumptions to what will interact with the service
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
yep
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Delphi client is still maintained and will keep being maintained
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the more we dig the more I space out plus the mouth pain from the teeth are getting so annyoign ughhhhhhhhh im sad about this feeling lost i might just use the old thing that is done too much has been build on top of it to change
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I could only do that once I got the thing working
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
well the links care about version
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm okay only one thing I dont understand well I kinda understand but I want to make sure you are tellimg me to do a bunch of differnet kinds of Ctors because you want to make the properties private, and instead of creating a empty instance at the beginning of the function and slowly filling it up, you want to directly return a instance in the return statement is that it? and this is somehow better? This is the part I dont 100% understand, is encapsulation the only factor?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see Makes sense now :) Thank you for explaining again they would remaing public then? Imma do that Ill start slow Ill start with the current one Im splitting
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
its the smalles of them all that uses that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I dont wanna touch the big one for this :( isnt it better to do it while I split them? same amount of work just done in different times
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
the original the big service
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I guess yeah
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
DI meaning dependency injection?
Pobiega
Pobiega2y ago
Kek?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
sibber
sibber2y ago
now its 4500
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
FusedQyou
FusedQyou2y ago
Wowee this thread finally finished
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
So I'm having a big problem Goddamn it I need to show code but can't rn I'm being monitored In 1 hour and 40 minuts more or less I will put the code Basically The old code was using some old stuff that don't exist anymore HttpContext.Request.Query.GetValue() This took in a String key and String valueIfKeyNotFound And returned the value for the key or second parameter Since this does not exist, I found something similar HttpContext.Rewuest.Query.TryGetValue() that takes in a Key and a reference to the place were it will store the result or the default value for the type of not found But I'm getting the compiler mad and I'm not sure what to do Well I did something that I think worked lol but it's kinda cursed I'll show code in a bit
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Xd Hello Can you confirm is something makes sense or is insane before I talk about the thing above? I just found out that a Sha1 key was stored in the Resources Is this dumb? Aren't the resources meant for like files n stuff? Images or whatever Also, won't this break cross platform? Original service uses the Resources to store a Sha1 secret Is this normal? Then they have to have a Resources.Designer class thing to query the secret I'm a nood but I think this is kinda insane Please correct me :( Maybe it's not insane bigthonk
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
danilwhale
danilwhale2y ago
why this have 4544 (now 4545) messages omegalul
júlio
júlioOP2y ago
So the HttpContext contains the things I pass to the service? Like the parameters in the url for example?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Hmmm I see I'm having a JSON problem If success and a object has fields, it does everything correct If it has null, instead for getting a {} I get 204 No Content I have no clue why, any tips I can try? It used to return {} I don't know what changed Oh snap in the afternoon I'm going to a meeting to talk about what I did so far Kinda hyped kinda nervous I just hope I don't forget anything xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
I see Noted! I think having JSON problems will be my day to day I'm having the most weird problem Sicne yesterday I managed to get the original service running thankfully I'm testing out one endpoint Same code Basically the only thing that changed was .NET version and the JsonResult object changed a bit The original Service correctly fills the JsonResponse object and returns the correct Json My Service apparently correctly fills the JsonResponse object but then when I go to return i get {} If I try to force it to convert to JSON by calling the .ToJson thingy, I get the most cursed JSON ever Lemme get some prints to show 1 sec
júlio
júlioOP2y ago
This is the normal return of the Object (it should get implicit converted to JSON)
júlio
júlioOP2y ago
This is me forcing the conversion to JSON by calling .ToJson
júlio
júlioOP2y ago
júlio
júlioOP2y ago
This is the contents of the object in memory, at the moment of the return So it has the things inside The object in the service has the same contents the memory looks the same but this one shows nothing or trash and the original shows the correct thing :( Any tips on how to aproach this? I got nowere yesterday
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
júlio
júlioOP2y ago
not solved, still issues :L
FusedQyou
FusedQyou2y ago
😦
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
mr_technocal
mr_technocal2y ago
For clarity, the Microsoft.AspNetCore.Mvc.Versioning* are effectively EOL. Since the 6.0 and .NET 6+ release, you should now use Asp.Versioning.* packages. Most things look, feel, and are named the same. If you're going to organize by folder, you might find it more convenient to use a convention rather than attributes. For example:
c#
services.AddApiVersioning(options =>
{
options.ApiVersionReader = new UrlSegmentApiVersionReader();
options.Conventions.Add(new VersionByNamespaceConvention());
});
c#
services.AddApiVersioning(options =>
{
options.ApiVersionReader = new UrlSegmentApiVersionReader();
options.Conventions.Add(new VersionByNamespaceConvention());
});
Assuming the full type name was My.Api.Controllers.V1.FooController, the version 1.0 would be applied without using any attributes. Conventions are not mutually exclusive and can be combined with other conventions, attributes. etc.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
júlio
júlioOP2y ago
Nope! I solved it actually I've been away from discord but i've made a lot of progress so far! I got every service split now, aaaaand i added docker support to the projects So now I'm focusing on the Docker / Kubernetes aspect I do have a bunch of questions but I think I will make a new thread for them, since they arent much on topic of this original thread idk
basically, i am little cat
Oh god 4615 messages here already
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FusedQyou
FusedQyou2y ago
Keep it in this thread and make it even bigger
Monsieur Wholesome
Youve started this, now youve got to commit
júlio
júlioOP2y ago
OhNo
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
Exactly one relation requires third table afaik - m to n (many to many). To create that relationship we need helper table that has 1 to n (one to many) with both the tables that have have m to n
júlio
júlioOP2y ago
not only a kinda of 1 to 1 can required 3 tables aswell and some other cases that requires another table exist too
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Florian Voß
Florian Voß2y ago
in what other cases? also ellaborate on that 1 to 1 case that requires 3 tables pls
júlio
júlioOP2y ago
1 to 1 non mandatory on each side requires 3 tables other cases depends on the kinds of columns in the tables
Florian Voß
Florian Voß2y ago
I think those cases would be against 3NF rules
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
júlio
júlioOP2y ago
Ah yes im not focusing i was just anwsering the questions xd The table I created was very basic no relations not relly
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
sibber
sibber2y ago
damn still not solved
FusedQyou
FusedQyou2y ago
Damn
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?