Tech Junkie Blog - Real World Tutorials, Happy Coding!: ACME Bank

Latest Posts

Showing posts with label ACME Bank. Show all posts
Showing posts with label ACME Bank. Show all 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 29, 2021

 In this post we are going to create our first Entity Framework migration and creating an actual database in MySQL. 

In order to do that we need to add a few NuGet packages to our Asp.Net Core project including the Entity Framework Core package.  But, before we do that we want to find out what what version of .NET Core we are running.  Obviously I have it memorized, but for the rest of you, you can type the command dotnet --version to figure out what the version is :)  It's always a good idea to try and match the package version with the .NET Core runtime you have.  It's one of the more annoying thing with Angular and Asp.Net Core, it's changing constantly. So as you can see my version 3.1.xxx so I should try to install packages that are made for 3.1.x.

The first package we are going to install is the Microsoft.EntityFrameworkCore.  So open the ACMEBank.API project with Visual Studio Code.  Press Ctrl+Shift+P and type NuGet and select

Tuesday, July 20, 2021

 In this post we are going to install MySQL Workbench on Fedora.  MySQL Workbench is a great GUI database management tool for MySQL.  Even though we can do everything we need with MySQL on the terminal it's nice sometime to see the tables and data visually.

Here are the steps to install MySQL Workbench:

1, Go to the yum repository for MySQL at https://dev.mysql.com/downloads/repo/yum/ select the Fedora repository, and click "Download"

Tuesday, July 13, 2021

 In this post we are going to circle back to MySQL and continue setting up our MySQL database, so that we can use it in our application.  Since we don't want to use our root for log in and we turned off root login for remote connection.  We have to create a dedicated user for our application.  Here are the steps to create a dedicated dev use in MySQL

1. Log into MySQL with root using this command mysql -u root -p

2.  In the MySQL prompt type CREATE User 'devuser'@'localhost' IDENTIFIED BY 'P@ssw0rd'; to create the user, obviously if this is your production environment you would want to use a more secure password

3. Then type GRANT ALL PRIVILEGES ON *.* TO 'devuser'@'localhost' WITH GRANT OPTION; to grant the user all the privileges on all the objects

4. Now type FLUSH PRIVILEGES; to update and apply the privileges

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.


Just create a new controller in the "Controllers" and call it "ValuesController.cs" Here is the code for it.
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.

  • NuGet Package Manager: This extension let's us install new NuGet packages which we will need from time to time.

Tuesday, June 22, 2021

The most important thing for most modern dynamic application these day is choosing a database to store your data.  If you are on a Windows environment then you use SQL Server database that is a fine choice. But if you are on Linux MySQL is a great choice also.  In this post we are going to go through how to install MySQL server on our Fedora development machine.

Here are the steps to install MySQL on Fedora Linux:

1. First we need to add the MySQL repository to our machine by tying in the following command in the terminal

sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc32-1.noarch


Tuesday, June 15, 2021

In this post we going to get our development environment with NodeJS, VSCode and Postman

The Urls are the following, if you are developing in Linux you should install the Linux version.  All these tools are cross platform so you can develop in either Windows, Linux or MacOS:

.NET Core: https://dotnet.microsoft.com/download

Node.JS: https://nodejs.org/en/

Visual Studio Code: https://code.visualstudio.com/#alt-downloads

Postman: https://www.postman.com/downloads/

For .NET Core make sure you download the "recommended" version and not the preview version. Also with NodeJS, usually it has LTS status.

Installing .NET Core SDK and NodeJS On Fedora

In order to install .NET Core SDK on Fedora open the terminal and type in the following

sudo dnf install dotnet-sdk-3.1 -y

The -y tells Fedora to skip the y/N prompt and just go on with the install

Once the SDK is installed you can verify the install with the command dotnet --version



















Tuesday, June 8, 2021

The first thing we want to do is set up the Google Chrome browser on a Linux instance, I've decided to use a virtualized Fedora workstation as my development machine.  You can use Windows if you want, it would be a lot easier.  It doesn't really matter because Asp.Net Core works on Linux as well.  Google Chrome has the best development tools and it also has an extension call Postman.  Although you want to install the standalone version of Postman.  Here are the steps to install Google Chrome on Linux

I wrote a post on how to set Fedora as your development machine here

1. Navigate to the URL https://www.google.com/chrome/

2. Click on "Download Chrome"

Google chrome download page

Search This Blog