Skip to content

Instantly share code, notes, and snippets.

View marraia's full-sized avatar

Fernando Mendes marraia

View GitHub Profile
public Student Insert(Student input)
{
if (input.Age <= 0)
_notification.NewNotificationBadRequest("Campo idade é obrigatório");
if (string.IsNullOrEmpty(input.Nome))
_notification.NewNotificationBadRequest("Campo nome é obrigatório");
if (!_notification.IsValid())
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ExemploNotifications.Domain;
using ExemploNotifications.Domain.Services.Abstraction;
using Marraia.Notifications.Base;
using Marraia.Notifications.Models;
using MediatR;
using Microsoft.AspNetCore.Http;
using ExemploNotifications.Domain.Services.Abstraction;
using Marraia.Notifications.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace ExemploNotifications.Domain.Services
{
public class StudentDomainService : IStudentDomainService
"ConnectionString": "User ID=gasstation;Password=123Aa321;Host=192.168.0.4;Port=6543;Database=station;",
"DefaultDatabase": "Postgres"
"ConnectionString": "Data Source=localhost,11433;Initial Catalog=testeDb;User ID=sa;Password=123Aa321",
"DefaultDatabase": "SqlServer"
CREATE DATABASE testeDB
GO
CREATE TABLE [dbo].[Station] (
[Id] [int] IDENTITY(1,1) NOT NULL,
[Nome] [varchar](50) NOT NULL,
[Endereco] [varchar](50) NOT NULL,
[Telefone] [varchar](50) NOT NULL
)
version: '3.4'
services:
gasstation.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "4444:80"
sql.server:
CREATE SCHEMA meuschema AUTHORIZATION station;
CREATE TABLE meuschema.station(
id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
nome VARCHAR(50) NOT NULL,
endereco VARCHAR(50) NOT NULL,
telefone VARCHAR(50) NOT NULL,
) WITH (OIDS = FALSE)
TABLESPACE pg_default;
public class RepositoryBase<TEntity, TKey> : IRepositoryBase<TEntity, TKey>, IDisposable
where TEntity : EntityBase<TKey>
where TKey : struct
{
protected readonly DbSet<TEntity> _db;
protected readonly GasStationContext _context;
protected RepositoryBase(GasStationContext context)
{
_context = context;
void RegisterServices(IServiceCollection services)
{
if (Configuration.GetSection("DefaultDatabase").Value == "Postgres")
{
services.AddDbContext<GasStationContext>(
options => options.UseNpgsql(Configuration.GetSection("ConnectionString").Value));
}
else
{
services.AddDbContext<GasStationContext>(options =>