Se hizo toda la parte del Unit Of Work y estoy a punto de terminar la de tests unitarios
This commit is contained in:
Alejandro Sarmiento
2024-02-28 22:40:34 +01:00
parent b55f2be085
commit 81a3e91d6e
67 changed files with 1112 additions and 1375 deletions

View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34607.119
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MandarCorreo", "MandarCorreo\MandarCorreo.csproj", "{9033A5CD-22DD-40DF-907F-E7F23A6CB5C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9033A5CD-22DD-40DF-907F-E7F23A6CB5C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9033A5CD-22DD-40DF-907F-E7F23A6CB5C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9033A5CD-22DD-40DF-907F-E7F23A6CB5C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9033A5CD-22DD-40DF-907F-E7F23A6CB5C6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CB12919E-932A-4A8F-870B-DFE108FDD721}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,28 @@
using System.Net.Mail;
using System.Net;
try
{
SmtpClient client = new SmtpClient("mail.asarmiento.es", 587)
{
Credentials = new NetworkCredential("alejandro@asarmiento.es", "Toledo.480200"),
EnableSsl = true
};
MailMessage mailMessage = new MailMessage
{
From = new MailAddress("alejandro@asarmiento.es"),
Subject = "Vacaciones de este año",
Body = "Este año me da que no vamos a tener vacaciones =(",
IsBodyHtml = false,
};
mailMessage.To.Add("alejandro.sarsan@gmail.com");
client.Send(mailMessage);
Console.WriteLine("Correo enviado con éxito.");
}
catch (Exception ex)
{
Console.WriteLine("No se pudo enviar el correo. Error: " + ex.Message);
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,6 @@
@MongoProject.API_HostAddress = http://localhost:5197
GET {{MongoProject.API_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@@ -0,0 +1,23 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:34210",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5197",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,17 @@
using MongoProject.Domain.Common;
namespace MongoProject.Domain
{
public class Actor : BaseDomainModel
{
public Actor()
{
Videos = new HashSet<Video>();
}
public string? Nombre { get; set; }
public string? Apellido { get; set; }
public virtual ICollection<Video>? Videos { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MongoProject.Domain.Common
{
public abstract class BaseDomainModel
{
public int Id { get; set; }
public DateTime? CreatedDate { get; set; }
public string? CreatedBy { get; set; }
public DateTime? LastModifiedDate { get; set; }
public string? LastModifiedBy { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
namespace MongoProject.Domain.Common
{
public abstract class ValueObject
{
protected static bool EqualOperator(ValueObject left, ValueObject right)
{
if (left is null ^ right is null)
{
return false;
}
return ReferenceEquals(left, right) || left.Equals(right);
}
protected static bool NotEqualOperator(ValueObject left, ValueObject right)
{
return !(EqualOperator(left, right));
}
protected abstract IEnumerable<object> GetEqualityComponents();
public override bool Equals(object obj)
{
if (obj == null || obj.GetType() != GetType())
{
return false;
}
var other = (ValueObject)obj;
return this.GetEqualityComponents().SequenceEqual(other.GetEqualityComponents());
}
public override int GetHashCode()
{
return GetEqualityComponents()
.Select(x => x != null ? x.GetHashCode() : 0)
.Aggregate((x, y) => x ^ y);
}
// Other utility methods
}
}

View File

@@ -0,0 +1,13 @@
using MongoProject.Domain.Common;
namespace MongoProject.Domain
{
public class Director : BaseDomainModel
{
public string? Nombre { get; set; }
public string? Apellido { get; set; }
public int VideoId { get; set; }
public virtual Video? Video { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,16 @@
using MongoProject.Domain.Common;
namespace MongoProject.Domain
{
public class Streamer : BaseDomainModel
{
public int Id { get; set; }
public DateTime? CreatedDate { get; set; }
public string? CreatedBy { get; set; }
public DateTime? LastModifiedDate { get; set; }
public string? LastModifiedBy { get; set; }
public string? Nombre { get; set; }
public string? Url { get; set; }
public ICollection<Video>? Videos { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
using MongoProject.Domain.Common;
namespace MongoProject.Domain
{
public class Video : BaseDomainModel
{
public Video()
{
Actores = [];
}
public string? Nombre { get; set; }
public int StreamerId { get; set; }
public virtual Streamer? Streamer { get; set; }
public int? DirectorId { get; set; }
public virtual Director? Director { get; set; }
public virtual ICollection<Actor>? Actores { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using MongoProject.Domain.Common;
namespace MongoProject.Domain
{
public class VideoActor : BaseDomainModel
{
public int VideoId { get; set; }
public virtual Video? Video { get; set; }
public int ActorId { get; set; }
public virtual Actor? Actor { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,60 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34607.119
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{529D43D8-F144-4D48-B288-95CB3A180D65}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API", "API", "{9E57EC3A-4903-499C-A438-DD9D2FC0A3B3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{24633152-BD8D-42B7-BC1D-0D4A9DE1F181}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{89FFD380-F129-41F0-9A5D-94FE5FBB5266}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoProject.Application", "MongoProject.Application\MongoProject.Application.csproj", "{BD54D679-B40F-48D6-9FFD-792FBD8FCCA4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoProject.Domain", "MongoProject.Domain\MongoProject.Domain.csproj", "{65F56A3D-BB3C-4F1F-8F23-A3033EDC2AEB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoProject.Infrastructure", "MongoProject.Infrastructure\MongoProject.Infrastructure.csproj", "{EE7D69D7-BDC7-4879-8466-58A2310BFC36}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoProject.API", "MongoProject.API\MongoProject.API.csproj", "{F237EEC3-972D-48EE-81E9-170FEDEF866F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BD54D679-B40F-48D6-9FFD-792FBD8FCCA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD54D679-B40F-48D6-9FFD-792FBD8FCCA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD54D679-B40F-48D6-9FFD-792FBD8FCCA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD54D679-B40F-48D6-9FFD-792FBD8FCCA4}.Release|Any CPU.Build.0 = Release|Any CPU
{65F56A3D-BB3C-4F1F-8F23-A3033EDC2AEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65F56A3D-BB3C-4F1F-8F23-A3033EDC2AEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65F56A3D-BB3C-4F1F-8F23-A3033EDC2AEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65F56A3D-BB3C-4F1F-8F23-A3033EDC2AEB}.Release|Any CPU.Build.0 = Release|Any CPU
{EE7D69D7-BDC7-4879-8466-58A2310BFC36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE7D69D7-BDC7-4879-8466-58A2310BFC36}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE7D69D7-BDC7-4879-8466-58A2310BFC36}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE7D69D7-BDC7-4879-8466-58A2310BFC36}.Release|Any CPU.Build.0 = Release|Any CPU
{F237EEC3-972D-48EE-81E9-170FEDEF866F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F237EEC3-972D-48EE-81E9-170FEDEF866F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F237EEC3-972D-48EE-81E9-170FEDEF866F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F237EEC3-972D-48EE-81E9-170FEDEF866F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9E57EC3A-4903-499C-A438-DD9D2FC0A3B3} = {529D43D8-F144-4D48-B288-95CB3A180D65}
{24633152-BD8D-42B7-BC1D-0D4A9DE1F181} = {529D43D8-F144-4D48-B288-95CB3A180D65}
{89FFD380-F129-41F0-9A5D-94FE5FBB5266} = {529D43D8-F144-4D48-B288-95CB3A180D65}
{BD54D679-B40F-48D6-9FFD-792FBD8FCCA4} = {24633152-BD8D-42B7-BC1D-0D4A9DE1F181}
{65F56A3D-BB3C-4F1F-8F23-A3033EDC2AEB} = {24633152-BD8D-42B7-BC1D-0D4A9DE1F181}
{EE7D69D7-BDC7-4879-8466-58A2310BFC36} = {89FFD380-F129-41F0-9A5D-94FE5FBB5266}
{F237EEC3-972D-48EE-81E9-170FEDEF866F} = {9E57EC3A-4903-499C-A438-DD9D2FC0A3B3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ABD21FD9-C4B4-4EDF-83C2-F6A6207C89A3}
EndGlobalSection
EndGlobal