Skip to content

Instantly share code, notes, and snippets.

View evgomes's full-sized avatar

Evandro Gomes evgomes

View GitHub Profile
@evgomes
evgomes / all_email_provider_domains.txt
Created May 19, 2024 00:32 — forked from ammarshah/all_email_provider_domains.txt
A list of all email provider domains (free, paid, blacklist etc). Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
0-mail.com
007addict.com
020.co.uk
027168.com
0815.ru
0815.su
0clickemail.com
0sg.net
0wnd.net
0wnd.org
@evgomes
evgomes / CategoryRepositoryADO.cs
Created September 2, 2019 23:29
ADO.NET implementation example of a repository.
public class CategoryRepositoryADO : ICategoryRepository
{
public async Task<IEnumerable<Category>> ListAsync()
{
var categories = new List<Category>();
using(var connection = new SqlConnection("connection_string"))
using(var command = new SqlCommand())
{
command.Connection = connection;
@evgomes
evgomes / AppDbContext.cs
Created February 4, 2019 23:03
AppDbContext with products, from Supermarket API
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Category>().ToTable("Categories");
builder.Entity<Category>().HasKey(p => p.Id);
builder.Entity<Category>().Property(p => p.Id).IsRequired().ValueGeneratedOnAdd().HasValueGenerator<InMemoryIntegerValueGenerator<int>>();
builder.Entity<Category>().Property(p => p.Name).IsRequired().HasMaxLength(30);
builder.Entity<Category>().HasMany(p => p.Products).WithOne(p => p.Category).HasForeignKey(p => p.CategoryId);
@evgomes
evgomes / ConfigureServices.cs
Created February 4, 2019 23:00
Last edit of ConfigureServices, from Supermarket API
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddDbContext<AppDbContext>(options =>
{
options.UseInMemoryDatabase("supermarket-api-in-memory");
});
services.AddScoped<ICategoryRepository, CategoryRepository>();
@evgomes
evgomes / ProductService.cs
Created February 4, 2019 22:54
ProductService from Supermarket API
using System.Collections.Generic;
using System.Threading.Tasks;
using Supermarket.API.Domain.Models;
using Supermarket.API.Domain.Repositories;
using Supermarket.API.Domain.Services;
namespace Supermarket.API.Services
{
public class ProductService : IProductService
{
@evgomes
evgomes / ProductRepository.cs
Created February 4, 2019 22:52
ProductRepository of Supermarket API
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Supermarket.API.Domain.Models;
using Supermarket.API.Domain.Repositories;
using Supermarket.API.Persistence.Contexts;
namespace Supermarket.API.Persistence.Repositories
{
public class ProductRepository : BaseRepository, IProductRepository
@evgomes
evgomes / IProductRepository.cs
Created February 4, 2019 22:48
IProductRepository of Supermarket API
using System.Collections.Generic;
using System.Threading.Tasks;
using Supermarket.API.Domain.Models;
namespace Supermarket.API.Domain.Repositories
{
public interface IProductRepository
{
Task<IEnumerable<Product>> ListAsync();
}
@evgomes
evgomes / IProductService.cs
Created February 4, 2019 22:45
IProductService of Supermarket API
using System.Collections.Generic;
using System.Threading.Tasks;
using Supermarket.API.Domain.Models;
namespace Supermarket.API.Domain.Services
{
public interface IProductService
{
Task<IEnumerable<Product>> ListAsync();
}
@evgomes
evgomes / ProductsController.cs
Created February 4, 2019 22:42
ProductsController from Sueprmarket API
using System.Collections.Generic;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
using Supermarket.API.Domain.Models;
using Supermarket.API.Domain.Services;
using Supermarket.API.Resources;
namespace Supermarket.API.Controllers
{
@evgomes
evgomes / ModelToResourceProfile.cs
Created February 4, 2019 22:34
ModelToResourceProfile with product mapping, of Supermarket API
using AutoMapper;
using Supermarket.API.Domain.Models;
using Supermarket.API.Extensions;
using Supermarket.API.Resources;
namespace Supermarket.API.Mapping
{
public class ModelToResourceProfile : Profile
{
public ModelToResourceProfile()