-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5bb1b7
commit f51bf53
Showing
19 changed files
with
554 additions
and
73 deletions.
There are no files selected for viewing
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
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
9 changes: 5 additions & 4 deletions
9
Exam.StockManagement.Application/Abstractions/IServices/IProductService.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,13 @@ | ||
using Exam.StockManagement.Domain.Entities.DTOs; | ||
using Exam.StockManagement.Domain.Entities.Models; | ||
|
||
namespace Exam.StockManagement.Application.Abstractions.IServices | ||
{ | ||
public interface IProductService | ||
{ | ||
public Task<string> Create(); | ||
public Task<List<Category>> GetAll(); | ||
public Task<string> Update(); | ||
public Task<string> Delete(); | ||
public Task<Product> Create(ProductDTO product); | ||
public Task<List<Product>> GetAll(); | ||
public Task<string> Update(Product product); | ||
public Task<string> Delete(int Id); | ||
} | ||
} |
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
61 changes: 49 additions & 12 deletions
61
Exam.StockManagement.Application/Services/ProductService.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,34 +1,71 @@ | ||
using Exam.StockManagement.Application.Abstractions.IRepository; | ||
using Exam.StockManagement.Application.Abstractions.IServices; | ||
using Exam.StockManagement.Domain.Entities.DTOs; | ||
using Exam.StockManagement.Domain.Entities.Models; | ||
using System.Linq.Expressions; | ||
|
||
namespace Exam.StockManagement.Application.Services | ||
{ | ||
public class ProductService : IProductRepository | ||
public class ProductService : IProductService | ||
{ | ||
public Task<Product> Create(Product entity) | ||
private readonly IProductRepository productRepository; | ||
|
||
public ProductService(IProductRepository productRepository) | ||
{ | ||
throw new NotImplementedException(); | ||
this.productRepository = productRepository; | ||
} | ||
|
||
public Task<bool> Delete(Expression<Func<Product, bool>> expression) | ||
public Task<Product> Create(ProductDTO product) | ||
{ | ||
throw new NotImplementedException(); | ||
ArgumentNullException.ThrowIfNull(product); | ||
|
||
var entity = new Product() | ||
{ | ||
CategoryId = product.CategoryId, | ||
ProductDescription = product.ProductDescription, | ||
ProductName = product.ProductName, | ||
ProductPrice = product.ProductPrice, | ||
ProductPicture = product.ProductPicture | ||
}; | ||
|
||
var result = productRepository.Create(entity); | ||
|
||
return result; | ||
} | ||
|
||
public Task<IEnumerable<Product>> GetAll() | ||
public async Task<List<Product>> GetAll() | ||
{ | ||
throw new NotImplementedException(); | ||
ArgumentNullException.ThrowIfNull(productRepository); | ||
var result = await productRepository.GetAll(); | ||
return result.ToList(); | ||
} | ||
|
||
public Task<Product> GetByAny(Expression<Func<Product, bool>> expression) | ||
public async Task<string> Update(Product product) | ||
{ | ||
throw new NotImplementedException(); | ||
ArgumentNullException.ThrowIfNull(productRepository); | ||
|
||
var entity = new Product() | ||
{ | ||
CategoryId = product.CategoryId, | ||
ProductDescription = product.ProductDescription, | ||
ProductName = product.ProductName, | ||
ProductPrice = product.ProductPrice, | ||
ProductPicture = product.ProductPicture | ||
}; | ||
|
||
await productRepository.Update(entity); | ||
|
||
return "Ma'lumot yangilandi"; | ||
} | ||
|
||
public Task<Product> Update(Product entity) | ||
public async Task<string> Delete(int Id) | ||
{ | ||
throw new NotImplementedException(); | ||
ArgumentNullException.ThrowIfNull(Id); | ||
|
||
var result = await productRepository.Delete(x => x.Id == Id); | ||
|
||
ArgumentNullException.ThrowIfNull(result); | ||
|
||
return "Qo'shildi"; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Exam.StockManagement.Domain.Entities.DTOs | ||
{ | ||
public class ProductDTO | ||
{ | ||
public string ProductName { get; set; } | ||
public int CategoryId { get; set; } | ||
public int ProductPrice { get; set; } | ||
public string ProductDescription { get; set; } | ||
public string ProductPicture { get; set; } | ||
} | ||
} |
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
Oops, something went wrong.