Skip to content

Commit

Permalink
Merge pull request #24 from ilyasbozdemir/case-project
Browse files Browse the repository at this point in the history
Association and Seed Data for WorkInventory Entities
  • Loading branch information
ilyasbozdemir authored Apr 30, 2024
2 parents f489989 + 9fcda4b commit e834e1c
Show file tree
Hide file tree
Showing 59 changed files with 12,964 additions and 8,885 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public record BookDTO : BaseAuditableDTO<Guid>

public DateTime PublicationDate { get; init; } // Yayın Tarihi
public DateTime OriginalPublicationDate { get; init; } // Orijinal Yayın Tarihi
public BookStatus Status { get; init; } // Kitap Durumu
public BookFormat Format { get; init; } // Kitap Formatı
public BookLanguage Language { get; init; } // Kitap Dili
public WorkStatus Status { get; init; } // Kitap Durumu
public WorkFormat Format { get; init; } // Kitap Formatı
public string Language { get; init; } // Kitap Dili
public bool IsDamaged { get; init; } // Hasar Durumu
public string Description { get; init; } // Açıklama
public string CoverImageUrl { get; init; } // Kapak Resmi URL'i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public record CreateBookDto : BaseAuditableDTO<Guid>
public Guid PublisherId { get; init; } // Yayıncı ID
public DateTime PublicationDate { get; init; } // Yayın Tarihi
public DateTime OriginalPublicationDate { get; init; } // Orijinal Yayın Tarihi
public BookStatus Status { get; init; } // Kitap Durumu
public BookFormat Format { get; init; } // Kitap Formatı
public BookLanguage Language { get; init; } // Kitap Dili
public WorkStatus Status { get; init; } // Kitap Durumu
public WorkFormat Format { get; init; } // Kitap Formatı
public string Language { get; init; } // Kitap Dili
public bool IsDamaged { get; init; } // Hasar Durumu
public string Description { get; init; } // Açıklama
public string CoverImageUrl { get; init; } // Kapak Resmi URL'i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<CreateBookGenreCommandResponse> Handle(CreateBookGenreCommandR
try
{
var existinBookGenre = await _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookGenre>()
.GetReadRepository<Domain.Entities.Library.WorkGenre>()
.ExistsAsync(b =>
b.Name == request.Name
);
Expand All @@ -37,7 +37,7 @@ public async Task<CreateBookGenreCommandResponse> Handle(CreateBookGenreCommandR
StateMessages = new string[] { "Bu bilgilere sahip bir tür zaten mevcut." }
};
}
var newBookGenre = new Domain.Entities.Library.BookGenre()
var newBookGenre = new Domain.Entities.Library.WorkGenre()
{
Name = request.Name,
IsActive= request.IsActive,
Expand All @@ -54,7 +54,7 @@ public async Task<CreateBookGenreCommandResponse> Handle(CreateBookGenreCommandR
IsActive = request.IsActive,
};

var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookGenre>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkGenre>();
bool isAdded = await writeRepository.AddAsync(newBookGenre);
if (isAdded)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<DeleteBookGenreCommandResponse> Handle(DeleteBookGenreCommandR
try
{

var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.BookGenre>();
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.WorkGenre>();

Guid bookId;
bool isGuid = Guid.TryParse(request.Id, out bookId);
Expand All @@ -40,7 +40,7 @@ public async Task<DeleteBookGenreCommandResponse> Handle(DeleteBookGenreCommandR
}
else
{
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookGenre>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkGenre>();
bool isDeleted = await writeRepository.DeleteAsync(existingBookGenre);
if (isDeleted)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<UpdateBookGenreCommandResponse> Handle(UpdateBookGenreCommandR
{
try
{
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.BookGenre>();
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.WorkGenre>();

var existingBookGenre = await readRepository.GetSingleAsync(s => s.Id == request.UpdatedId);
if (existingBookGenre == null)
Expand All @@ -36,7 +36,7 @@ public async Task<UpdateBookGenreCommandResponse> Handle(UpdateBookGenreCommandR
}
else
{
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookGenre>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkGenre>();

existingBookGenre.Name = request.Name;
existingBookGenre.IsActive = request.IsActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public async Task<GetAllBookGenresQueryResponse> Handle(GetAllBookGenresQueryReq
int PageIndex = request.PageIndex;

var readRepository = _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookGenre>();
.GetReadRepository<Domain.Entities.Library.WorkGenre>();

var BookGenreList = readRepository.GetAll();

var bookGenreDtoList = new List<BookGenreDTO>();

foreach (BookGenre libraryBranch in BookGenreList)
foreach (WorkGenre libraryBranch in BookGenreList)
{
bookGenreDtoList.Add(new BookGenreDTO
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task<GetBookGenreQueryResponse> Handle(GetBookGenreQueryRequest req
try
{
var readRepository = _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookGenre>();
.GetReadRepository<Domain.Entities.Library.WorkGenre>();


var existingBookGenre = await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class BookMappingProfile : Profile
{
public BookMappingProfile()
{
CreateMap<BookCatalog, BookDTO>().ReverseMap();
CreateMap<BookCatalog, CreateBookCommandRequest>().ReverseMap();
CreateMap<WorkCatalog, BookDTO>().ReverseMap();
CreateMap<WorkCatalog, CreateBookCommandRequest>().ReverseMap();
CreateMap<BookDTO, CreateBookCommandRequest>().ReverseMap();

// lazım olan yerde burda map'leme yapılabilir.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class CreateBookCommandRequestValidator : AbstractValidator<CreateBookCom
{
public CreateBookCommandRequestValidator()
{
RuleFor(book => book.AudioFilePath).NotEmpty().When(book => book.Format == BookFormat.AudioBook);
RuleFor(book => book.FilePath).NotEmpty().When(book => book.Format == BookFormat.EBook);
RuleFor(book => book.AudioFilePath).NotEmpty().When(book => book.Format == WorkFormat.AudioBook);
RuleFor(book => book.FilePath).NotEmpty().When(book => book.Format == WorkFormat.EBook);

//geri kalanlarda yazılcaktır.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task<CreateBookCommandResponse> Handle(CreateBookCommandRequest req

try
{
var existingBook = await _unitOfWork.GetReadRepository<Domain.Entities.Library.BookCatalog>()
var existingBook = await _unitOfWork.GetReadRepository<Domain.Entities.Library.WorkCatalog>()
.ExistsAsync(b => b.ISBN == request.ISBN);

if (existingBook)
Expand All @@ -40,11 +40,11 @@ public async Task<CreateBookCommandResponse> Handle(CreateBookCommandRequest req



var newBook = _mapper.Map<Domain.Entities.Library.BookCatalog>(request);
var newBook = _mapper.Map<Domain.Entities.Library.WorkCatalog>(request);
newBook.Id = Guid.NewGuid();


var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookCatalog>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkCatalog>();
bool isAdded = await writeRepository.AddAsync(newBook);

if (isAdded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task<DeleteBookCommandResponse> Handle(DeleteBookCommandRequest req
try
{

var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.BookCatalog>();
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.WorkCatalog>();

Guid bookId;
bool isGuid = Guid.TryParse(request.IdOrISBN, out bookId);
Expand All @@ -39,7 +39,7 @@ public async Task<DeleteBookCommandResponse> Handle(DeleteBookCommandRequest req
}
else
{
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookCatalog>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkCatalog>();
bool isDeleted = await writeRepository.DeleteAsync(existingBookStock);
if (isDeleted)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task<UpdateBookCommandResponse> Handle(UpdateBookCommandRequest req
{
try
{
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.BookCatalog>();
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.WorkCatalog>();

var existingBook = await readRepository.GetSingleAsync(s => s.Id == request.Id);

Expand All @@ -33,18 +33,17 @@ public async Task<UpdateBookCommandResponse> Handle(UpdateBookCommandRequest req

else
{
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookCatalog>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkCatalog>();

existingBook.Title = request.Title;
existingBook.ISBN = request.ISBN;
existingBook.PageCount = request.PageCount;
existingBook.PublicationDate = request.PublicationDate;
//existingBook.PublicationDate = request.PublicationDate;
existingBook.BookStatus = request.Status;
existingBook.Description = request.Description;
existingBook.PublicationDate = request.PublicationDate;
existingBook.Summary = request.Summary;
existingBook.OriginalPublicationDate = request.OriginalPublicationDate;
existingBook.BookFormat = request.BookFormat;
existingBook.BookLanguage = request.BookLanguage;
existingBook.WorkLanguage = request.BookLanguage;
existingBook.GenreId = request.GenreId;
existingBook.PublisherId = request.PublisherId;
existingBook.AuthorId = request.AuthorId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CreateBookCommandRequest : IRequest<CreateBookCommandResponse>


[JsonConverter(typeof(JsonStringEnumConverter))]
public BookStatus Status { get; init; } = BookStatus.Active; // Kitap Durumu
public WorkStatus Status { get; init; } = WorkStatus.Active; // Kitap Durumu
public Guid GenreId { get; init; } // Tür Id'si
public Guid PublisherId { get; init; } // Yayıncı Id'si
public Guid LibraryBranchId { get; init; } // Kütüphane Şube Id'si
Expand All @@ -25,9 +25,9 @@ public class CreateBookCommandRequest : IRequest<CreateBookCommandResponse>
public DateTime OriginalPublicationDate { get; init; } // Orijinal Yayın Tarihi

[JsonConverter(typeof(JsonStringEnumConverter))]
public BookFormat Format { get; init; } // Kitap Formatı
public WorkFormat Format { get; init; } // Kitap Formatı

[JsonConverter(typeof(JsonStringEnumConverter))]
public BookLanguage Language { get; init; } // Kitap Dili

public string WorkLanguage { get; init; } // Kitap Dili
public bool IsFeatured { get; init; } // Öne Çıkarılmış mı?
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ public class UpdateBookCommandRequest : IRequest<UpdateBookCommandResponse>
public string ISBN { get; set; } // Yeni ISBN
public int PageCount { get; set; } // Yeni sayfa sayısı
public string Publisher { get; set; } // Yeni yayıncı
public string Description { get; set; }
public string Summary { get; set; }
public string CoverImageUrl { get; set; }
public DateTime PublicationDate { get; set; } // Yeni yayın tarihi
public DateTime OriginalPublicationDate { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public BookStatus BookStatus { get; set; }
public WorkStatus BookStatus { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public BookFormat BookFormat { get; set; }
public WorkFormat BookFormat { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public BookLanguage BookLanguage { get; set; }
public string BookLanguage { get; set; }
public bool IsFeatured { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public BookStatus Status { get; set; } // Yeni kitap durumu
public WorkStatus Status { get; set; } // Yeni kitap durumu

public Guid GenreId { get; set; }
public Guid PublisherId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<GetBookQueryResponse> Handle(GetBookQueryRequest request, Canc
try
{
var readRepository = _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookCatalog>();
.GetReadRepository<Domain.Entities.Library.WorkCatalog>();


var existingAuthor = await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<CreateBookPublisherCommandResponse> Handle(CreateBookPublisher
try
{
var existinBookPublisher = await _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookPublisher>()
.GetReadRepository<Domain.Entities.Library.WorkPublisher>()
.ExistsAsync(b =>
b.Name == request.Name
);
Expand All @@ -37,7 +37,7 @@ public async Task<CreateBookPublisherCommandResponse> Handle(CreateBookPublisher
StateMessages = new string[] { "Bu bilgilere sahip bir yayınevi zaten mevcut." }
};
}
var newBookPublisher = new Domain.Entities.Library.BookPublisher()
var newBookPublisher = new Domain.Entities.Library.WorkPublisher()
{
Name = request.Name,
Website = request.Website,
Expand All @@ -61,7 +61,7 @@ public async Task<CreateBookPublisherCommandResponse> Handle(CreateBookPublisher
PhoneNumber = request.PhoneNumber,
};

var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookPublisher>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkPublisher>();
bool isAdded = await writeRepository.AddAsync(newBookPublisher);
if (isAdded)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<DeleteBookPublisherCommandResponse> Handle(DeleteBookPublisher
try
{

var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.BookPublisher>();
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.WorkPublisher>();

Guid bookId;
bool isGuid = Guid.TryParse(request.Id, out bookId);
Expand All @@ -40,7 +40,7 @@ public async Task<DeleteBookPublisherCommandResponse> Handle(DeleteBookPublisher
}
else
{
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookPublisher>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkPublisher>();
bool isDeleted = await writeRepository.DeleteAsync(existingBookPublisher);
if (isDeleted)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task<UpdateBookPublisherCommandResponse> Handle(UpdateBookPublisher
{
try
{
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.BookPublisher>();
var readRepository = _unitOfWork.GetReadRepository<Domain.Entities.Library.WorkPublisher>();

var existingBookPublisher = await readRepository.GetSingleAsync(s => s.Id == request.UpdatedId);
if (existingBookPublisher == null)
Expand All @@ -36,7 +36,7 @@ public async Task<UpdateBookPublisherCommandResponse> Handle(UpdateBookPublisher
}
else
{
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.BookPublisher>();
var writeRepository = _unitOfWork.GetWriteRepository<Domain.Entities.Library.WorkPublisher>();

existingBookPublisher.Name = request.Name;
existingBookPublisher.Website = request.Website;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public async Task<GetAllBookGenresQueryResponse> Handle(GetAllBookPublishersQuer
int PageIndex = request.PageIndex;

var readRepository = _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookGenre>();
.GetReadRepository<Domain.Entities.Library.WorkGenre>();

var BookGenreList = readRepository.GetAll();

var bookGenreDtoList = new List<BookGenreDTO>();

foreach (BookGenre libraryBranch in BookGenreList)
foreach (WorkGenre libraryBranch in BookGenreList)
{
bookGenreDtoList.Add(new BookGenreDTO
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task<GetBookPublisherQueryResponse> Handle(GetBookPublisherQueryReq
try
{
var readRepository = _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookPublisher>();
.GetReadRepository<Domain.Entities.Library.WorkPublisher>();


var existingBookPublisher = await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CancellationToken cancellationToken
try
{
var existingBook = await _unitOfWork
.GetReadRepository<Domain.Entities.Library.BookCatalog>()
.GetReadRepository<Domain.Entities.Library.WorkCatalog>()
.ExistsAsync(b => b.Id == request.BookId);


Expand Down
Loading

0 comments on commit e834e1c

Please sign in to comment.