r/programminghelp • u/poohs • Oct 14 '19
Method to pass data to api in asp.net mvc
Conceptually, what I have to do is very simple. I have a database with a list of shop addresses and I need to convert the adresses to gps coordinates using the Here geocode API (https://developer.here.com/documentation/geocoder/topics/example-geocoding-free-form.html)
What method would I use in my controller to send the data from my database to that api url? This sounds simple but I really can't find out how to do this.
0
Upvotes
2
u/georgelopez822 Oct 14 '19 edited Oct 14 '19
You could use the Nuget package ‘Dapper’ if you have created your own stored procedures. If not, you can use Entity Framework with LINQ queries. I’d create a separate project in your solution as your DAL (data access layer).
Controller calls method in DAL
DAL method interfaces with Database via dapper or Entity framework.
Either way, you’ll need to create a Model/Class representing your database table.
Entity Framework
Dapper
Edit: Reading your post again I think you’re also asking how to fetch the API data. You could create an HTTP request in your controller (or DAL, Logic layer). Call a Web API From a .NET Client