Skip to content

Instantly share code, notes, and snippets.

💭
Coding AI...

Simon Gilbert sahgilbert

💭
Coding AI...
Block or report user

Report or block sahgilbert

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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()
{
@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 / 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);
}
You can’t perform that action at this time.