Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Increasing revenue/reducing costs...

Simon Gilbert sahgilbert

💭
Increasing revenue/reducing costs...
View GitHub Profile
@sahgilbert
sahgilbert / NumericalExtensions.cs
Created May 22, 2019
Numerical Extension Methods - C# .Net Core
View NumericalExtensions.cs
using System;
namespace SimonGilbert.Blog
{
public static class NumericalExtensions
{
public static double RoundByDecimalPlaces(this double number, int numberOfDecimalPlaces = 2)
{
return Math.Round(number, numberOfDecimalPlaces);
}
@sahgilbert
sahgilbert / DateTimeExtensions.cs
Created May 22, 2019
DateTime Extension Methods - C# .Net Core
View DateTimeExtensions.cs
using System;
namespace SimonGilbert.Blog
{
public static class DateTimeExtensions
{
public static string ToRelativeDate(this DateTime dateTime)
{
var timeSpan = DateTime.Now - dateTime;
@sahgilbert
sahgilbert / UnifiedController.cs
Created Jun 3, 2019
C# ASP.Net Core - Unified MVC & Web Api Controller
View UnifiedController.cs
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace SimonGilbert.Blog.Controllers
{
public class UnifiedController : Controller
{
[HttpGet]
public IActionResult Index()
{