-
Notifications
You must be signed in to change notification settings - Fork 3
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 #6 from vicheanath/git-repo
Add Test and restructure folder project
- Loading branch information
Showing
287 changed files
with
590 additions
and
249 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
src/SearchBugs.Application/Git/DeleteGitRepo/DeleteGitCommandValidator.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,14 @@ | ||
using FluentValidation; | ||
using Shared.Extensions; | ||
|
||
namespace SearchBugs.Application.Git.DeleteGitRepo; | ||
|
||
internal sealed class DeleteGitCommandValidator : AbstractValidator<DeleteGitRepoCommand> | ||
{ | ||
public DeleteGitCommandValidator() | ||
{ | ||
RuleFor(x => x.Url) | ||
.NotEmpty() | ||
.WithError(GitValidationErrors.UrlIsRequired); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/SearchBugs.Application/Git/DeleteGitRepo/DeleteGitRepoCommandHandler.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,34 @@ | ||
using SearchBugs.Domain; | ||
using SearchBugs.Domain.Repositories; | ||
using Shared.Messaging; | ||
using Shared.Results; | ||
|
||
namespace SearchBugs.Application.Git.DeleteGitRepo; | ||
|
||
public sealed class DeleteGitRepoCommandHandler : ICommandHandler<DeleteGitRepoCommand> | ||
{ | ||
private readonly IGitRepository _gitRepository; | ||
private readonly IUnitOfWork _unitOfWork; | ||
|
||
public DeleteGitRepoCommandHandler(IGitRepository gitRepository, IUnitOfWork unitOfWork) | ||
{ | ||
_gitRepository = gitRepository; | ||
_unitOfWork = unitOfWork; | ||
} | ||
|
||
public async Task<Result> Handle(DeleteGitRepoCommand request, CancellationToken cancellationToken) | ||
{ | ||
var gitRepo = await _gitRepository.GetByUrlAsync(request.Url, cancellationToken); | ||
|
||
if (gitRepo.IsFailure) | ||
{ | ||
return Result.Failure(GitValidationErrors.GitRepoNotFound); | ||
} | ||
|
||
await _gitRepository.Remove(gitRepo.Value); | ||
|
||
await _unitOfWork.SaveChangesAsync(cancellationToken); | ||
|
||
return Result.Success(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,21 @@ | ||
using Shared.Errors; | ||
|
||
namespace SearchBugs.Domain.Bugs; | ||
|
||
internal static class BugsErrors | ||
{ | ||
internal static Error TitleIsRequired => new Error("Bug.TitleIsRequired", "Title is required"); | ||
internal static Error InvalidBugStatus => new Error("Bug.InvalidStatus", "Invalid bug status"); | ||
|
||
internal static Error InvalidBugPriority => new Error("Bug.InvalidPriority", "Invalid bug priority"); | ||
|
||
internal static Error InvalidBugSeverity => new Error("Bug.InvalidSeverity", "Invalid bug severity"); | ||
|
||
internal static Error InvalidProjectId => new Error("Bug.InvalidProjectId", "Invalid project id"); | ||
|
||
internal static Error InvalidAssigneeId => new Error("Bug.InvalidAssigneeId", "Invalid assignee id"); | ||
|
||
internal static Error InvalidReporterId => new Error("Bug.InvalidReporterId", "Invalid reporter id"); | ||
|
||
internal static Error InvalidTitle => new Error("Bug.InvalidTitle", "Invalid title"); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Shared.Primitives; | ||
|
||
namespace SearchBugs.Domain.Bugs; | ||
|
||
public record TimeTracingId(Guid Value) : IEntityId | ||
{ | ||
public static TimeTracingId New => new(Guid.NewGuid()); | ||
} |
File renamed without changes.
File renamed without changes.
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,18 @@ | ||
using Shared.Primitives; | ||
using Shared.Results; | ||
using System.Linq.Expressions; | ||
|
||
namespace SearchBugs.Domain; | ||
|
||
public interface IRepository<TEntity, TEntityId> | ||
where TEntity : Entity<TEntityId> | ||
where TEntityId : class, IEntityId | ||
{ | ||
Task<Result> Add(TEntity entity); | ||
|
||
Task<Result<TEntity>> GetByIdAsync(IEntityId id, CancellationToken cancellationToken = default, params Expression<Func<TEntity, object>>[] includes); | ||
|
||
Task<Result> Remove(TEntity entity); | ||
|
||
Task<Result> Update(TEntity entity); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
namespace SearchBugs.Domain.Projects; | ||
|
||
public interface IProjectRepository : IRepository<Project, ProjectId> | ||
{ | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,8 @@ | ||
using Shared.Results; | ||
|
||
namespace SearchBugs.Domain.Repositories; | ||
|
||
public interface IGitRepository : IRepository<Repository, RepositoryId> | ||
{ | ||
Task<Result<Repository>> GetByUrlAsync(string url, CancellationToken cancellationToken = default); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,32 @@ | ||
using Shared.Errors; | ||
|
||
namespace SearchBugs.Domain.Services; | ||
|
||
public static class Ensure | ||
{ | ||
public static Error NotNull<T>(T value, Error error) | ||
{ | ||
return value == null ? error : Error.None; | ||
} | ||
|
||
public static Error NotNullOrEmpty<T>(T value, Error error) | ||
{ | ||
return value == null || string.IsNullOrEmpty(value.ToString()) ? error : Error.None; | ||
} | ||
|
||
public static Error NotNullOrWhiteSpace(string value, Error error) | ||
{ | ||
return string.IsNullOrWhiteSpace(value) ? error : Error.None; | ||
} | ||
|
||
public static Error NotNegative<T>(T value, Error error) | ||
{ | ||
return value switch | ||
{ | ||
int i when i < 0 => error, | ||
long l when l < 0 => error, | ||
decimal d when d < 0 => error, | ||
_ => Error.None | ||
}; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.