My Reverie

MyReverie is a new simple side project I am working on. The idea is to build a goal tracking solution set target dates against those goals as well as set milestone markers to track progress. They could be long or short term goals – entirely up to the user.

I will routinely push the code at certain points to GitHub under MyReverie Repo.

I have a rough idea of some of the features to add which I will list under the Projects Tab of GitHub.

This is also a way to experiment and learn new technologies as I go, some technologies I will be looking to incorporate are Asp.Net Core, Swagger, Docker,  xUnit.Net and EF Core so far.

I would like to have this solution created in a Micro Services style architecture – so functionality abstracted to services.

I will break this solution out to different blog posts as the solution is going to continue to grow.

The solution is not intended to be a complete sample or starter app more of a reference or exploration on learning.

In this post I will begin with the Goals API

Okay, let’s get started.

I want to create this entirely in Code so lets go to Visual Studio and create a new ASP.Net Core project.

I am using Visual Studio 2017 Community version 15.7.1

After clicking File->New Project, I want to select ASP.NET Core Web Application

ASPNetCoreWebApp

Lets call the project name ‘Goal.API’ and Solution Name ‘MyReverie’ as below, I want to also also select ‘Create new Git repository’ to commit using Git

NameprojSol

Lets choose the API template and select ASP.Net Core 2.1 under the dropdown as well as uncheck ‘Enable Docker support’ for now and clock OK

Template

After restore of packages has completed, lets run the API to ensure it build and runs successfully,After launching add /api/values to the end of the URL and you should see something similar as below.

RunApp

Great, we have created our Solution as well as our Goal API.

Let’s go ahead and create 2 new folders in our solutions, src and Services, Services being a child of src and lets move the API project under Services as below.

SolStructure

That’s it for this post, next post will continue to build upon this solution

ASP.NET Core Web API with Docker

This post simply demonstrates creating a simple service called ‘AdditionMicroservice’ that adds two numbers provided as query string parameters.

I will add this code to my GitHub account under Getting started with Microservices repo

Pre-requisites:
Docker for Windows

1) Create a new ASP.NET Core Web Application project

image

Select the Web API Template

image

Check the Enable Docker Support checkbox

Select Windows as the OS

Click

Open Values Controller file under Controllers

image 

Remove all other methods except first Get method and change to below as below

image

The change  launchUrl’s from api/value to api/addition in launchsettngs.json file:

image

Run the app and append to the URL both the x and y parameters along with their set values to view the result:

image

Visual Studio 2015 debugging lambda expressions

Debugging Lambda expressions is certainly a very welcome feature of Visual Studio 2015. Before when trying to evaluate lambda expressions within either the watch or immediate windows we would see the message “Expression cannot contain lambda expressions”.

The great thing about this feature is that it really speeds up the diagnoses of possible bugs being faced within your application and being able to really dig in to your collections and query the data right there and then on the fly.

For instance if you are retrieving a result set from a collection but not getting the results you are expecting, you can now query the collection using lambda expressions within either the immediate or watch window during debug to give you a direct view of what data is resident within your collection that particular point in time, from there you can then dynamically make changes to your query within the immediate or watch windows necessary to confirm your hypothesis of why you are not seeing the results you were expecting – all while in debug mode without having to perform that oh so fun process of stop debugging –> make a change –> re-run –> confirm results if yes stop else go again.

Once you confirm that you are now getting the results expected from your changes you can then go ahead an make the necessary adjustments to your source code.

This is really well demonstrated by Andrew Hall in the below video.