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,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; }
}
}