<file_sep>﻿using System;

namespace Macaria.Core.Exceptions
{
    public class DomainException: Exception
    {
        public int Code { get; set; } = 0;
    }
}
<file_sep>﻿using Macaria.Core.Interfaces;
using Macaria.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace Macaria.Infrastructure.Extensions
{
    public static class ServiceCollectionExtensions
    {                
        public static IServiceCollection AddDataStore(this IServiceCollection services,
                                               string connectionString)
        {
            services.AddScoped<IAppDbContext, AppDbContext>();

            services.AddDbContext<AppDbContext>(options =>
            {                
                options
                .UseLoggerFactory(AppDbContext.ConsoleLoggerFactory)
                .UseSqlServer(connectionString, b=> b.MigrationsAssembly("Macaria.Infrastructure"));
            });

            return services;
        }
    }
}
<file_sep># Api Code Organization<file_sep># Introduction to MediatR and CQRS