Creating a 'Work from Home' log using .NET Core and Winforms

I’ve spent most of my time on the Front End in web apps, with limited time on the server side. One of my earlier projects was a personal project called Mile Money which used NodeJS app. Originally written with server rendered pages using EJS I then rewrote the app as an API with an Angular frontend. This was 2.5 years ago. Since then I’ve been all front end, until now.

In my attempt to go ‘Full Stack’ I’ve been delving into writing C# (.Net Core), and understanding the basics of Object Oriented Programming. As they say in Programming, the best way to learn, is to do! Which is what I did.

Work From Home Logger

As with most projects, it’s important to pick something that either interests you, or will be useful to you (or both) in order to get your own personal ‘buy in’ to the time commmittment. Due to this, I decided to write a little app using .NET Core and Winforms to help me track my days working from home which will ultimately help me with tax return time.

Why Winforms? I was asked this a few times, I think because it is considered by many to be ‘old tech’. I used it as a straightforward way to get into writing and focussing on the code aspect, whilst also having a neat UI editor.

work from home logger user interface

The app is quite straightforward in it’s final state, which does the below:

It ‘listens’ to system session events, using SystemEvents

If I unlock my machine, and I had not previously created a new ‘workday’ on that date, then the form will popup. I can then select ‘Yes’ or ‘No’ to “Are you working from home”. I went down this route after having a first attempt at the app where I input my home IP Address which, if it matched any of the current active IPs it would perform some sort of action. I abandoned this idea and decided to KISS.

It knows if there’s a previous workday created

Through simple try, catch blocks, it creates a new workday, if there’s an existing record with that date, then it creates an exception which is caught and the UI is updated to inform the user.

catching exceptions

It’s tested using MSTest

Using the MSTest library, I wrote unit tests, particularly around the WorkPlace repository part of the project as this is where most of the heavy lifting happens.

visual studio test explorer

What next

THis is a super simply project in terms of the scope, which was my objective. Otherwise I want to keep adding features and it never is ‘done’. I really just wanted to get more hands on with .NET Core and increase my understanding which I definitely achieved.

The source code for this project is on Github.

Get in contact

Complete the form below to get in contact with me 😃