Latest Posts
Tuesday, August 3, 2021
In the last post we created our ACME Bank database in MySQL, the next step is to get the values from the Values table in the Asp.Net Core WebApi controller.
Let's create some test data so that we could retrieve the values from the database. The Values table could contain anything. So I am going to store famous philosophers throughout history. These philosophers are so famous that they only have one name:
You can run the SQL insert statement below to seed the data in MySQL:
INSERT INTO acmebank.Values ( Name ) VALUES ( 'Socrate' ), ( 'Plato' ), ( 'Spock' ), ( 'Thanos' );
So your Values table should look like this when you executed the insert query
Thursday, July 8, 2021
Before we run our Asp.Net Core application for the first time we are going to copy a controller from Asp.Net Core 2.2 to help us create the skeleton for our application. A skeleton are the plumbings we do at the beginning of our application to make sure all the mechanisms work. It's called the ValuesController which has been replaced with a more complicated WeatherForecastController. The ValuesController is just a lot easier to work with to get things set up.
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; namespace ACMEBank.API.Controllers { [Route("api/[controller]")] [ApiController] public class ValuesController : ControllerBase { // GET api/values [HttpGet] public ActionResult> Get() { return new string[] { "value1", "value2" }; } // GET api/values/5 [HttpGet("{id}")] public ActionResult Get(int id) { return "value"; } // POST api/values [HttpPost] public void Post([FromBody] string value) { } // PUT api/values/5 [HttpPut("{id}")] public void Put(int id, [FromBody] string value) { } // DELETE api/values/5 [HttpDelete("{id}")] public void Delete(int id) { } } }
Thursday, July 1, 2021
For those of you who works with Visual Studio, working with C# comes out of the box, but with Visual Studio Code you need to install some extensions from the Marketplace to make it suitable for C# development.
Here are the extensions you need to install:
- C#: This extension by Microsoft gives us IntelliSense, references, code editing and highlighting and debugging support
- C# Extensions: This extension let's you create C# files, like classes and interfaces also some keyboard shortcuts like creating. This one seems to be no longer in development for a long time, but it works fine.