-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modifing the database, repos, adding some Serivces, and start servic…
…e implementation
- Loading branch information
Abdullah Ahmed
committed
Oct 10, 2024
1 parent
6fce5c7
commit 2a2a652
Showing
47 changed files
with
915 additions
and
965 deletions.
There are no files selected for viewing
91 changes: 87 additions & 4 deletions
91
src/Application.BLL/Services/Implementation/BookService.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 |
---|---|---|
@@ -1,12 +1,95 @@ | ||
using System; | ||
using Application.DAL; | ||
using Application.DAL.UnitOfWork; | ||
using Application.Shared; | ||
using AutoMapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using System.Threading.Tasks; | ||
namespace Application.BLL | ||
{ | ||
public class BookService | ||
public class BookService : IBookService | ||
{ | ||
|
||
private readonly IUnitOfWork _unitOfWork; | ||
private readonly IMapper _mapper; | ||
|
||
public async Task AddBook(CreateBookDto createBookDto) | ||
{ | ||
/// Get Category using its Id | ||
/// Id will based through drop down list the display is category_name, and the value is category_id | ||
var Category = await _unitOfWork.CategoryRepository.GetByIdAsync(createBookDto.CategoryId); | ||
|
||
/// Category Validation | ||
if (Category != null) | ||
{ | ||
/// get Authors via search by names | ||
List<ApplicationUser> authors = new List<ApplicationUser>(); | ||
foreach(var AuthorName in createBookDto.AuthorNames) | ||
{ | ||
ApplicationUser Author = await _unitOfWork.UserRepository.GetUserByNameAsync(AuthorName); | ||
|
||
/// Author Existence validation | ||
if (Author == null) | ||
throw new Exception($"Author {AuthorName} Doesn't Exists"); | ||
authors.Add(Author); | ||
|
||
} | ||
|
||
if (createBookDto.PublicationYear > DateTime.UtcNow.Year) | ||
throw new Exception("PublicationYear Not Valid"); | ||
|
||
var Book = new Book() | ||
{ | ||
Title = createBookDto.Title, | ||
ISBN = createBookDto.ISBN, | ||
IsDeleted = false, | ||
CoverUrl = createBookDto.CoverUrl, | ||
Category = Category, | ||
CategoryId = Category.CategoryId, | ||
Loans = new List<Loan>(), | ||
AvailableCopies = createBookDto.AvailableCopies, | ||
Authors = authors, | ||
PublicationYear = createBookDto.PublicationYear | ||
}; | ||
|
||
|
||
await _unitOfWork.BookRepository.AddAsync(Book); | ||
await _unitOfWork.CompleteAsync(); | ||
} | ||
throw new Exception("Category Not Found"); | ||
|
||
} | ||
|
||
public Task<IEnumerable<ReadBookDto>> AllBooks() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task DeleteBook(Guid bookId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<ReadBookDto> GetBookById(Guid bookId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<bool> IsBookAvailable(Guid bookId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<bool> IsBookExists(string name) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task UpdateBook(UpdateBookDto updateBookDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
34 changes: 32 additions & 2 deletions
34
src/Application.BLL/Services/Implementation/CategoryService.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 |
---|---|---|
@@ -1,12 +1,42 @@ | ||
using System; | ||
using Application.Shared; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.BLL | ||
{ | ||
public class CategoryService | ||
public class CategoryService : ICategoryService | ||
{ | ||
public Task AddCategory(CreateCategoryDto createCategoryDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<IEnumerable<ReadCategoryDto>> AllCategories() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task DeleteCategory(Guid CategoryId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<ReadCategoryDto> GetCategoryById(Guid CategoryId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<bool> IsCategoryExists(string name) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task UpdateCategory(UpdateCategoryDto updateCategoryDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
62 changes: 60 additions & 2 deletions
62
src/Application.BLL/Services/Implementation/LoanService.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 |
---|---|---|
@@ -1,12 +1,70 @@ | ||
using System; | ||
using Application.DAL; | ||
using Application.DAL.UnitOfWork; | ||
using Application.Shared; | ||
using AutoMapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.BLL | ||
{ | ||
public class LoanService | ||
public class LoanService : ILoanService | ||
{ | ||
|
||
private readonly IUnitOfWork _unitOfWork; | ||
private readonly IMapper _mapper; | ||
public LoanService(IUnitOfWork unitOfWork, IMapper mapper) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task AddLoan(CreateLoanDto createLoanDto) | ||
{ | ||
/// check book exists -> book reposiotry | ||
/// user -> userrepos | ||
/// loan -> loan | ||
var bookid = Guid.NewGuid(); | ||
var book = await _unitOfWork.BookRepository.GetByIdAsync(bookid); | ||
if(book != null) | ||
{ | ||
var user = await _unitOfWork.UserRepository.GetByIdAsync(); | ||
if (user != null) | ||
{ | ||
await _unitOfWork.LoanRepository.AddAsync(_mapper.Map<Loan>(createLoanDto)); | ||
|
||
book.AvailableCopies -= 1; | ||
await _unitOfWork.BookRepository.UpdateAsync(book); | ||
await _unitOfWork.CompleteAsync(); | ||
|
||
} | ||
} | ||
|
||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<IEnumerable<ReadLoanDto>> AllLoans() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
|
||
|
||
public Task<ReadLoanDto> GetBookById(Guid LoanId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task ReturnLoan(Guid LoanId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task UpdateLoan(UpdateLoanDto updateLoanDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
29 changes: 27 additions & 2 deletions
29
src/Application.BLL/Services/Implementation/PenaltyService.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 |
---|---|---|
@@ -1,12 +1,37 @@ | ||
using System; | ||
using Application.Shared; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.BLL | ||
{ | ||
public class PenaltyService | ||
public class PenaltyService : IPenaltyService | ||
{ | ||
public Task<IEnumerable<ReadPenaltyDto>> AllPenalties() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task DeletePenalty(Guid PenaltyId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<ReadPenaltyDto> GetLByPenaltiesByMember(Guid MemberId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<bool> IsPenaltyPaid(Guid PenaltyId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task UpdatePenalty(UpdatePenaltyDto updatePenaltyto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
29 changes: 27 additions & 2 deletions
29
src/Application.BLL/Services/Implementation/UserService.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 |
---|---|---|
@@ -1,12 +1,37 @@ | ||
using System; | ||
using Application.Shared; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.BLL | ||
{ | ||
public class UserService | ||
public class UserService : IUserService | ||
{ | ||
public Task BlockUserAsync(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<IEnumerable<ReadUserDto>> GetAllUsersAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<ReadUserDto> GetUserByIdAsync(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<IEnumerable<ReadUserDto>> GetUsersByRoleAsync(string role) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task SoftDeleteUserAsync(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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
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
13 changes: 13 additions & 0 deletions
13
src/Application.BLL/Services/Interfaces/INotificationService.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,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.BLL.Services | ||
{ | ||
public interface INotificationService | ||
{ | ||
|
||
} | ||
} |
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
Oops, something went wrong.