From c457d885f0773a516696581561565d5e0b3fb2d9 Mon Sep 17 00:00:00 2001 From: Tohirjon-Odilov Date: Sun, 3 Mar 2024 10:50:44 +0500 Subject: [PATCH] add repository --- .../BaseRepositories/BaseRepository.cs | 5 +++-- .../BaseRepositories/CategoryRepository.cs | 13 +++++++++++++ .../BaseRepositories/ProductRepository.cs | 13 +++++++++++++ .../BaseRepositories/StatsRepository.cs | 13 +++++++++++++ .../BaseRepositories/UserRepository.cs | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 Exam.StockManagement.Infrastructure/BaseRepositories/CategoryRepository.cs create mode 100644 Exam.StockManagement.Infrastructure/BaseRepositories/ProductRepository.cs create mode 100644 Exam.StockManagement.Infrastructure/BaseRepositories/StatsRepository.cs diff --git a/Exam.StockManagement.Infrastructure/BaseRepositories/BaseRepository.cs b/Exam.StockManagement.Infrastructure/BaseRepositories/BaseRepository.cs index cee112a..c200ed8 100644 --- a/Exam.StockManagement.Infrastructure/BaseRepositories/BaseRepository.cs +++ b/Exam.StockManagement.Infrastructure/BaseRepositories/BaseRepository.cs @@ -1,4 +1,5 @@ -using Exam.StockManagement.Application.Abstractions; +using Exam.StockManagement.Application.Abstractions.IRepository; +using Exam.StockManagement.Domain.Exceptions; using Exam.StockManagement.Infrastructure.Persistance; using Microsoft.EntityFrameworkCore; using System; @@ -53,7 +54,7 @@ public async Task GetByAny(Expression> expression) return result; } catch (Exception ex) { - throw; + throw new NotFoundException(); } } diff --git a/Exam.StockManagement.Infrastructure/BaseRepositories/CategoryRepository.cs b/Exam.StockManagement.Infrastructure/BaseRepositories/CategoryRepository.cs new file mode 100644 index 0000000..e57bae1 --- /dev/null +++ b/Exam.StockManagement.Infrastructure/BaseRepositories/CategoryRepository.cs @@ -0,0 +1,13 @@ +using Exam.StockManagement.Application.Abstractions.IRepository; +using Exam.StockManagement.Domain.Entities.Models; +using Exam.StockManagement.Infrastructure.Persistance; + +namespace Exam.StockManagement.Infrastructure.BaseRepositories +{ + public class CategoryRepository : BaseRepository, ICategoryRepository + { + public CategoryRepository(StockManagementDbContext context) : base(context) + { + } + } +} diff --git a/Exam.StockManagement.Infrastructure/BaseRepositories/ProductRepository.cs b/Exam.StockManagement.Infrastructure/BaseRepositories/ProductRepository.cs new file mode 100644 index 0000000..ce11cd5 --- /dev/null +++ b/Exam.StockManagement.Infrastructure/BaseRepositories/ProductRepository.cs @@ -0,0 +1,13 @@ +using Exam.StockManagement.Application.Abstractions.IRepository; +using Exam.StockManagement.Domain.Entities.Models; +using Exam.StockManagement.Infrastructure.Persistance; + +namespace Exam.StockManagement.Infrastructure.BaseRepositories +{ + public class ProductRepository : BaseRepository, IProductRepository + { + public ProductRepository(StockManagementDbContext context) : base(context) + { + } + } +} diff --git a/Exam.StockManagement.Infrastructure/BaseRepositories/StatsRepository.cs b/Exam.StockManagement.Infrastructure/BaseRepositories/StatsRepository.cs new file mode 100644 index 0000000..daedd96 --- /dev/null +++ b/Exam.StockManagement.Infrastructure/BaseRepositories/StatsRepository.cs @@ -0,0 +1,13 @@ +using Exam.StockManagement.Application.Abstractions.IRepository; +using Exam.StockManagement.Domain.Entities.Models; +using Exam.StockManagement.Infrastructure.Persistance; + +namespace Exam.StockManagement.Infrastructure.BaseRepositories +{ + public class StatsRepository : BaseRepository, IStatsService + { + public StatsRepository(StockManagementDbContext context) : base(context) + { + } + } +} diff --git a/Exam.StockManagement.Infrastructure/BaseRepositories/UserRepository.cs b/Exam.StockManagement.Infrastructure/BaseRepositories/UserRepository.cs index a0fd452..c0e36ad 100644 --- a/Exam.StockManagement.Infrastructure/BaseRepositories/UserRepository.cs +++ b/Exam.StockManagement.Infrastructure/BaseRepositories/UserRepository.cs @@ -1,4 +1,4 @@ -using Exam.StockManagement.Application.Abstractions; +using Exam.StockManagement.Application.Abstractions.IRepository; using Exam.StockManagement.Domain.Entities.Models; using Exam.StockManagement.Infrastructure.Persistance;