Tag: c#
Why you should use a DTO to send to your API instead of the class itself
IWhen I first started putting together the API for my dnd app, I was just using whatever model I had on the backend as the expected argument from the body. This worked fine for basic stuff, but eventually I ran into a problem. Take a look at my location class: In it, I say that… Read more
How to change from a string input to an enum input using an an Angular app sending to a C# API
Lets say you have a class that needs to use an enum, for instance in dungeons and dragons, you have a monster class that is going to have an alignment. Defining the enum is simple enough, define the enum Now, change where you were previously using a string input to an alignment input Change the… Read more
How to quickly make an API controller for a data object in C#
If you need a quick API controller, first make sure you are using Microsoft.AspNetCore.Mvc, then inherit the base class. I am going to do it for locations here: You’ll note this part: The first part defines the route for your api. [controller] will be replaced with the name of the class -Controller. In other words,… Read more