Skip to content

Instantly share code, notes, and snippets.

View brunomartinspro's full-sized avatar
🚀

Bruno Martins brunomartinspro

🚀
View GitHub Profile
@brunomartinspro
brunomartinspro / IMicrosoftAspNetCoreIdentityUtils.cs
Last active June 11, 2018 12:58
Generate User Two Factor Security Code from Microsoft.AspNetCore.Identity
using System.Threading.Tasks;
using BrunoMartinsPro.Data.Models;
namespace BrunoMartinsPro.Utils.MicrosoftAspNetCoreIdentity
{
public interface IMicrosoftAspNetCoreIdentityUtils
{
Task<string> GenerateUserTwoFactorSecurityCode(ApplicationUser user, string securityType);
}
}
@brunomartinspro
brunomartinspro / AutoMapperProfile.cs
Created June 11, 2018 18:34
Configure AutoMapper in ASP.NET Core
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using BrunoMartinsPro.Models.Report;
using BrunoMartinsPro.DTO.Report;
namespace BrunoMartinsPro.Config
{
@brunomartinspro
brunomartinspro / CSVUtils.cs
Created June 12, 2018 14:30
Generic CSV Export using CSVHelper
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CsvHelper;
using BrunoMartinsPro.Data.Interfaces.Utils.CSV;
@brunomartinspro
brunomartinspro / DocumentModel.cs
Last active June 13, 2018 15:33
Convert property to a enum from a XML Object
namespace BrunoMartinsPro
{
public class DocumentModel
{
public long DocumentId { get; set; }
public MetadataModel Metadata { get; set; }
}
}
@brunomartinspro
brunomartinspro / IJsonHttpClient.cs
Last active June 14, 2018 15:18
Generic JSON HttpClient
using System.Threading.Tasks;
namespace BrunoMartinsPro.Http
{
public interface IJsonHttpClient
{
/// <summary>
/// Add Request Headers
/// </summary>
/// <param name="name"></param>
@brunomartinspro
brunomartinspro / ADUtils.cs
Last active June 21, 2018 22:43
Get Active Active Directory Users based on List of usernames
using System;
using System.Linq;
using System.Collections.Generic;
using System.DirectoryServices;
using BrunoMartinsPro.Data.Interfaces.Utils.ActiveDirectory;
namespace BrunoMartinsPro.Utils.ActiveDirectory
{
public class ADUtils : IADUtils
{
@brunomartinspro
brunomartinspro / MSSQLServiceBrokerUtils.sql
Last active July 5, 2018 11:36
SQL Server Service Broker Utils
-- Verify the state of the service broker in SQL Server Management Studio
-- Database -> Properties -> Options -> Service Broker Tab -> Broker Enabled
-- To enable broker
ALTER DATABASE [database] SET ENABLE_BROKER
-- To disable broker
ALTER DATABASE [database] SET DISABLE_BROKER
-- When having multiple service brokers, each service broker must have an unique identifier to run.
@brunomartinspro
brunomartinspro / Startup.cs
Last active July 9, 2018 22:11
[ASP.NET Core] Enable HTTPS rewrite
...
using Microsoft.AspNetCore.Mvc
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Primitives;
namespace BrunoMartinsPro.Startup
{
public class Startup
{
@brunomartinspro
brunomartinspro / Startup.cs
Created July 9, 2018 22:26
[ASP.NET Core] Deactivate default authentication challenge (Account/Login)
...
namespace BrunoMartinsPro.Startup
{
public class Startup
{
...
public Startup(IHostingEnvironment env)
{
@brunomartinspro
brunomartinspro / AutoMapperConfig.cs
Created July 10, 2018 11:30
Use AutoMapper to map properties
using AutoMapper;
using BrunoMartinsPro.Data;
namespace BrunoMartinsPro.Config
{
public class AutoMapperConfig
{
/// <summary>
/// Initialize and configure AutoMapper Mappings
/// </summary>