Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ReviewService.Domain.Entities;

namespace ReviewService.Domain.Repositories;
namespace ReviewService.Application.Interfaces.Repositories;

public interface IGenericRepository<TEntity> where TEntity : class, IEntity, new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ReviewService.Domain.Entities;

namespace ReviewService.Domain.Repositories;
namespace ReviewService.Application.Interfaces.Repositories;

public interface IReviewRepository : IGenericRepository<ReviewEntity>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using ReviewService.Application.Interfaces.Services;
using ReviewService.Application.Services.Extensions;
using ReviewService.Domain.Entities;
using ReviewService.Domain.Repositories;
using ReviewService.Application.Interfaces.Repositories;

namespace ReviewService.Application.Services.Operations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,80 @@
namespace ReviewService.Domain.Entities;
public class ReviewEntity : IEntity
{
private string _title = null!;
private string _movieId = null!;
private string _content = null!;
private string _author = null!;
private int _rating = 0;

public Guid Id { get; set; }
public string MovieId { get; set; } = null!;
public string Title { get; set; } = null!;
public string Content { get; set; } = null!;
public string Author { get; set; } = null!;

public string MovieId
{
get => _movieId;
set
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("MovieId cannot be null or empty.");
}
_movieId = value;
}
}

public string Title
{
get => _title;
set
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Title cannot be null or empty.");
}
_title = value;
}
}

public string Content
{
get => _content;
set
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Content cannot be null or empty.");
}
_content = value;
}
}

public string Author
{
get => _author;
set
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Author cannot be null or empty.");
}
_author = value;
}
}

public DateTime CreatedOn { get; set; } = DateTime.UtcNow;
public IEnumerable<string> UpvotedBy { get; set; } = [];
public IEnumerable<string> DownvotedBy { get; set; } = [];
public int Rating { get; set; } = 0;

public int Rating
{
get => _rating;
set
{
if (value is < 0 or > 5)
{
throw new ArgumentOutOfRangeException(nameof(Rating), "Rating must be between 0 and 5.");
}
_rating = value;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using AutoMapper;
using MongoDB.Driver;
using MongoDB.Entities;
using ReviewService.Domain.Repositories;
using ReviewService.Application.Interfaces.Repositories;

namespace ReviewService.Infrastructure.Repository.Repositories;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using AutoMapper;
using MongoDB.Driver;
using ReviewService.Domain.Entities;
using ReviewService.Domain.Repositories;
using ReviewService.Application.Interfaces.Repositories;
using ReviewService.Infrastructure.Repository.Documents;

namespace ReviewService.Infrastructure.Repository.Repositories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ReviewService.Application.Interfaces\ReviewService.Application.Interfaces.csproj" />
<ProjectReference Include="..\ReviewService.Domain\ReviewService.Domain.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static void RegisterRepositories(IServiceCollection serviceCollection)
{
// Register your repositories here
// Example: serviceCollection.AddScoped<IReviewRepository, ReviewRepository>();
serviceCollection.AddScoped<Domain.Repositories.IReviewRepository, ReviewService.Infrastructure.Repository.Repositories.ReviewRepository>();
serviceCollection.AddScoped<Application.Interfaces.Repositories.IReviewRepository, ReviewService.Infrastructure.Repository.Repositories.ReviewRepository>();
}
private static void RegisterInitializersAndProviders(IServiceCollection serviceCollection)
{
Expand Down
Loading