tüm public servisler birleştirildi
This commit is contained in:
parent
53ce6238c2
commit
7a57112e0b
16 changed files with 325 additions and 466 deletions
|
|
@ -9,9 +9,6 @@ namespace Kurs.Platform.Blog;
|
|||
public interface IBlogAppService : IApplicationService
|
||||
{
|
||||
// Blog Post methods
|
||||
Task<BlogPostAndCategoriesDto> GetPostListAsync(GetBlogPostsInput input);
|
||||
Task<BlogPostDto> GetPostAsync(Guid id);
|
||||
Task<BlogPostDto> GetPostBySlugAsync(string slug);
|
||||
Task<BlogPostDto> CreatePostAsync(CreateUpdateBlogPostDto input);
|
||||
Task<BlogPostDto> UpdatePostAsync(Guid id, CreateUpdateBlogPostDto input);
|
||||
Task DeletePostAsync(Guid id);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Localization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Users;
|
||||
|
||||
|
|
@ -33,160 +29,6 @@ public class BlogAppService : PlatformAppService, IBlogAppService
|
|||
_localizer = localizer;
|
||||
}
|
||||
|
||||
// Blog Post methods
|
||||
[AllowAnonymous]
|
||||
public async Task<BlogPostAndCategoriesDto> GetPostListAsync(GetBlogPostsInput input)
|
||||
{
|
||||
// IQueryable
|
||||
var postQuery = await _postRepository.GetQueryableAsync();
|
||||
|
||||
// 🔎 Arama
|
||||
if (!input.Search.IsNullOrWhiteSpace())
|
||||
{
|
||||
postQuery = postQuery.Where(p =>
|
||||
p.ContentTr.Contains(input.Search) ||
|
||||
p.ContentEn.Contains(input.Search));
|
||||
}
|
||||
|
||||
// 📁 Kategori filtresi
|
||||
if (input.CategoryId.HasValue)
|
||||
{
|
||||
postQuery = postQuery.Where(p => p.CategoryId == input.CategoryId.Value);
|
||||
}
|
||||
|
||||
// Toplam adet (sayfalama öncesi)
|
||||
var totalCount = await AsyncExecuter.CountAsync(postQuery);
|
||||
|
||||
// Sayfalama + sıralama
|
||||
var pagedPosts = await AsyncExecuter.ToListAsync(
|
||||
postQuery
|
||||
.OrderByDescending(p => p.CreationTime)
|
||||
.PageBy(input)
|
||||
);
|
||||
|
||||
// Sayfadaki kategori kayıtları
|
||||
var categoryIds = pagedPosts.Select(x => x.CategoryId).Distinct().ToList();
|
||||
var pageCategories = await _categoryRepository.GetListAsync(x => categoryIds.Contains(x.Id));
|
||||
var categoryDict = pageCategories.ToDictionary(x => x.Id, x => x);
|
||||
|
||||
// Post DTO mapping
|
||||
var postDtos = pagedPosts.Select(post =>
|
||||
{
|
||||
var dto = ObjectMapper.Map<BlogPost, BlogPostListDto>(post);
|
||||
if (categoryDict.TryGetValue(post.CategoryId, out var c))
|
||||
{
|
||||
dto.Category = ObjectMapper.Map<BlogCategory, BlogCategoryDto>(c);
|
||||
}
|
||||
|
||||
dto.Author = new AuthorDto { Id = post.AuthorId, Name = "User" };
|
||||
return dto;
|
||||
}).ToList();
|
||||
|
||||
// ----------- KATEGORİLER (PostCount ile) -----------
|
||||
var allCategories = await _categoryRepository.GetListAsync();
|
||||
|
||||
var allPostQuery = await _postRepository.GetQueryableAsync();
|
||||
var counts = await AsyncExecuter.ToListAsync(
|
||||
allPostQuery
|
||||
.Where(p => p.IsPublished)
|
||||
.GroupBy(p => p.CategoryId)
|
||||
.Select(g => new { g.Key, Count = g.Count() })
|
||||
);
|
||||
|
||||
var countDict = counts.ToDictionary(x => x.Key, x => x.Count);
|
||||
|
||||
var categoryDtos = ObjectMapper.Map<List<BlogCategory>, List<BlogCategoryDto>>(allCategories);
|
||||
foreach (var dto in categoryDtos)
|
||||
{
|
||||
dto.PostCount = countDict.GetOrDefault(dto.Id);
|
||||
}
|
||||
|
||||
return new BlogPostAndCategoriesDto
|
||||
{
|
||||
Posts = new PagedResultDto<BlogPostListDto>(totalCount, postDtos),
|
||||
Categories = categoryDtos
|
||||
};
|
||||
}
|
||||
|
||||
// public async Task<PagedResultDto<BlogPostListDto>> GetPostsAsync(GetBlogPostsInput input)
|
||||
// {
|
||||
// var allPosts = await _postRepository.GetListAsync(); // Tüm kayıtlar memory'ye alınır
|
||||
// var filtered = allPosts.Where(post =>
|
||||
// {
|
||||
// var searchMatch = string.IsNullOrWhiteSpace(input.Search) ||
|
||||
// post.ContentTr.Contains(input.Search, StringComparison.OrdinalIgnoreCase) ||
|
||||
// post.ContentEn.Contains(input.Search, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// var categoryMatch = !input.CategoryId.HasValue || post.CategoryId == input.CategoryId.Value;
|
||||
|
||||
// return searchMatch && categoryMatch;
|
||||
// }).ToList();
|
||||
|
||||
// var totalCount = filtered.Count;
|
||||
// var pagedPosts = filtered
|
||||
// .OrderByDescending(x => x.CreationTime)
|
||||
// .Skip(input.SkipCount)
|
||||
// .Take(input.MaxResultCount)
|
||||
// .ToList();
|
||||
|
||||
// var categoryIds = pagedPosts.Select(x => x.CategoryId).Distinct().ToList();
|
||||
// var categories = await _categoryRepository.GetListAsync(x => categoryIds.Contains(x.Id));
|
||||
// var categoryDict = categories.ToDictionary(x => x.Id, x => x);
|
||||
|
||||
// var postIds = pagedPosts.Select(x => x.Id).ToList();
|
||||
// var postDtos = pagedPosts.Select(post =>
|
||||
// {
|
||||
// var dto = ObjectMapper.Map<BlogPost, BlogPostListDto>(post);
|
||||
// if (categoryDict.TryGetValue(post.CategoryId, out var category))
|
||||
// {
|
||||
// dto.Category = ObjectMapper.Map<BlogCategory, BlogCategoryDto>(category);
|
||||
// }
|
||||
|
||||
// dto.Author = new AuthorDto
|
||||
// {
|
||||
// Id = post.AuthorId,
|
||||
// Name = "User"
|
||||
// };
|
||||
|
||||
// return dto;
|
||||
// }).ToList();
|
||||
|
||||
// return new PagedResultDto<BlogPostListDto>(totalCount, postDtos);
|
||||
// }
|
||||
|
||||
[AllowAnonymous]
|
||||
public async Task<BlogPostDto> GetPostAsync(Guid id)
|
||||
{
|
||||
var post = await _postRepository.GetAsync(id);
|
||||
var dto = ObjectMapper.Map<BlogPost, BlogPostDto>(post);
|
||||
|
||||
// Get category
|
||||
dto.Category = ObjectMapper.Map<BlogCategory, BlogCategoryDto>(
|
||||
await _categoryRepository.GetAsync(post.CategoryId)
|
||||
);
|
||||
|
||||
// Get author info
|
||||
dto.Author = new AuthorDto
|
||||
{
|
||||
Id = post.AuthorId,
|
||||
Name = "User"
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
public async Task<BlogPostDto> GetPostBySlugAsync(string slug)
|
||||
{
|
||||
var post = await _postRepository.FirstOrDefaultAsync(x => x.Slug == slug);
|
||||
if (post == null)
|
||||
{
|
||||
throw new EntityNotFoundException(typeof(BlogPost));
|
||||
}
|
||||
|
||||
return await GetPostAsync(post.Id);
|
||||
}
|
||||
|
||||
public async Task<BlogPostDto> CreatePostAsync(CreateUpdateBlogPostDto input)
|
||||
{
|
||||
var post = new BlogPost(
|
||||
|
|
@ -210,6 +52,26 @@ public class BlogAppService : PlatformAppService, IBlogAppService
|
|||
return await GetPostAsync(post.Id);
|
||||
}
|
||||
|
||||
private async Task<BlogPostDto> GetPostAsync(Guid id)
|
||||
{
|
||||
var post = await _postRepository.GetAsync(id);
|
||||
var dto = ObjectMapper.Map<BlogPost, BlogPostDto>(post);
|
||||
|
||||
// Get category
|
||||
dto.Category = ObjectMapper.Map<BlogCategory, BlogCategoryDto>(
|
||||
await _categoryRepository.GetAsync(post.CategoryId)
|
||||
);
|
||||
|
||||
// Get author info
|
||||
dto.Author = new AuthorDto
|
||||
{
|
||||
Id = post.AuthorId,
|
||||
Name = "User"
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<BlogPostDto> UpdatePostAsync(Guid id, CreateUpdateBlogPostDto input)
|
||||
{
|
||||
var post = await _postRepository.GetAsync(id);
|
||||
|
|
@ -296,31 +158,6 @@ public class BlogAppService : PlatformAppService, IBlogAppService
|
|||
return await GetPostAsync(id);
|
||||
}
|
||||
|
||||
// // Blog Category methods
|
||||
// [AllowAnonymous]
|
||||
// public async Task<List<BlogCategoryDto>> GetCategoriesAsync()
|
||||
// {
|
||||
// var categories = await _categoryRepository.GetListAsync();
|
||||
|
||||
// var postQuery = await _postRepository.GetQueryableAsync();
|
||||
|
||||
// var groupedCounts = postQuery
|
||||
// .Where(p => p.IsPublished) // sadece yayınlanmış yazılar
|
||||
// .GroupBy(p => p.CategoryId)
|
||||
// .Select(g => new { CategoryId = g.Key, Count = g.Count() })
|
||||
// .ToList();
|
||||
|
||||
// var dtoList = ObjectMapper.Map<List<BlogCategory>, List<BlogCategoryDto>>(categories);
|
||||
|
||||
// foreach (var dto in dtoList)
|
||||
// {
|
||||
// dto.PostCount = groupedCounts
|
||||
// .FirstOrDefault(x => x.CategoryId == dto.Id)?.Count ?? 0;
|
||||
// }
|
||||
|
||||
// return dtoList;
|
||||
// }
|
||||
|
||||
public async Task<BlogCategoryDto> GetCategoryAsync(Guid id)
|
||||
{
|
||||
var category = await _categoryRepository.GetAsync(id);
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
using AutoMapper;
|
||||
using Kurs.Platform.Blog;
|
||||
using Kurs.Platform.Entities;
|
||||
|
||||
namespace Kurs.Platform;
|
||||
|
||||
public class BlogAutoMapperProfile : Profile
|
||||
{
|
||||
public BlogAutoMapperProfile()
|
||||
{
|
||||
// Blog mappings
|
||||
CreateMap<BlogCategory, BlogCategoryDto>();
|
||||
CreateMap<BlogPost, BlogPostDto>();
|
||||
CreateMap<BlogPost, BlogPostListDto>();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Kurs.Platform.Data.Seeds;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Sender.Mail;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Settings;
|
||||
|
||||
namespace Kurs.Platform.Demos;
|
||||
|
||||
public class DemoAppService : PlatformAppService
|
||||
{
|
||||
private readonly ISettingProvider _settingProvider;
|
||||
private readonly IKursEmailSender _emailSender;
|
||||
private readonly IRepository<Demo, Guid> _repository;
|
||||
|
||||
public DemoAppService(
|
||||
ISettingProvider settingProvider,
|
||||
IKursEmailSender emailSender,
|
||||
IRepository<Demo, Guid> repository
|
||||
)
|
||||
{
|
||||
_settingProvider = settingProvider;
|
||||
_emailSender = emailSender;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
public async Task CreateDemoAsync(DemoDto input)
|
||||
{
|
||||
var demo = ObjectMapper.Map<DemoDto, Demo>(input);
|
||||
await _repository.InsertAsync(demo);
|
||||
|
||||
var bodyBuilder = new StringBuilder();
|
||||
bodyBuilder.AppendLine($"Şirket: {input.OrganizationName}");
|
||||
bodyBuilder.AppendLine($"Ad Soyad: {input.FullName}");
|
||||
bodyBuilder.AppendLine($"E-Posta: {input.Email}");
|
||||
bodyBuilder.AppendLine($"Telefon: {input.Phone}");
|
||||
bodyBuilder.AppendLine($"Adres: {input.Address}");
|
||||
bodyBuilder.AppendLine($"Şube Sayısı: {input.NumberOfBranches}");
|
||||
bodyBuilder.AppendLine($"Kullanıcı Sayısı: {input.NumberOfUsers}");
|
||||
bodyBuilder.AppendLine($"Mesaj: {input.Message}");
|
||||
|
||||
var SenderName = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName);
|
||||
var SenderEmailAddress = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress);
|
||||
|
||||
await _emailSender.QueueEmailAsync(
|
||||
SenderEmailAddress,
|
||||
new KeyValuePair<string, string>(SenderName, SenderEmailAddress),
|
||||
null,
|
||||
bodyBuilder.ToString(),
|
||||
subject: PlatformConsts.AppName + " : Demo Talebi");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using AutoMapper;
|
||||
using Kurs.Platform.Entities;
|
||||
|
||||
namespace Kurs.Platform.Demos;
|
||||
|
||||
public class DemoAutoMapperProfile : Profile
|
||||
{
|
||||
public DemoAutoMapperProfile()
|
||||
{
|
||||
CreateMap<Demo, DemoDto>().ReverseMap();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
using System;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Kurs.Platform.Entities;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kurs.Platform.Orders;
|
||||
|
||||
public interface IOrderAppService : IApplicationService
|
||||
{
|
||||
Task<List<ProductDto>> GetProductListAsync();
|
||||
Task<List<PaymentMethodDto>> GetPaymentMethodListAsync();
|
||||
Task<List<InstallmentOptionDto>> GetInstallmentOptionListAsync();
|
||||
|
||||
Task<OrderDto> CreateAsync(OrderDto input);
|
||||
}
|
||||
|
||||
public class OrderAppService : ApplicationService, IOrderAppService
|
||||
{
|
||||
private readonly IRepository<Product, Guid> _productRepository;
|
||||
private readonly IRepository<PaymentMethod, string> _paymentMethodRepository;
|
||||
private readonly IRepository<InstallmentOption, int> _installmentOptionRepository;
|
||||
private readonly IRepository<Order, Guid> _orderRepository;
|
||||
|
||||
public OrderAppService(IRepository<Product, Guid> productRepository,
|
||||
IRepository<PaymentMethod, string> paymentMethodRepository,
|
||||
IRepository<InstallmentOption, int> installmentOptionRepository,
|
||||
IRepository<Order, Guid> orderRepository)
|
||||
{
|
||||
_productRepository = productRepository;
|
||||
_paymentMethodRepository = paymentMethodRepository;
|
||||
_installmentOptionRepository = installmentOptionRepository;
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
public async Task<List<ProductDto>> GetProductListAsync()
|
||||
{
|
||||
var products = await _productRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<Product>, List<ProductDto>>(products.OrderBy(p => p.Order).ToList());
|
||||
}
|
||||
|
||||
public async Task<List<PaymentMethodDto>> GetPaymentMethodListAsync()
|
||||
{
|
||||
var paymentMethods = await _paymentMethodRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<PaymentMethod>, List<PaymentMethodDto>>(paymentMethods);
|
||||
}
|
||||
|
||||
public async Task<List<InstallmentOptionDto>> GetInstallmentOptionListAsync()
|
||||
{
|
||||
var installmentOptions = await _installmentOptionRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<InstallmentOption>, List<InstallmentOptionDto>>(installmentOptions);
|
||||
}
|
||||
|
||||
public async Task<OrderDto> CreateAsync(OrderDto input)
|
||||
{
|
||||
var entity = new Order()
|
||||
{
|
||||
TenantId = input.Tenant.Id,
|
||||
InstitutionName = input.Tenant.InstitutionName,
|
||||
Founder = input.Tenant.Founder,
|
||||
VknTckn = input.Tenant.VknTckn,
|
||||
TaxOffice = input.Tenant.TaxOffice,
|
||||
Address = input.Tenant.Address,
|
||||
Address2 = input.Tenant.Address2,
|
||||
District = input.Tenant.District,
|
||||
Country = input.Tenant.Country,
|
||||
City = input.Tenant.City,
|
||||
PostalCode = input.Tenant.PostalCode,
|
||||
Phone = input.Tenant.Phone,
|
||||
Mobile = input.Tenant.Mobile,
|
||||
Fax = input.Tenant.Fax,
|
||||
Email = input.Tenant.Email,
|
||||
Website = input.Tenant.Website,
|
||||
|
||||
Subtotal = input.Subtotal,
|
||||
Commission = input.Commission,
|
||||
Total = input.Total,
|
||||
PaymentMethod = input.PaymentMethod,
|
||||
Installments = input.Installments,
|
||||
InstallmentName = input.InstallmentName,
|
||||
PaymentDataJson = JsonConvert.SerializeObject(input.PaymentData),
|
||||
};
|
||||
|
||||
foreach (var item in input.Items)
|
||||
{
|
||||
entity.Items.Add(new OrderItem
|
||||
{
|
||||
OrderId = entity.Id,
|
||||
Order = entity,
|
||||
ProductId = item.Product.Id,
|
||||
ProductName = item.Product.Name,
|
||||
BillingCycle = item.BillingCycle,
|
||||
Quantity = item.Quantity,
|
||||
TotalPrice = item.TotalPrice
|
||||
});
|
||||
}
|
||||
|
||||
await _orderRepository.InsertAsync(entity, autoSave: true);
|
||||
|
||||
return new OrderDto
|
||||
{
|
||||
Id = entity.Id,
|
||||
Total = entity.Total,
|
||||
PaymentMethod = entity.PaymentMethod
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using AutoMapper;
|
||||
using Kurs.Platform.Entities;
|
||||
|
||||
namespace Kurs.Platform.Orders;
|
||||
|
||||
public class OrderApplicationAutoMapperProfile : Profile
|
||||
{
|
||||
public OrderApplicationAutoMapperProfile()
|
||||
{
|
||||
CreateMap<Product, ProductDto>().ReverseMap();
|
||||
CreateMap<PaymentMethod, PaymentMethodDto>();
|
||||
CreateMap<InstallmentOption, InstallmentOptionDto>();
|
||||
CreateMap<Order, OrderDto>();
|
||||
}
|
||||
}
|
||||
271
api/src/Kurs.Platform.Application/Public/PublicAppService.cs
Normal file
271
api/src/Kurs.Platform.Application/Public/PublicAppService.cs
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Services;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using System.Text;
|
||||
using Kurs.Platform.Data.Seeds;
|
||||
using Kurs.Sender.Mail;
|
||||
using Volo.Abp.Settings;
|
||||
using Kurs.Platform.Demos;
|
||||
using Kurs.Platform.Blog;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using System.Linq;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Kurs.Platform.Orders;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class PublicAppService : PlatformAppService
|
||||
{
|
||||
private readonly IRepository<Service, Guid> _serviceRepository;
|
||||
private readonly ISettingProvider _settingProvider;
|
||||
private readonly IKursEmailSender _emailSender;
|
||||
private readonly IRepository<Demo, Guid> _demoRepository;
|
||||
private readonly IRepository<BlogPost, Guid> _postRepository;
|
||||
private readonly IRepository<BlogCategory, Guid> _categoryRepository;
|
||||
private readonly IRepository<Product, Guid> _productRepository;
|
||||
private readonly IRepository<PaymentMethod, string> _paymentMethodRepository;
|
||||
private readonly IRepository<InstallmentOption, int> _installmentOptionRepository;
|
||||
private readonly IRepository<Order, Guid> _orderRepository;
|
||||
|
||||
public PublicAppService(
|
||||
IRepository<Service, Guid> serviceRepository,
|
||||
ISettingProvider settingProvider,
|
||||
IKursEmailSender emailSender,
|
||||
IRepository<Demo, Guid> demoRepository,
|
||||
IRepository<BlogPost, Guid> postRepository,
|
||||
IRepository<BlogCategory, Guid> categoryRepository,
|
||||
IRepository<Product, Guid> productRepository,
|
||||
IRepository<PaymentMethod, string> paymentMethodRepository,
|
||||
IRepository<InstallmentOption, int> installmentOptionRepository,
|
||||
IRepository<Order, Guid> orderRepository
|
||||
)
|
||||
{
|
||||
_serviceRepository = serviceRepository;
|
||||
_settingProvider = settingProvider;
|
||||
_emailSender = emailSender;
|
||||
_demoRepository = demoRepository;
|
||||
_postRepository = postRepository;
|
||||
_categoryRepository = categoryRepository;
|
||||
_productRepository = productRepository;
|
||||
_paymentMethodRepository = paymentMethodRepository;
|
||||
_installmentOptionRepository = installmentOptionRepository;
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
public async Task<List<ServiceDto>> GetServicesListAsync()
|
||||
{
|
||||
var entity = await _serviceRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<Service>, List<ServiceDto>>(entity);
|
||||
}
|
||||
|
||||
public async Task CreateDemoAsync(DemoDto input)
|
||||
{
|
||||
var demo = ObjectMapper.Map<DemoDto, Demo>(input);
|
||||
await _demoRepository.InsertAsync(demo);
|
||||
|
||||
var bodyBuilder = new StringBuilder();
|
||||
bodyBuilder.AppendLine($"Şirket: {input.OrganizationName}");
|
||||
bodyBuilder.AppendLine($"Ad Soyad: {input.FullName}");
|
||||
bodyBuilder.AppendLine($"E-Posta: {input.Email}");
|
||||
bodyBuilder.AppendLine($"Telefon: {input.Phone}");
|
||||
bodyBuilder.AppendLine($"Adres: {input.Address}");
|
||||
bodyBuilder.AppendLine($"Şube Sayısı: {input.NumberOfBranches}");
|
||||
bodyBuilder.AppendLine($"Kullanıcı Sayısı: {input.NumberOfUsers}");
|
||||
bodyBuilder.AppendLine($"Mesaj: {input.Message}");
|
||||
|
||||
var SenderName = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName);
|
||||
var SenderEmailAddress = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress);
|
||||
|
||||
await _emailSender.QueueEmailAsync(
|
||||
SenderEmailAddress,
|
||||
new KeyValuePair<string, string>(SenderName, SenderEmailAddress),
|
||||
null,
|
||||
bodyBuilder.ToString(),
|
||||
subject: PlatformConsts.AppName + " : Demo Talebi");
|
||||
|
||||
}
|
||||
|
||||
public async Task<BlogPostAndCategoriesDto> GetPostListAsync(GetBlogPostsInput input)
|
||||
{
|
||||
// IQueryable
|
||||
var postQuery = await _postRepository.GetQueryableAsync();
|
||||
|
||||
// 🔎 Arama
|
||||
if (!input.Search.IsNullOrWhiteSpace())
|
||||
{
|
||||
postQuery = postQuery.Where(p =>
|
||||
p.ContentTr.Contains(input.Search) ||
|
||||
p.ContentEn.Contains(input.Search));
|
||||
}
|
||||
|
||||
// 📁 Kategori filtresi
|
||||
if (input.CategoryId.HasValue)
|
||||
{
|
||||
postQuery = postQuery.Where(p => p.CategoryId == input.CategoryId.Value);
|
||||
}
|
||||
|
||||
// Toplam adet (sayfalama öncesi)
|
||||
var totalCount = await AsyncExecuter.CountAsync(postQuery);
|
||||
|
||||
// Sayfalama + sıralama
|
||||
var pagedPosts = await AsyncExecuter.ToListAsync(
|
||||
postQuery
|
||||
.OrderByDescending(p => p.CreationTime)
|
||||
.PageBy(input)
|
||||
);
|
||||
|
||||
// Sayfadaki kategori kayıtları
|
||||
var categoryIds = pagedPosts.Select(x => x.CategoryId).Distinct().ToList();
|
||||
var pageCategories = await _categoryRepository.GetListAsync(x => categoryIds.Contains(x.Id));
|
||||
var categoryDict = pageCategories.ToDictionary(x => x.Id, x => x);
|
||||
|
||||
// Post DTO mapping
|
||||
var postDtos = pagedPosts.Select(post =>
|
||||
{
|
||||
var dto = ObjectMapper.Map<BlogPost, BlogPostListDto>(post);
|
||||
if (categoryDict.TryGetValue(post.CategoryId, out var c))
|
||||
{
|
||||
dto.Category = ObjectMapper.Map<BlogCategory, BlogCategoryDto>(c);
|
||||
}
|
||||
|
||||
dto.Author = new AuthorDto { Id = post.AuthorId, Name = "User" };
|
||||
return dto;
|
||||
}).ToList();
|
||||
|
||||
// ----------- KATEGORİLER (PostCount ile) -----------
|
||||
var allCategories = await _categoryRepository.GetListAsync();
|
||||
|
||||
var allPostQuery = await _postRepository.GetQueryableAsync();
|
||||
var counts = await AsyncExecuter.ToListAsync(
|
||||
allPostQuery
|
||||
.Where(p => p.IsPublished)
|
||||
.GroupBy(p => p.CategoryId)
|
||||
.Select(g => new { g.Key, Count = g.Count() })
|
||||
);
|
||||
|
||||
var countDict = counts.ToDictionary(x => x.Key, x => x.Count);
|
||||
|
||||
var categoryDtos = ObjectMapper.Map<List<BlogCategory>, List<BlogCategoryDto>>(allCategories);
|
||||
foreach (var dto in categoryDtos)
|
||||
{
|
||||
dto.PostCount = countDict.GetOrDefault(dto.Id);
|
||||
}
|
||||
|
||||
return new BlogPostAndCategoriesDto
|
||||
{
|
||||
Posts = new PagedResultDto<BlogPostListDto>(totalCount, postDtos),
|
||||
Categories = categoryDtos
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<BlogPostDto> GetPostAsync(Guid id)
|
||||
{
|
||||
var post = await _postRepository.GetAsync(id);
|
||||
var dto = ObjectMapper.Map<BlogPost, BlogPostDto>(post);
|
||||
|
||||
// Get category
|
||||
dto.Category = ObjectMapper.Map<BlogCategory, BlogCategoryDto>(
|
||||
await _categoryRepository.GetAsync(post.CategoryId)
|
||||
);
|
||||
|
||||
// Get author info
|
||||
dto.Author = new AuthorDto
|
||||
{
|
||||
Id = post.AuthorId,
|
||||
Name = "User"
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<BlogPostDto> GetPostBySlugAsync(string slug)
|
||||
{
|
||||
var post = await _postRepository.FirstOrDefaultAsync(x => x.Slug == slug);
|
||||
if (post == null)
|
||||
{
|
||||
throw new EntityNotFoundException(typeof(BlogPost));
|
||||
}
|
||||
|
||||
return await GetPostAsync(post.Id);
|
||||
}
|
||||
|
||||
public async Task<List<ProductDto>> GetProductListAsync()
|
||||
{
|
||||
var products = await _productRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<Product>, List<ProductDto>>(products.OrderBy(p => p.Order).ToList());
|
||||
}
|
||||
|
||||
public async Task<List<PaymentMethodDto>> GetPaymentMethodListAsync()
|
||||
{
|
||||
var paymentMethods = await _paymentMethodRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<PaymentMethod>, List<PaymentMethodDto>>(paymentMethods);
|
||||
}
|
||||
|
||||
public async Task<List<InstallmentOptionDto>> GetInstallmentOptionListAsync()
|
||||
{
|
||||
var installmentOptions = await _installmentOptionRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<InstallmentOption>, List<InstallmentOptionDto>>(installmentOptions);
|
||||
}
|
||||
|
||||
public async Task<OrderDto> CreateOrderAsync(OrderDto input)
|
||||
{
|
||||
var entity = new Order()
|
||||
{
|
||||
TenantId = input.Tenant.Id,
|
||||
InstitutionName = input.Tenant.InstitutionName,
|
||||
Founder = input.Tenant.Founder,
|
||||
VknTckn = input.Tenant.VknTckn,
|
||||
TaxOffice = input.Tenant.TaxOffice,
|
||||
Address = input.Tenant.Address,
|
||||
Address2 = input.Tenant.Address2,
|
||||
District = input.Tenant.District,
|
||||
Country = input.Tenant.Country,
|
||||
City = input.Tenant.City,
|
||||
PostalCode = input.Tenant.PostalCode,
|
||||
Phone = input.Tenant.Phone,
|
||||
Mobile = input.Tenant.Mobile,
|
||||
Fax = input.Tenant.Fax,
|
||||
Email = input.Tenant.Email,
|
||||
Website = input.Tenant.Website,
|
||||
|
||||
Subtotal = input.Subtotal,
|
||||
Commission = input.Commission,
|
||||
Total = input.Total,
|
||||
PaymentMethod = input.PaymentMethod,
|
||||
Installments = input.Installments,
|
||||
InstallmentName = input.InstallmentName,
|
||||
PaymentDataJson = JsonSerializer.Serialize(input.PaymentData),
|
||||
};
|
||||
|
||||
foreach (var item in input.Items)
|
||||
{
|
||||
entity.Items.Add(new OrderItem
|
||||
{
|
||||
OrderId = entity.Id,
|
||||
Order = entity,
|
||||
ProductId = item.Product.Id,
|
||||
ProductName = item.Product.Name,
|
||||
BillingCycle = item.BillingCycle,
|
||||
Quantity = item.Quantity,
|
||||
TotalPrice = item.TotalPrice
|
||||
});
|
||||
}
|
||||
|
||||
await _orderRepository.InsertAsync(entity, autoSave: true);
|
||||
|
||||
return new OrderDto
|
||||
{
|
||||
Id = entity.Id,
|
||||
Total = entity.Total,
|
||||
PaymentMethod = entity.PaymentMethod
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using AutoMapper;
|
||||
using Kurs.Platform.Blog;
|
||||
using Kurs.Platform.Demos;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Orders;
|
||||
using Kurs.Platform.Services;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class PublicAutoMapperProfile : Profile
|
||||
{
|
||||
public PublicAutoMapperProfile()
|
||||
{
|
||||
CreateMap<Demo, DemoDto>().ReverseMap();
|
||||
CreateMap<Service, ServiceDto>();
|
||||
CreateMap<BlogCategory, BlogCategoryDto>();
|
||||
CreateMap<BlogPost, BlogPostDto>();
|
||||
CreateMap<BlogPost, BlogPostListDto>();
|
||||
CreateMap<Product, ProductDto>().ReverseMap();
|
||||
CreateMap<PaymentMethod, PaymentMethodDto>();
|
||||
CreateMap<InstallmentOption, InstallmentOptionDto>();
|
||||
CreateMap<Order, OrderDto>();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Services;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Kurs.Platform.Dashboard;
|
||||
|
||||
public class ServiceAppService : PlatformAppService
|
||||
{
|
||||
private readonly IRepository<Service, Guid> serviceRepository;
|
||||
|
||||
public ServiceAppService(
|
||||
IRepository<Service, Guid> serviceRepository)
|
||||
{
|
||||
this.serviceRepository = serviceRepository;
|
||||
}
|
||||
|
||||
public async Task<List<ServiceDto>> GetListAsync()
|
||||
{
|
||||
var entity = await serviceRepository.GetListAsync();
|
||||
|
||||
return ObjectMapper.Map<List<Service>, List<ServiceDto>>(entity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
using AutoMapper;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Services;
|
||||
|
||||
namespace Kurs.Platform;
|
||||
|
||||
public class ServiceAutoMapperProfile : Profile
|
||||
{
|
||||
public ServiceAutoMapperProfile()
|
||||
{
|
||||
CreateMap<Service, ServiceDto>();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
|
||||
namespace Kurs.Platform.Orders;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import apiService from '@/services/api.service'
|
|||
class BlogService {
|
||||
async getPosts(params: BlogListParams = {}): Promise<BlogPostAndCategoriesDto> {
|
||||
const response = await apiService.fetchData<BlogPostAndCategoriesDto>({
|
||||
url: '/api/app/blog/post-list',
|
||||
url: '/api/app/public/post-list',
|
||||
method: 'GET',
|
||||
params,
|
||||
})
|
||||
|
|
@ -20,15 +20,7 @@ class BlogService {
|
|||
|
||||
async getPostBySlug(slug: string): Promise<BlogPost> {
|
||||
const response = await apiService.fetchData<BlogPost>({
|
||||
url: `/api/app/blog/post-by-slug?slug=${slug}`,
|
||||
method: 'GET',
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
async getPost(idOrSlug: string): Promise<BlogPost> {
|
||||
const response = await apiService.fetchData<BlogPost>({
|
||||
url: `/api/app/blog/posts/${idOrSlug}`,
|
||||
url: `/api/app/public/post-by-slug?slug=${slug}`,
|
||||
method: 'GET',
|
||||
})
|
||||
return response.data
|
||||
|
|
@ -75,14 +67,6 @@ class BlogService {
|
|||
return response.data
|
||||
}
|
||||
|
||||
// async getCategories(): Promise<BlogCategory[]> {
|
||||
// const response = await apiService.fetchData<BlogCategory[]>({
|
||||
// url: '/api/app/blog/categories',
|
||||
// method: 'GET',
|
||||
// })
|
||||
// return response.data
|
||||
// }
|
||||
|
||||
async deleteComment(id: string): Promise<void> {
|
||||
await apiService.fetchData({
|
||||
url: `/api/app/blog/comments/${id}`,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ import apiService from './api.service'
|
|||
export const createDemoAsync = (input: DemoDto) =>
|
||||
apiService.fetchData<DemoDto>({
|
||||
method: 'POST',
|
||||
url: `/api/app/demo/demo`,
|
||||
url: `/api/app/public/demo`,
|
||||
data: input as any,
|
||||
})
|
||||
|
|
@ -9,7 +9,7 @@ export class OrderService {
|
|||
apiService.fetchData<ProductDto[]>(
|
||||
{
|
||||
method: 'GET',
|
||||
url: '/api/app/order/product-list',
|
||||
url: '/api/app/public/product-list',
|
||||
},
|
||||
{ apiName: this.apiName },
|
||||
)
|
||||
|
|
@ -18,7 +18,7 @@ export class OrderService {
|
|||
apiService.fetchData<PaymentMethodDto[]>(
|
||||
{
|
||||
method: 'GET',
|
||||
url: '/api/app/order/payment-method-list',
|
||||
url: '/api/app/public/payment-method-list',
|
||||
},
|
||||
{ apiName: this.apiName },
|
||||
)
|
||||
|
|
@ -27,7 +27,7 @@ export class OrderService {
|
|||
apiService.fetchData<InstallmentOptionDto[]>(
|
||||
{
|
||||
method: 'GET',
|
||||
url: '/api/app/order/installment-option-list',
|
||||
url: '/api/app/public/installment-option-list',
|
||||
},
|
||||
{ apiName: this.apiName },
|
||||
)
|
||||
|
|
@ -40,7 +40,7 @@ export class OrderService {
|
|||
const response = await apiService.fetchData<{ orderId?: string; id?: string }>(
|
||||
{
|
||||
method: 'POST',
|
||||
url: `/api/app/order`,
|
||||
url: `/api/app/public/order`,
|
||||
data: {
|
||||
tenant: orderData.tenant,
|
||||
items: orderData.items,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export function getServices() {
|
|||
return apiService.fetchData<ServiceDto[]>(
|
||||
{
|
||||
method: 'GET',
|
||||
url: '/api/app/service',
|
||||
url: '/api/app/public/services-list',
|
||||
},
|
||||
{ apiName: 'Default' },
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue