Skip to content

Commit

Permalink
Fixing some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mervanerdem committed Jun 25, 2023
1 parent b54aa84 commit fa8c76b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ECOmmerceAPI.Business/Services/Category/CategoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public override ApiResponse<List<CategoryResponse>> GetAll()
{
var categories = unitOfWork.Repository<Category>()
.GetAsQueryable()
.Include(x => x.Products)
.ThenInclude(pc => pc.Product)
/*.Include(x => x.Products)
.ThenInclude(pc => pc.Product) */
.ToList();
var categoryResponses = mapper.Map<List<CategoryResponse>>(categories);
return new ApiResponse<List<CategoryResponse>>(categoryResponses);
Expand All @@ -33,8 +33,8 @@ public override ApiResponse<CategoryResponse> GetById(int id)
{
var category = unitOfWork.Repository<Category>()
.Where(x => x.Id.Equals(id))
.Include(x => x.Products)
.ThenInclude(pc => pc.Product)
/*.Include(x => x.Products)
.ThenInclude(pc => pc.Product)*/
.FirstOrDefault();
if (category is null)
{
Expand Down
7 changes: 3 additions & 4 deletions ECOmmerceAPI.Business/Services/Product/ProductService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using ECommerceAPI.Data.Domain;
using ECommerceAPI.Schema.DataSets.Product;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks.Dataflow;

namespace ECommerceAPI.Business.Services
{
Expand Down Expand Up @@ -109,7 +108,7 @@ public override ApiResponse Update(int id, ProductRequest request)
}
public ApiResponse<List<ProductResponse>> GetAllProduct(bool isActive)
{
var products = unitOfWork.Repository<Product>().Where(p => p.IsActive.Equals(isActive)).Include(p => p.Categories).ThenInclude(p => p.Category).IgnoreAutoIncludes().ToList();
var products = unitOfWork.Repository<Product>().Where(p => p.IsActive.Equals(isActive))/*.Include(p => p.Categories).ThenInclude(p => p.Category).IgnoreAutoIncludes()*/.ToList();

var productsResponse = mapper.Map<List<ProductResponse>>(products);

Expand All @@ -118,14 +117,14 @@ public ApiResponse<List<ProductResponse>> GetAllProduct(bool isActive)

public override ApiResponse<List<ProductResponse>> GetAll()
{
var products = unitOfWork.Repository<Product>().GetAll().Include(p => p.Categories).ThenInclude(p => p.Category).ToList();
var products = unitOfWork.Repository<Product>().GetAll()/*.Include(p => p.Categories).ThenInclude(p => p.Category)*/.ToList();
var productsResponse = mapper.Map<List<ProductResponse>>(products);
return new ApiResponse<List<ProductResponse>>(productsResponse);
}

public override ApiResponse<ProductResponse> GetById(int id)
{
var product = unitOfWork.Repository<Product>().Where(p => p.Id.Equals(id))?.Include(p => p.Categories).ThenInclude(p => p.Category)?.FirstOrDefault();
var product = unitOfWork.Repository<Product>().Where(p => p.Id.Equals(id))/*?.Include(p => p.Categories).ThenInclude(p => p.Category)*/.FirstOrDefault();
if (product is null)
{
return new ApiResponse<ProductResponse>("Not Found");
Expand Down

0 comments on commit fa8c76b

Please sign in to comment.