Compare commits
3 Commits
092d335f77
...
7d4301423d
Author | SHA1 | Date |
---|---|---|
|
7d4301423d | |
|
e54477f226 | |
|
f942bbb421 |
|
@ -66,7 +66,7 @@ public class OrderBagController : ICarterModule
|
|||
=> TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken));
|
||||
|
||||
public async Task<IResult> AddShippingToOrderBagAsync(Guid orderId, [FromBody] SubmitOrderDeliveryCommand request, IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new SubmitOrderDeliveryCommand(request.AddressId, orderId, request.ShippingId), cancellationToken));
|
||||
=> TypedResults.Ok(await mediator.Send(request with { OrderId = orderId }, cancellationToken));
|
||||
|
||||
public async Task<IResult> SubmitOrderPaymentAsync(Guid orderId, [FromQuery] OrderPaymentMethod paymentMethod, IMediator mediator, CancellationToken cancellationToken)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Netina.Api.Controllers;
|
||||
using Netina.Core.CoreServices.CommandQueries.Queries;
|
||||
|
||||
namespace Netina.Api.Controllers;
|
||||
|
||||
public class SearchController : ICarterModule
|
||||
{
|
||||
|
@ -6,9 +8,6 @@ public class SearchController : ICarterModule
|
|||
{
|
||||
var group = app.NewVersionedApi("Search").MapGroup("api/search");
|
||||
|
||||
group.MapGet("", SearchAsync)
|
||||
.WithDisplayName("Search Async")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("/thumb", SearchThumbAsync)
|
||||
.WithDisplayName("Thumb Search Async")
|
||||
|
@ -21,27 +20,22 @@ public class SearchController : ICarterModule
|
|||
group.MapGet("torob", TorobAsync)
|
||||
.WithDisplayName("Get Torob Product Async")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("emalls", EmallsAsync)
|
||||
.WithDisplayName("Get Emalls Product Async")
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
private async Task<IResult> SearchThumbAsync([FromQuery] string name, [FromServices] ISearchService searchService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await searchService.ThumbSearchAsync(name, cancellationToken));
|
||||
private async Task<IResult> SearchThumbAsync([FromQuery] string name, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new GetThumbSearchProductsQuery(name),cancellationToken));
|
||||
|
||||
private async Task<IResult> SearchAsync([FromQuery] string name, [FromServices] ISearchService searchService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await searchService.SearchAsync(name, cancellationToken));
|
||||
|
||||
private async Task<IResult> ZarehbinAsync([FromQuery] string? product_id, [FromQuery] int? page, [FromServices] ISearchService searchService, CancellationToken cancellationToken)
|
||||
{
|
||||
if (product_id == null)
|
||||
{
|
||||
if (page == null)
|
||||
return TypedResults.Ok(await searchService.ZarehbinAsync(0, cancellationToken));
|
||||
else
|
||||
return TypedResults.Ok(await searchService.ZarehbinAsync(page.Value, cancellationToken));
|
||||
}
|
||||
else
|
||||
return TypedResults.Ok(await searchService.ZarehbinAsync(Guid.Parse(product_id), cancellationToken));
|
||||
}
|
||||
private async Task<IResult> ZarehbinAsync([FromQuery] string? product_id, [FromQuery] int? page, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new GetZarehbinProductsQuery(Page: page ?? 0, ProductId: product_id), cancellationToken));
|
||||
|
||||
private async Task<IResult> TorobAsync([FromQuery] int page, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new GetTorobProductsQuery(page),cancellationToken));
|
||||
|
||||
private async Task<IResult> EmallsAsync([FromQuery] int page, [FromQuery]int? item_per_page, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new GetEmallsProductsQuery(page,item_per_page??20), cancellationToken));
|
||||
}
|
|
@ -75,7 +75,6 @@
|
|||
<Using Include="Netina.Core" />
|
||||
<Using Include="Netina.Core.Abstracts" />
|
||||
<Using Include="Netina.Core.BaseServices.Abstracts" />
|
||||
<Using Include="Netina.Core.CoreServices.Abstracts" />
|
||||
<Using Include="Netina.Core.CoreServices.CommandQueries.Commands" />
|
||||
<Using Include="Netina.Core.Models.Api" />
|
||||
<Using Include="Netina.Core.Utilities" />
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
using Netina.Domain.Dtos.ScraperDtos.Response;
|
||||
using Netina.Domain.Dtos.ScraperDtos.Response;
|
||||
|
||||
namespace Netina.Core.Abstracts;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
using Netina.Domain.Models.Districts;
|
||||
using Netina.Domain.Models.Districts;
|
||||
|
||||
namespace Netina.Core.Abstracts;
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
using Netina.Domain.Dtos.ResponseDtos;
|
||||
|
||||
namespace Netina.Core.Abstracts;
|
||||
namespace Netina.Core.Abstracts;
|
||||
|
||||
public interface IExternalFilesService : IScopedDependency
|
||||
{
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
|
||||
namespace Netina.Core.Abstracts;
|
||||
namespace Netina.Core.Abstracts;
|
||||
|
||||
public interface IPaymentService : IScopedDependency
|
||||
{
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using Netina.Common.Models;
|
||||
|
||||
namespace Netina.Core.Abstracts;
|
||||
namespace Netina.Core.Abstracts;
|
||||
|
||||
public interface ISmsService : IScopedDependency
|
||||
{
|
||||
Task SendVerifyCodeAsync(string phoneNumber, string verifyCode);
|
||||
Task SendForgerPasswordAsync(string phoneNumber, string newPassword);
|
||||
Task SendLookUpAsync(string phoneNumber, string template, string token, string? token2 = null, string? token3 = null, string? token10 = null, string? token20 = null);
|
||||
}
|
|
@ -1,7 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
using Netina.Common.Models.Api;
|
||||
|
||||
namespace Netina.Core.Abstracts;
|
||||
namespace Netina.Core.Abstracts;
|
||||
|
||||
public interface IUploadFileService : IScopedDependency
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Netina.Core.CoreServices.Abstracts;
|
||||
namespace Netina.Core.BaseServices.Abstracts;
|
||||
|
||||
public interface IAccountService : IScopedDependency
|
||||
{
|
|
@ -1,8 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
using Netina.Common.Models.Api;
|
||||
using Netina.Domain.Entities.Users;
|
||||
|
||||
namespace Netina.Core.BaseServices.Abstracts;
|
||||
namespace Netina.Core.BaseServices.Abstracts;
|
||||
|
||||
public interface IJwtService : IScopedDependency
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
namespace Netina.Core.CoreServices.Abstracts;
|
||||
namespace Netina.Core.BaseServices.Abstracts;
|
||||
|
||||
public interface IPageService : IScopedDependency
|
||||
{
|
||||
Task<BasePageSDto> GetPageAsync(Guid? id = null, string? pageName = null, string? pageSlug = null,string? type = null, CancellationToken cancellationToken=default);
|
||||
Task<BasePageSDto> GetPageAsync(Guid? id = null, string? pageName = null, string? pageSlug = null, string? type = null, CancellationToken cancellationToken = default);
|
||||
Task<List<BasePageSDto>> GetPagesAsync(CancellationToken cancellationToken = default);
|
||||
Task<bool> CreatePageAsync(PageActionRequestDto entity, CancellationToken cancellationToken = default);
|
||||
Task<bool> DeletePageAsync(Guid id,CancellationToken cancellationToken = default);
|
||||
Task<bool> DeletePageAsync(Guid id, CancellationToken cancellationToken = default);
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
|
||||
namespace Netina.Core.CoreServices.Abstracts;
|
||||
namespace Netina.Core.BaseServices.Abstracts;
|
||||
|
||||
public interface ISettingService : IScopedDependency
|
||||
{
|
|
@ -1,6 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
|
||||
namespace Netina.Core.BaseServices.Abstracts;
|
||||
namespace Netina.Core.BaseServices.Abstracts;
|
||||
|
||||
public interface ISiteMapService : IScopedDependency
|
||||
{
|
||||
|
|
|
@ -1,19 +1,4 @@
|
|||
using Netina.Common.Extensions;
|
||||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Core.Abstracts;
|
||||
using Netina.Core.BaseServices.Abstracts;
|
||||
using Netina.Core.CoreServices.Abstracts;
|
||||
using Netina.Core.EntityServices.Abstracts;
|
||||
using Netina.Domain.Dtos.RequestDtos;
|
||||
using Netina.Domain.Dtos.ResponseDtos;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Users;
|
||||
using Netina.Domain.Enums;
|
||||
using Netina.Repository.Abstracts;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.CoreServices;
|
||||
namespace Netina.Core.BaseServices;
|
||||
|
||||
|
||||
public class AccountService : IAccountService
|
|
@ -1,10 +1,4 @@
|
|||
using Netina.Common.Extensions;
|
||||
using Netina.Common.Models.Api;
|
||||
using Netina.Core.BaseServices.Abstracts;
|
||||
using Netina.Domain.Entities.Users;
|
||||
using Netina.Domain.Models.Settings;
|
||||
|
||||
namespace Netina.Core.BaseServices;
|
||||
namespace Netina.Core.BaseServices;
|
||||
|
||||
|
||||
public class JwtService : IJwtService
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Netina.Domain.MartenEntities.Pages;
|
||||
|
||||
namespace Netina.Core.CoreServices;
|
||||
namespace Netina.Core.BaseServices;
|
||||
|
||||
public class PageService : IPageService
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ public class PageService : IPageService
|
|||
var page = await _martenRepositoryWrapper.SetRepository<BasePage>().GetEntityAsync(p => p.Id == id, cancellationToken);
|
||||
if (page == null)
|
||||
throw new AppException("Page not found", ApiResultStatusCode.NotFound);
|
||||
await _martenRepositoryWrapper.SetRepository<BasePage>().RemoveEntityAsync(page,cancellationToken);
|
||||
await _martenRepositoryWrapper.SetRepository<BasePage>().RemoveEntityAsync(page, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
namespace Netina.Core.CoreServices;
|
||||
|
||||
|
||||
|
||||
public class SettingService : ISettingService
|
||||
{
|
||||
|
@ -23,7 +22,6 @@ public class SettingService : ISettingService
|
|||
setting = Activator.CreateInstance(type);
|
||||
else
|
||||
setting = JsonConvert.DeserializeObject(baseSetting.JsonData, type) ?? Activator.CreateInstance(type);
|
||||
|
||||
if (setting == null)
|
||||
throw new AppException("Setting type or base is wrong");
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
using System.IO.Compression;
|
||||
using System.Xml;
|
||||
using Netina.Core.Models;
|
||||
using Netina.Domain.Entities.Blogs;
|
||||
using Netina.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace Netina.Core.BaseServices;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
using Netina.Domain.Dtos.ResponseDtos.Zarehbin;
|
||||
|
||||
namespace Netina.Core.CoreServices.Abstracts;
|
||||
|
||||
public interface ISearchService : IScopedDependency
|
||||
{
|
||||
public Task<SearchResponseDto> SearchAsync(string name,CancellationToken cancellationToken = default);
|
||||
public Task<SearchResponseDto> ThumbSearchAsync(string name,CancellationToken cancellationToken = default);
|
||||
public Task<ZarehbinPagedResponseDto> ZarehbinAsync(int page,CancellationToken cancellationToken = default);
|
||||
public Task<ZarehbinProductResponseDto> ZarehbinAsync(Guid productId,CancellationToken cancellationToken = default);
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace Netina.Core.CoreServices.CommandQueries.Queries;
|
||||
|
||||
public sealed record GetTorobProductsQuery(int Page = 0) : IRequest<List<TorobProductResponseDto>>;
|
||||
|
||||
public sealed record GetEmallsProductsQuery(int Page = 0 , int Count = 20) : IRequest<EmallsResponseDto>;
|
||||
|
||||
public sealed record GetThumbSearchProductsQuery(string Name) : IRequest<SearchResponseDto>;
|
||||
|
||||
public sealed record GetZarehbinProductsQuery(int Page=0, string? ProductId=null);
|
|
@ -1,71 +0,0 @@
|
|||
using Netina.Domain.Dtos.ResponseDtos.Zarehbin;
|
||||
using Netina.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace Netina.Core.CoreServices;
|
||||
|
||||
public class SearchService : ISearchService
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public SearchService(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<SearchResponseDto> SearchAsync(string name, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var searchQuery = name;
|
||||
var products = await _repositoryWrapper.SetRepository<Product>()
|
||||
.TableNoTracking
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.PersianName, searchQuery))
|
||||
.Select(ProductMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var categories = await _repositoryWrapper.SetRepository<ProductCategory>()
|
||||
.TableNoTracking
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.Name, searchQuery))
|
||||
.Select(ProductCategoryMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new SearchResponseDto
|
||||
{
|
||||
Products = products.Select(p => p.Adapt<SearchedProductResponseDto>()).ToList(),
|
||||
Categories = categories.Select(c => c.Adapt<SearchedProductCategoryResponseDto>()).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<SearchResponseDto> ThumbSearchAsync(string name, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var searchQuery = name;
|
||||
|
||||
var products = await _repositoryWrapper.SetRepository<Product>()
|
||||
.TableNoTracking
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.PersianName, searchQuery))
|
||||
.Take(8)
|
||||
.Select(ProductMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var categories = await _repositoryWrapper.SetRepository<ProductCategory>()
|
||||
.TableNoTracking
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.Name.ToLower().Trim(), searchQuery))
|
||||
.Take(8)
|
||||
.Select(ProductCategoryMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new SearchResponseDto
|
||||
{
|
||||
Products = products.Select(p => p.Adapt<SearchedProductResponseDto>()).ToList(),
|
||||
Categories = categories.Select(c => c.Adapt<SearchedProductCategoryResponseDto>()).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public Task<ZarehbinPagedResponseDto> ZarehbinAsync(int page, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ZarehbinProductResponseDto> ZarehbinAsync(Guid productId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
namespace Netina.Core.CoreServices.SearchServices;
|
||||
|
||||
public class GetEmallsProductsQueryHandler : IRequestHandler<GetEmallsProductsQuery, EmallsResponseDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly IMediator _mediator;
|
||||
private readonly SiteSettings _siteSetting;
|
||||
public GetEmallsProductsQueryHandler(IRepositoryWrapper repositoryWrapper, IMediator mediator, IOptionsSnapshot<SiteSettings> optionsSnapshot)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_mediator = mediator;
|
||||
_siteSetting = optionsSnapshot.Value;
|
||||
}
|
||||
|
||||
public async Task<EmallsResponseDto> Handle(GetEmallsProductsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var page = request.Page;
|
||||
var productsSDto = await _repositoryWrapper.SetRepository<Product>()
|
||||
.TableNoTracking
|
||||
.OrderByDescending(p => p.ModifiedAt == DateTime.MinValue ? p.CreatedAt : p.ModifiedAt)
|
||||
.Select(p => new ProductSDto
|
||||
{
|
||||
Id = p.Id,
|
||||
BeDisplayed = p.BeDisplayed,
|
||||
IsEnable = p.IsEnable,
|
||||
Cost = p.Cost,
|
||||
CategoryId = p.CategoryId,
|
||||
BrandId = p.BrandId,
|
||||
EnglishName = p.EnglishName,
|
||||
PersianName = p.PersianName,
|
||||
Slug = p.Slug,
|
||||
|
||||
})
|
||||
.Skip(page * request.Count)
|
||||
.Take(request.Count)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
||||
foreach (var productSDto in productsSDto)
|
||||
await _mediator.Send(new CalculateProductDiscountCommand(productSDto), cancellationToken);
|
||||
var products = new List<EmallsProductResponseDto>();
|
||||
foreach (var product in productsSDto)
|
||||
{
|
||||
var torobProduct = new EmallsProductResponseDto
|
||||
{
|
||||
is_available = product.IsEnable,
|
||||
url = $"{_siteSetting.WebSiteUrl}/products/{product.Id}/{product.Slug}",
|
||||
id = product.Id.ToString(),
|
||||
title = product.PersianName,
|
||||
category = product.CategoryName
|
||||
};
|
||||
if (product.Cost > product.CostWithDiscount)
|
||||
{
|
||||
torobProduct.old_price = (int)product.Cost;
|
||||
torobProduct.price = (int)product.CostWithDiscount;
|
||||
}
|
||||
else
|
||||
torobProduct.price = (int)product.Cost;
|
||||
products.Add(torobProduct);
|
||||
}
|
||||
|
||||
var response = new EmallsResponseDto();
|
||||
response.item_per_page = request.Count;
|
||||
response.page_num = request.Page;
|
||||
response.total_items = (await _repositoryWrapper.SetRepository<Product>().TableNoTracking.CountAsync(cancellationToken));
|
||||
response.pages_count = response.total_items / request.Count;
|
||||
response.products = products;
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using Netina.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace Netina.Core.CoreServices.SearchServices;
|
||||
|
||||
public class GetThumbSearchProductsQueryHandler : IRequestHandler<GetThumbSearchProductsQuery, SearchResponseDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public GetThumbSearchProductsQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<SearchResponseDto> Handle(GetThumbSearchProductsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
var searchQuery = request.Name;
|
||||
|
||||
var products = await _repositoryWrapper.SetRepository<Product>()
|
||||
.TableNoTracking
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.PersianName, searchQuery))
|
||||
.Take(8)
|
||||
.Select(ProductMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var categories = await _repositoryWrapper.SetRepository<ProductCategory>()
|
||||
.TableNoTracking
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.Name.ToLower().Trim(), searchQuery))
|
||||
.Take(8)
|
||||
.Select(ProductCategoryMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new SearchResponseDto
|
||||
{
|
||||
Products = products.Select(p => p.Adapt<SearchedProductResponseDto>()).ToList(),
|
||||
Categories = categories.Select(c => c.Adapt<SearchedProductCategoryResponseDto>()).ToList()
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
using Netina.Domain.Dtos.ResponseDtos.Torob;
|
||||
|
||||
namespace Netina.Core.CoreServices.SearchServices;
|
||||
namespace Netina.Core.CoreServices.SearchServices;
|
||||
|
||||
public class GetTorobProductsQueryHandler : IRequestHandler<GetTorobProductsQuery, List<TorobProductResponseDto>>
|
||||
{
|
||||
|
@ -46,7 +44,7 @@ public class GetTorobProductsQueryHandler : IRequestHandler<GetTorobProductsQuer
|
|||
var torobProduct = new TorobProductResponseDto
|
||||
{
|
||||
availibility = product.IsEnable,
|
||||
page_url = $"{_siteSetting.WebSiteUrl}/products/{product.Id}",
|
||||
page_url = $"{_siteSetting.WebSiteUrl}/products/{product.Id}/{product.Slug}",
|
||||
product_id = product.Id.ToString()
|
||||
};
|
||||
if (product.Cost > product.CostWithDiscount)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Netina.Domain.Entities.Blogs;
|
||||
using Netina.Domain.Entities.ProductCategories;
|
||||
using Netina.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace Netina.Core.CoreServices.WebSiteServices;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
using Netina.Common.Models;
|
||||
using Netina.Domain.Dtos.RequestDtos;
|
||||
using Netina.Domain.Dtos.ResponseDtos;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Users;
|
||||
using Netina.Domain.Models.Claims;
|
||||
|
||||
namespace Netina.Core.EntityServices.Abstracts;
|
||||
namespace Netina.Core.EntityServices.Abstracts;
|
||||
|
||||
public interface IUserService : IScopedDependency
|
||||
{
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Entities.Discounts;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Enums;
|
||||
using Netina.Repository.Abstracts;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.DiscountHandlers;
|
||||
namespace Netina.Core.EntityServices.DiscountHandlers;
|
||||
|
||||
public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrderDiscountCommand , double>
|
||||
{
|
||||
|
|
|
@ -1,14 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.CommandQueries.Queries;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Entities.Products;
|
||||
using Netina.Repository.Abstracts;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class AddToOrderBagCommandHandler : IRequestHandler<AddToOrderBagCommand, OrderSDto>
|
||||
{
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Dtos.ResponseDtos;
|
||||
using Netina.Domain.Entities.Products;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class CheckOrderBagCommandHandler : IRequestHandler<CheckOrderBagCommand , List<CheckOrderBagResponseItem>>
|
||||
{
|
||||
|
|
|
@ -1,14 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.CommandQueries.Queries;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Entities.Users;
|
||||
using Netina.Domain.Enums;
|
||||
using Netina.Repository.Abstracts;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class GetUserOrderBagQueryHandler : IRequestHandler<GetUserOrderBagQuery,Order>
|
||||
{
|
||||
|
|
|
@ -1,14 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.CommandQueries.Queries;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Entities.Products;
|
||||
using Netina.Repository.Abstracts;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class RemoveFromOrderBagCommandHandler : IRequestHandler<RemoveFromOrderBagCommand, OrderSDto>
|
||||
{
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Discounts;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountCommand,OrderSDto>
|
||||
{
|
||||
|
|
|
@ -1,14 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.CommandQueries.Queries;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Entities.Products;
|
||||
using Netina.Repository.Abstracts;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class SubmitOrderBagCommandHandler : IRequestHandler<SubmitOrderBagCommand,OrderSDto>
|
||||
{
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Entities.Warehouses;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
using Netina.Domain.Entities.Warehouses;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
|
|
|
@ -1,31 +1,14 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Core.Abstracts;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Dtos.ResponseDtos;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Enums;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class SubmitOrderPaymentCommandHandler : IRequestHandler<SubmitOrderPaymentCommand , SubmitOrderPaymentResponseDto>
|
||||
public class SubmitOrderPaymentCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper, IPaymentService paymentService, ISmsService smsService, IOptionsSnapshot<SiteSettings> optionsSnapshot)
|
||||
: IRequestHandler<SubmitOrderPaymentCommand , SubmitOrderPaymentResponseDto>
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly IPaymentService _paymentService;
|
||||
|
||||
public SubmitOrderPaymentCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper, IPaymentService paymentService)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_paymentService = paymentService;
|
||||
}
|
||||
public async Task<SubmitOrderPaymentResponseDto> Handle(SubmitOrderPaymentCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _mediator.Send(new CalculateOrderCommand(request.OrderId, true), cancellationToken);
|
||||
var _siteSetting = optionsSnapshot.Value;
|
||||
await mediator.Send(new CalculateOrderCommand(request.OrderId, true), cancellationToken);
|
||||
|
||||
var order = await _repositoryWrapper.SetRepository<Order>()
|
||||
var order = await repositoryWrapper.SetRepository<Order>()
|
||||
.TableNoTracking
|
||||
.Where(o => o.Id == request.OrderId)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
@ -41,45 +24,53 @@ public class SubmitOrderPaymentCommandHandler : IRequestHandler<SubmitOrderPayme
|
|||
{
|
||||
response.NeedToPayOnline = false;
|
||||
order.SetOrderPayment(request.PaymentMethod);
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
if (!_siteSetting.Manager.Phone.IsNullOrEmpty())
|
||||
await smsService.SendLookUpAsync(_siteSetting.Manager.Phone, "manager-submitOrder",order.FactorCode,null,null, $"{_siteSetting.Manager.FirstName} {_siteSetting.Manager.LastName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
response.NeedToPayOnline = true;
|
||||
var orderSDto = await _repositoryWrapper.SetRepository<Order>()
|
||||
var orderSDto = await repositoryWrapper.SetRepository<Order>()
|
||||
.TableNoTracking
|
||||
.Where(o => o.Id == request.OrderId)
|
||||
.Select(OrderMapper.ProjectToSDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
if (orderSDto == null)
|
||||
throw new AppException("Order not found", ApiResultStatusCode.NotFound);
|
||||
response.PaymentUrl = await _paymentService.GetPaymentLinkAsync(orderSDto.TotalPrice, orderSDto.FactorCode, orderSDto.Id, orderSDto.CustomerId, orderSDto.CustomerPhoneNumber, orderSDto.CustomerFullName, cancellationToken);
|
||||
response.PaymentUrl = await paymentService.GetPaymentLinkAsync(orderSDto.TotalPrice, orderSDto.FactorCode, orderSDto.Id, orderSDto.CustomerId, orderSDto.CustomerPhoneNumber, orderSDto.CustomerFullName, cancellationToken);
|
||||
}
|
||||
}
|
||||
else if (request.PaymentMethod == OrderPaymentMethod.PayOnDoor)
|
||||
{
|
||||
response.NeedToPayOnline = false;
|
||||
order.SetOrderPayment(request.PaymentMethod);
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
await _mediator.Send(new CreateOrUpdatePaymentCommand(null,order.FactorCode, order.TotalPrice,
|
||||
await mediator.Send(new CreateOrUpdatePaymentCommand(null,order.FactorCode, order.TotalPrice,
|
||||
$"پرداخت نقدی سفارش {order.FactorCode}", string.Empty, string.Empty, string.Empty,
|
||||
PaymentType.PayOnDoor, PaymentStatus.Paid, order.Id
|
||||
, order.CustomerId), cancellationToken);
|
||||
|
||||
if (!_siteSetting.Manager.Phone.IsNullOrEmpty())
|
||||
await smsService.SendLookUpAsync(_siteSetting.Manager.Phone, "manager-submitOrder", order.FactorCode, null, null, $"{_siteSetting.Manager.FirstName} {_siteSetting.Manager.LastName}");
|
||||
}
|
||||
else if (request.PaymentMethod == OrderPaymentMethod.CardTransfer)
|
||||
{
|
||||
response.NeedToPayOnline = false;
|
||||
order.SetOrderPayment(request.PaymentMethod);
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
await _mediator.Send(new CreateOrUpdatePaymentCommand(null,order.FactorCode, order.TotalPrice,
|
||||
await mediator.Send(new CreateOrUpdatePaymentCommand(null,order.FactorCode, order.TotalPrice,
|
||||
$"پرداخت نقدی سفارش {order.FactorCode}", string.Empty, string.Empty, string.Empty,
|
||||
PaymentType.CardTransfer, PaymentStatus.Paid, order.Id
|
||||
, order.CustomerId), cancellationToken);
|
||||
|
||||
if (!_siteSetting.Manager.Phone.IsNullOrEmpty())
|
||||
await smsService.SendLookUpAsync(_siteSetting.Manager.Phone, "manager-submitOrder", order.FactorCode, null, null, $"{_siteSetting.Manager.FirstName} {_siteSetting.Manager.LastName}");
|
||||
}
|
||||
|
||||
return response;
|
||||
|
|
|
@ -1,27 +1,11 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.CommandQueries.Queries;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Enums;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
namespace Netina.Core.EntityServices.OrderHandlers;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderHandlers;
|
||||
|
||||
public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderCommand,Order>
|
||||
public class CalculateOrderCommandHandler(IRepositoryWrapper repositoryWrapper, IMediator mediator) : IRequestHandler<CalculateOrderCommand,Order>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public CalculateOrderCommandHandler(IRepositoryWrapper repositoryWrapper, IMediator mediator)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
public async Task<Order> Handle(CalculateOrderCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken);
|
||||
var order = await mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken);
|
||||
if (order.OrderStatus != OrderStatus.OrderBag)
|
||||
throw new AppException("Order is not in bag status and cant be calculate", ApiResultStatusCode.BadRequest);
|
||||
var totalProductPrice = order.OrderProducts.Sum(op => op.ProductFee * op.Count);
|
||||
|
@ -36,7 +20,7 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
double productDiscountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count);
|
||||
double discountCodePrice = 0;
|
||||
if (!order.DiscountCode.IsNullOrEmpty())
|
||||
discountCodePrice += await _mediator.Send(new CalculateOrderDiscountCommand(order.DiscountCode, order),cancellationToken);
|
||||
discountCodePrice += await mediator.Send(new CalculateOrderDiscountCommand(order.DiscountCode, order),cancellationToken);
|
||||
|
||||
//var taxesPrice = (((totalProductPrice - discountPrice) + totalPackingPrice + servicePrice) / 100) * _shopSettings.TaxesFee;
|
||||
|
||||
|
@ -45,8 +29,8 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, productDiscountPrice, discountCodePrice, taxesPrice);
|
||||
order.OrderProducts.Clear();
|
||||
order.OrderDelivery = null;
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return order;
|
||||
}
|
||||
}
|
|
@ -1,33 +1,33 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Entities.Orders;
|
||||
using Netina.Domain.Enums;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
using MD.PersianDateTime.Standard;
|
||||
|
||||
namespace Netina.Core.EntityServices.OrderHandlers;
|
||||
|
||||
public class ConfirmOrderStepCommandHandler : IRequestHandler<ConfirmOrderStepCommand, bool>
|
||||
public class ConfirmOrderStepCommandHandler(IRepositoryWrapper repositoryWrapper, ISmsService smsService) : IRequestHandler<ConfirmOrderStepCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public ConfirmOrderStepCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(ConfirmOrderStepCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var order = await _repositoryWrapper.SetRepository<Order>()
|
||||
var order = await repositoryWrapper.SetRepository<Order>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken);
|
||||
if (order == null)
|
||||
throw new AppException("Order not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
order.SetOrderStatus(request.NextOrderStatus);
|
||||
|
||||
if (request.NextOrderStatus == OrderStatus.Processing)
|
||||
{
|
||||
var customer = await repositoryWrapper.SetRepository<Customer>().TableNoTracking
|
||||
.Where(c => c.Id == order.CustomerId)
|
||||
.Select(CustomerMapper.ProjectToSDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
if (customer != null)
|
||||
{
|
||||
await smsService.SendLookUpAsync(customer.PhoneNumber, "customer-submitOrder",
|
||||
(order.TotalPrice/10).ToString("N0"),order.FactorCode,null, $"{customer.FirstName} {customer.LastName}");
|
||||
}
|
||||
}
|
||||
if (request.NextOrderStatus == OrderStatus.Delivered)
|
||||
{
|
||||
var delivery = await _repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
var delivery = await repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(od => od.OrderId == order.Id, cancellationToken);
|
||||
if (delivery != null)
|
||||
|
@ -35,15 +35,26 @@ public class ConfirmOrderStepCommandHandler : IRequestHandler<ConfirmOrderStepCo
|
|||
if (request.TrackingCode == null || request.TrackingCode.IsNullOrEmpty())
|
||||
throw new AppException("لطفا کد پیگیری ارسال را پر کنید");
|
||||
delivery.SetTrackingCode(request.TrackingCode);
|
||||
_repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.Update(delivery);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
}
|
||||
var customer = await repositoryWrapper.SetRepository<Customer>().TableNoTracking
|
||||
.Where(c => c.Id == order.CustomerId)
|
||||
.Select(CustomerMapper.ProjectToSDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
if (customer != null)
|
||||
{
|
||||
await smsService.SendLookUpAsync(customer.PhoneNumber, "customer-deliveryOrder",
|
||||
order.FactorCode, request.TrackingCode,null, PersianDateTime.Today.ToLongDateString(), $"{customer.FirstName} {customer.LastName}");
|
||||
}
|
||||
}
|
||||
|
||||
_repositoryWrapper.SetRepository<Order>()
|
||||
|
||||
repositoryWrapper.SetRepository<Order>()
|
||||
.Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Netina.Domain.Dtos.LargDtos;
|
||||
using Syncfusion.Drawing;
|
||||
using Syncfusion.Drawing;
|
||||
using Syncfusion.Pdf;
|
||||
using Syncfusion.Pdf.Graphics;
|
||||
using Syncfusion.Pdf.Grid;
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Entities.Products;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
namespace Netina.Core.EntityServices.ReviewHandlers;
|
||||
namespace Netina.Core.EntityServices.ReviewHandlers;
|
||||
|
||||
public class ConfirmReviewCommandHandler : IRequestHandler<ConfirmReviewCommand , bool>
|
||||
{
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Folder Include="CoreServices\WebSiteServices\" />
|
||||
<Folder Include="CoreServices\SearchServices\" />
|
||||
<Folder Include="EntityServices\ProductHandlers\" />
|
||||
<Folder Include="EntityServices\ReviewHandlers\" />
|
||||
<Folder Include="Models\Api\" />
|
||||
|
@ -48,8 +47,8 @@
|
|||
<Using Include="Netina.Common.Models.Exception" />
|
||||
<Using Include="Netina.Core.Abstracts" />
|
||||
<Using Include="Netina.Core.BaseServices.Abstracts" />
|
||||
<Using Include="Netina.Core.CoreServices.Abstracts" />
|
||||
<Using Include="Netina.Core.CoreServices.CommandQueries.Commands" />
|
||||
<Using Include="Netina.Core.CoreServices.CommandQueries.Queries" />
|
||||
<Using Include="Netina.Core.EntityServices.Abstracts" />
|
||||
<Using Include="Netina.Domain" />
|
||||
<Using Include="Netina.Domain.CommandQueries.Commands" />
|
||||
|
@ -58,6 +57,8 @@
|
|||
<Using Include="Netina.Domain.Dtos.LargDtos" />
|
||||
<Using Include="Netina.Domain.Dtos.RequestDtos" />
|
||||
<Using Include="Netina.Domain.Dtos.ResponseDtos" />
|
||||
<Using Include="Netina.Domain.Dtos.ResponseDtos.Emalls" />
|
||||
<Using Include="Netina.Domain.Dtos.ResponseDtos.Torob" />
|
||||
<Using Include="Netina.Domain.Dtos.SmallDtos" />
|
||||
<Using Include="Netina.Domain.Entities.Blogs" />
|
||||
<Using Include="Netina.Domain.Entities.Brands" />
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
using Netina.Domain.Dtos.ResponseDtos.Torob;
|
||||
|
||||
namespace Netina.Domain.CommandQueries.Queries;
|
||||
|
||||
public sealed record GetTorobProductsQuery(int Page = 0) : IRequest<List<TorobProductResponseDto>>;
|
|
@ -0,0 +1,14 @@
|
|||
namespace Netina.Domain.Dtos.ResponseDtos.Emalls;
|
||||
|
||||
public class EmallsProductResponseDto
|
||||
{
|
||||
public string title { get; set; } = string.Empty;
|
||||
public string id { get; set; } = string.Empty;
|
||||
public int price { get; set; }
|
||||
public int? old_price { get; set; }
|
||||
public string category { get; set; }
|
||||
public string color { get; set; }
|
||||
public string guarantee { get; set; }
|
||||
public bool is_available { get; set; }
|
||||
public string url { get; set; }
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
namespace Netina.Domain.Dtos.ResponseDtos.Emalls;
|
||||
|
||||
public class EmallsResponseDto
|
||||
{
|
||||
public List<EmallsProductResponseDto> products { get; set; } = new();
|
||||
public int total_items { get; set; }
|
||||
public int pages_count { get; set; }
|
||||
public int item_per_page { get; set; }
|
||||
public int page_num { get; set; }
|
||||
}
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dtos\FilterDtos\" />
|
||||
<Folder Include="Dtos\ResponseDtos\Emalls\" />
|
||||
<Folder Include="Entities\StorageFiles\" />
|
||||
<Folder Include="Models\Districts\" />
|
||||
<Folder Include="Models\Settings\" />
|
||||
|
|
|
@ -6,7 +6,9 @@ public interface IKaveNegarRestApi
|
|||
{
|
||||
|
||||
[Post("/{apiKey}/verify/lookup.json")]
|
||||
Task<KaveNegarResponse> SendLookUp(string apiKey, [Query] string receptor, [Query] string token, [Query] string token2, [Query] string token10, [Query] string token20, [Query] string template);
|
||||
Task<KaveNegarResponse> SendLookUp(string apiKey, [Query] string receptor, [Query] string template, [Query] string token, [Query] string? token2=null,
|
||||
[Query]string? token3 = null, [Query] string? token10 = null, [Query] string? token20 = null);
|
||||
|
||||
[Post("/{apiKey}/sms/send.json")]
|
||||
Task<KaveNegarResponse> SendSms(string apiKey, [Query] string receptor, [Query] string message, [Query] string sender);
|
||||
}
|
|
@ -1,10 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Core.Abstracts;
|
||||
using Netina.Domain.Models.Settings;
|
||||
using Netina.Infrastructure.RestServices;
|
||||
|
||||
namespace Netina.Infrastructure.Services;
|
||||
namespace Netina.Infrastructure.Services;
|
||||
|
||||
public class SmsService : ISmsService
|
||||
{
|
||||
|
@ -25,7 +19,9 @@ public class SmsService : ISmsService
|
|||
}
|
||||
public async Task SendForgerPasswordAsync(string phoneNumber, string newPassword)
|
||||
{
|
||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, newPassword, null, null, null, "forgetPassword");
|
||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, newPassword,
|
||||
null, null
|
||||
, null, null, "forgetPassword");
|
||||
|
||||
if (rest.Return.status != 200)
|
||||
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message);
|
||||
|
@ -36,8 +32,7 @@ public class SmsService : ISmsService
|
|||
|
||||
try
|
||||
{
|
||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber,
|
||||
verifyCode, null, null, null, _siteSettings.LoginOtpTemplate);
|
||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, _siteSettings.LoginOtpTemplate,verifyCode);
|
||||
|
||||
if (rest.Return.status != 200 && _environment.IsProduction())
|
||||
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message);
|
||||
|
@ -45,7 +40,7 @@ public class SmsService : ISmsService
|
|||
catch (ApiException apiException)
|
||||
{
|
||||
if (_environment.IsProduction())
|
||||
throw ;
|
||||
throw;
|
||||
else
|
||||
_logger.LogError(apiException.Message);
|
||||
}
|
||||
|
@ -58,4 +53,23 @@ public class SmsService : ISmsService
|
|||
}
|
||||
}
|
||||
|
||||
public async Task SendLookUpAsync(string phoneNumber, string template, string token, string? token2 = null, string? token3 = null, string? token10 = null, string? token20 = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber,template,token,token2,token3,token10,token20);
|
||||
|
||||
if (rest.Return.status != 200)
|
||||
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message);
|
||||
}
|
||||
catch (ApiException apiException)
|
||||
{
|
||||
_logger.LogError(apiException.Message);
|
||||
}
|
||||
catch (Exception apiException)
|
||||
{
|
||||
_logger.LogError(apiException.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
using Microsoft.IdentityModel.Tokens;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Core.Abstracts;
|
||||
using Netina.Core.CoreServices.Abstracts;
|
||||
using Netina.Core.BaseServices.Abstracts;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.CommandQueries.Queries;
|
||||
using Netina.Domain.Enums;
|
||||
|
|
Loading…
Reference in New Issue