This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"ConnectionString": "User ID=gasstation;Password=123Aa321;Host=192.168.0.4;Port=6543;Database=station;", | |
"DefaultDatabase": "Postgres" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"ConnectionString": "Data Source=localhost,11433;Initial Catalog=testeDb;User ID=sa;Password=123Aa321", | |
"DefaultDatabase": "SqlServer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.4' | |
services: | |
gasstation.api: | |
environment: | |
- ASPNETCORE_ENVIRONMENT=Development | |
ports: | |
- "4444:80" | |
sql.server: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => |
NewerOlder