-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from lucasdaquina/feat/db-setup
Feat/db setup
- Loading branch information
Showing
17 changed files
with
530 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
13 changes: 13 additions & 0 deletions
13
src/SM.Medication.Application/SM.Medication.Application.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\SM.Medication.Domain\SM.Medication.Domain.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace SM.Medication.Domain.Common; | ||
public class AuditableEntity | ||
{ | ||
public string? CreatedBy { get; set; } | ||
public string? ModifiedBy { get; set; } | ||
public DateTime CreatedAt { get; set; } | ||
public DateTime ModifiedAt { get; set; } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SM.Medication.Domain.Common; | ||
|
||
public class BaseEntity : AuditableEntity | ||
{ | ||
public int Id { get; set; } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using SM.Medication.Domain.Common; | ||
|
||
namespace SM.Medication.Domain.Entities; | ||
|
||
public class Medication : BaseEntity | ||
{ | ||
public string? Name { get; set; } | ||
|
||
private int _quantity; | ||
[Range(1, int.MaxValue)] | ||
public int Quantity | ||
{ | ||
get { return _quantity; } | ||
set | ||
{ | ||
if (value < 1) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(value), "Quantity must be greater than 0"); | ||
} | ||
_quantity = value; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
</Project> |
43 changes: 43 additions & 0 deletions
43
src/SM.Medication.Infrastructure/Mapping/MedicationMapping.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace SM.Medication.Infrastructure.Mapping; | ||
public class MedicationMapping : IEntityTypeConfiguration<SM.Medication.Domain.Entities.Medication> | ||
{ | ||
public void Configure(EntityTypeBuilder<SM.Medication.Domain.Entities.Medication> builder) | ||
{ | ||
builder.ToTable("Medication"); | ||
builder.HasKey(x => x.Id); | ||
|
||
builder.Property(p => p.Id) | ||
.HasColumnName("MedicationId") | ||
.ValueGeneratedOnAdd(); | ||
|
||
builder.Property(p => p.Name) | ||
.HasColumnName("Name") | ||
.HasMaxLength(100) | ||
.IsRequired(); | ||
|
||
builder.Property(p => p.Quantity) | ||
.HasColumnName("Quantity") | ||
.IsRequired(); | ||
|
||
builder.Property(p => p.CreatedAt) | ||
.HasColumnName("CreatedAt") | ||
.IsRequired(); | ||
|
||
builder.Property(p => p.CreatedBy) | ||
.HasColumnName("CreatedBy") | ||
.HasMaxLength(100) | ||
.IsRequired(); | ||
|
||
builder.Property(p => p.ModifiedAt) | ||
.HasColumnName("ModifiedAt") | ||
.IsRequired(); | ||
|
||
builder.Property(p => p.ModifiedBy) | ||
.HasColumnName("ModifiedBy") | ||
.HasMaxLength(100) | ||
.IsRequired(); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
src/SM.Medication.Infrastructure/Migrations/20240726082831_InitialDataBase.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.