=== .agent\skills\controller-authorization\SKILL.md === --- name: ControllerAuthorization description: H>ng dn cAi `t phAn quy?n (role-based authorization) chucn cho ASP.NET Core Controller trong d An Ladaer.BackEnd. --- # Controller Authorization Skill ## Tng quan M-i action trong Controller phi `c g_n attribute `[Authorize(Roles = "...")]` Y cp **action**, KHA"NG ch% dA1ng `[Authorize]` chung Y cp class. ?i?u nAy giAp kim soAt quy?n truy c-p chi tit theo tng nghip v. ## Quy t_c `t tAn Role TAn role theo format: **`{ControllerName}.{ActionName}`** - `ControllerName`: TAn controller **khA'ng cA3 h-u t` "Controller"** (vA- d: `Premise`, `Order`, `PremiseScoring`). - `ActionName`: TAn method action trong controller (vA- d: `Search`, `GetById`, `CreateOrUpdate`, `Delete`). ### VA- d | Controller | Action | Role | |---|---|---| | `OrderController` | `Search` | `Order.Search` | | `OrderController` | `CreateOrder` | `Order.CreateOrder` | | `PremiseController` | `Search` | `Premise.Search` | | `PremiseController` | `CreateOrUpdate` | `Premise.CreateOrUpdate` | | `PremiseController` | `Delete` | `Premise.Delete` | | `PremiseScoringController` | `SearchCriteria` | `PremiseScoring.SearchCriteria` | ## Cu trAc attribute chucn ```csharp [HttpPost("Search")] [Authorize(Roles = "ControllerName.ActionName")] public async Task Search([FromBody] SmartTableParam param) { var result = await _service.Search(param); return Ok(result); } ``` === .agent\skills\service-patterns\SKILL.md === --- name: ServicePatterns description: Quy t_c chucn cho Service layer (Interface, Implementation, DI, Repository, Result patterns). --- # Service Layer Patterns TAi liu nAy mA' t cAc quy t_c b_t buTc khi to Service trong d An LADA Backend. ## 1. File Organization (QUAN TRONG) **Interface vA Implementation phi nm trong cA1ng 1 file.** ``` o. ?AsNG: Services/Premises/PremiseService.cs +' chca c IPremiseService + PremiseService ?O SAI: Services/Premises/IPremiseService.cs +' ch% chca interface Services/Premises/PremiseService.cs +' ch% chca class ``` ## 2. File & Class Naming | Loi | Convention | VA- d | |------|-----------|-------| | File | `{Name}Service.cs` | `ExpenseService.cs` | | Interface | `I{Name}Service` | `IExpenseService` | | Class | `{Name}Service` | `ExpenseService` | ## 3. Standard Service Structure ```csharp public interface IExampleService { /// /// TAm kim entity /// Task> Search(SmartTableParam param); === .agent\skills\service-search-patterns\SKILL.md === --- name: ServiceSearchPatterns description: Quy t_c chucn cho Search/Filter/Sort/Pagination trong Service layer (SmartTable, AutoMapper). --- # Service Search Patterns TAi liu nAy mA' t quy t_c b_t buTc khi vit method Search trong Service. ## 1. Search Method Pattern (CHU"N) ```csharp public async Task> Search(SmartTableParam param) { IQueryable query = _repository.Query() .Include(x => x.RelatedEntity1) .Include(x => x.RelatedEntity2) .Where(x => !x.IsDeleted); // Nu cA3 soft delete // 1. L?c theo t khA3a tAm kim (PredicateObject pattern) if (param.Search.PredicateObject != null) { dynamic search = param.Search.PredicateObject; if (search.Keyword != null) { string keyword = search.Keyword; keyword = keyword.Trim().ToLower(); query = query.Where(x => x.Property1.Contains(keyword) || x.Property2.ToLower().Contains(keyword) || (x.RelatedEntity != null && x.RelatedEntity.Property.ToLower().Contains(keyword))); } // CAc filter khAc (enum, date range, FK filter...) if (search.Status != null) { MyStatus status = search.Status; query = query.Where(x => x.Status == status); } === .cursor\rules\service-search-patterns.md === # Service Search Patterns ## Search Method Pattern Tt c service Search methods phi tuAn th pattern sau: ### 1. Query Building ```csharp public async Task> Search(SmartTableParam param) { IQueryable query = _repository.Query() .Include(x => x.RelatedEntity1) .Include(x => x.RelatedEntity2) .Where(x => !x.IsDeleted); // Nu cA3 soft delete // L?c theo t khA3a tAm kim if (param.Search.PredicateObject != null) { dynamic search = param.Search.PredicateObject; if (search.Keyword != null) { string keyword = search.Keyword; keyword = keyword.Trim().ToLower(); query = query.Where(x => x.Property1.Contains(keyword) || x.Property2.ToLower().Contains(keyword) || (x.RelatedEntity != null && x.RelatedEntity.Property.ToLower().Contains(keyword))); } // CAc filter khAc... if (search.FilterProperty != null) { query = query.Where(x => x.FilterProperty == search.FilterProperty); } } } ``` ### 2. Sorting Pattern === Lada.Framework\Docs\OrderFeeCalculationService_Usage_Guide.md === # OrderFeeCalculationService - H>ng dn s- dng ## Tng quan `OrderFeeCalculationService` lA service t-p trung ` x- lA tA-nh toAn c>c cho `n hAng, bao g"m logic VAT vA phAn b c>c theo loi thanh toAn. ## TA-nh nng chA-nh ### 1. TA-nh toAn c>c v-n chuyn c bn - TA-nh c>c da trAn khAch hAng, tuyn `?ng vA tr?ng lng - TA-ch hp v>i `FeeService` hin ti ### 2. TA-nh toAn VAT - **PhA- VAT `c tA-nh t tng c>c `A bao g"m VAT 8%** - Tng c>c sau VAT = C>c c bn + PhA- COD + Ph phA- - Gim giA (`A bao g"m VAT) - PhA- VAT = Tng c>c sau VAT \* 0.08 / 1.08 - Tng c>c tr>c VAT = Tng c>c sau VAT - PhA- VAT ### 3. PhAn b c>c theo loi thanh toAn - **SenderPay**: Ng?i g-i tr toAn bT - **ConsigneePay**: Ng?i nh-n tr toAn bT - **BankTransfer**: Chuyn khon cho k toAn - **SplitPay**: Chia c>c 2 bAn - **COD**: Cn tr t ti?n thu hT ## CAi `t ### 1. ?ng kA service trong DI Container ```csharp // Trong Startup.cs hoc DependencyRegister.cs services.AddOrderFeeCalculationService(); // Hoc `ng kA th cA'ng services.AddTransient(); services.AddTransient(); ``` === Lada.Framework\Examples\ImageServiceUsage.cs === using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO.Models.Media; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Services; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace Lada.Framework.Examples { /// /// VA- d s- dng ImageService /// public class ImageServiceUsage { private readonly IImageService _imageService; public ImageServiceUsage(IImageService imageService) { _imageService = imageService; } /// /// VA- d 1: X- lA nh `n gin (ch% tr v? URL) /// public async Task SimpleImageProcessing(IFormFile imageFile) { // X- lA nh avatar var result = await _imageService.ProcessImageAsync(imageFile, ImageType.Avatar); if (result.Result == Lada.Framework.DTO.Result.Success) { return result.Url; // Tr v? URL ` hin th< } throw new Exception(result.Message); } === Lada.Framework\Hangfires\HangfireBasicAuthMiddleware.cs === using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using System.Net; using System.Net.Http.Headers; using System.Text; namespace Lada.Framework.Hangfires { public class HangfireBasicAuthMiddleware { private readonly RequestDelegate next; private readonly IConfiguration _config; public HangfireBasicAuthMiddleware(RequestDelegate next, IConfiguration configuration) { this.next = next; _config = configuration; } public async Task InvokeAsync(HttpContext context) { if (context.Request.Path.StartsWithSegments("/hangfire")) { string authHeader = context.Request.Headers["Authorization"]; if (authHeader != null && authHeader.StartsWith("Basic ")) { // Get the credentials from request header var header = AuthenticationHeaderValue.Parse(authHeader); var inBytes = Convert.FromBase64String(header.Parameter); var credentials = Encoding.UTF8.GetString(inBytes).Split(':'); var username = credentials[0]; var password = credentials[1]; var validUserName = _config.GetSection("Hangfire:UserName").Value; var validPassword = _config.GetSection("Hangfire:Password").Value; // validate credentials if (username.Equals(validUserName) && password.Equals(validPassword)) { await next.Invoke(context).ConfigureAwait(false); return; } } === Lada.Framework\Hangfires\HangfireOAuthMiddleware.cs === using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; namespace Lada.Framework.Hangfires { public class HangfireOAuthMiddleware { private readonly RequestDelegate next; public HangfireOAuthMiddleware(RequestDelegate next) { this.next = next; } public async Task InvokeAsync(HttpContext context) { if (IsSwaggerUI(context.Request.Path)) { // if user is not authenticated if (!context.User.Identity.IsAuthenticated) { await context.ChallengeAsync(); return; } } await next.Invoke(context); } public bool IsSwaggerUI(PathString pathString) { return pathString.StartsWithSegments("/hangfire"); } } } === Lada.Framework\Infrastructures\AppSettings\AutConfig.cs === namespace Lada.Framework.Infrastructures.AppSettings { public class AutConfig { public string Authority { get; set; } public string ClientId { get; set; } public string ClientSecret { get; set; } } } === Lada.Framework\Infrastructures\AppSettings\MediaProcessingSettings.cs === using Lada.Framework.Data.Enums; namespace Lada.Framework.Infrastructures.AppSettings { /// /// Cu hAnh x- lA media (nh vA video) /// public class MediaProcessingSettings { /// /// ??ng dn g`c lu tr_ media /// public string RootPath { get; set; } = "C:\\uploads\\"; /// /// Domain ` to URL hin th< /// public string Domain { get; set; } = "https://localhost:5001/"; /// /// Th mc con chca file `A t`i u /// public string OutputFolder { get; set; } = "optimized"; /// /// Th mc tm ` x- lA /// public string TempPath { get; set; } = "C:\\temp\\"; #region Image Settings /// /// Chi?u rTng t`i `a ca nh (pixel) /// public int MaxImageWidth { get; set; } = 1200; /// /// Cht lng nh (1-100) /// public int ImageQuality { get; set; } = 80; === Lada.Framework\Infrastructures\AppSettings\MediaSettings.cs === namespace Lada.Framework.Infrastructures.AppSettings { public class MediaSettings { public string Drive { get; set; } public string RootPath { get; set; } //Resize settings public string OutputFolder { get; set; } public int MaxWidth { get; set; } public string ImageDomain { get; set; } /// /// 1: JPG /// 2: WEBP /// 3. AVIF /// public int ImageFormat { get; set; } } } === Lada.Framework\Infrastructures\Services\BaseLocationService.cs === using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Lada.Framework.Infrastructures.Services { public class BaseLocationService { } } === Lada.Framework\Infrastructures\Services\CvUploadService.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.Enums; using Lada.Framework.DTO.Results; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using System.Diagnostics; namespace Lada.Framework.Infrastructures.Services { /// /// Giao di?n cho d?ch v? upload CV /// public interface ICvUploadService { /// /// Upload file CV /// /// File CV /// ID ?ng vin (ty ch?n) /// Lo?i ti li?u /// K?t qu? upload Task UploadCvAsync(IFormFile file, int? candidateId = null, DocumentType documentType = DocumentType.CV); /// /// Xa file CV /// /// Du?ng d?n file /// K?t qu? xa Task DeleteCvAsync(string filePath); /// /// L?y URL t? du?ng d?n h? th?ng /// /// Du?ng d?n file /// URL truy c?p string GetUrlFromPath(string filePath); } === Lada.Framework\Infrastructures\Services\DocumentService.cs === using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Models.Media; using Lada.Framework.DTO.Results.Media; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; namespace Lada.Framework.Infrastructures.Services { public interface IDocumentService { /// /// X- lA vA lu tAi liu, tr v? URL /// /// File tAi liu cn x- lA /// Loi tAi liu (` t chcc th mc) /// ? /// Kt qu x- lA tAi liu v>i URL Task ProcessDocumentAsync(IFormFile file, DocumentType documentType, DocumentFormat documentFormat); /// /// X- lA vA lu tAi liu v>i metadata vAo database (optional) /// /// File tAi liu cn x- lA /// TA1y ch?n lu tAi liu vA metadata /// Kt qu x- lA tAi liu v>i metadata Task ProcessAndSaveAsync(IFormFile file, DocumentSaveOptions options); /// /// Validate tAi liu bng header validation /// /// File cn validate /// ? /// True nu lA tAi liu hp l Task ValidateDocumentAsync(IFormFile file, DocumentFormat expectedFormat); /// === Lada.Framework\Infrastructures\Services\ExcelFileService.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.Results; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Helpers; using Microsoft.Extensions.Options; using OfficeOpenXml; namespace Lada.Framework.Infrastructures.Services { /// /// Giao din cho d public interface IExcelFileService { /// /// Lu file Excel vAo h th`ng /// /// Excel package cn lu /// TAn file (khA'ng bao g"m extension) /// Loi th mc (vA- d: "reconciliations", "transfer-payment-bills") /// Th mc con (tA1y ch?n) /// Kt qu lu file Task SaveExcelFileAsync(ExcelPackage excelPackage, string fileName, string folderType, string? subFolder = null); /// /// Lu file Excel t byte array /// /// D_ liu file Excel /// TAn file (khA'ng bao g"m extension) /// Loi th mc /// Th mc con (tA1y ch?n) /// Kt qu lu file Task SaveExcelFileAsync(byte[] fileBytes, string fileName, string folderType, string? subFolder = null); /// /// XA3a file Excel /// /// ??ng dn file /// Kt qu xA3a Task DeleteExcelFileAsync(string filePath); === Lada.Framework\Infrastructures\Services\FeeService.cs === using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance.Quotations; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO.Models; using Lada.Framework.DTO.Results; using Microsoft.EntityFrameworkCore; namespace Lada.Framework.Infrastructures.Services { public interface IFeeService { /// /// L?y gi theo phu?ng /// /// /// Task GetFeeByWard(FeeByWardModel model,string apiKey); /// /// L?y gi theo kho?ng cch /// /// /// Task GetFee(FeeModel model); } public class FeeService : IFeeService { private readonly IRepository _priceRepository; private readonly IRepository _routeRepository; private readonly IRepository _customerRepository; private readonly IRepository _locationRepository; private readonly IRepository _endPointsRepository; private readonly IGoogleMapService _googleMapService; public FeeService(IRepository priceRepository, IRepository routeRepository, IRepository customerRepository, IRepository locationRepository, === Lada.Framework\Infrastructures\Services\GoogleMapService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.GoogleMap.PlaceAutocomplete; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Items.GoogleMap.PlaceAutocomplete; using Lada.Framework.DTO.Results.GoogleMap; using Lada.Framework.DTO.Results.GoogleMap.PlaceAutocomplete; using Lada.Framework.Infrastructures.Helpers; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Globalization; using System.Security.Cryptography.X509Certificates; namespace Lada.Framework.Infrastructures.Services { public interface IGoogleMapService { /// /// L?y ra cc phu?ng/xa chua c latlong d? c?p nh?t /// /// Task UpdateWardLatLong(string apiKey); /// /// C?p nh?t kho?ng cch v van b?n kho?ng cch c?a EndPoints. /// /// Task UpdateEndPointsDistance(string apiKey); Task UpdateEndPointsDistance(int endPointsId, string apiKey); Task UpdateEndPointsDistance(int startLocation, int endLocation, string apiKey); #region PlaceAutocomplete Task PlaceAutocomplete(string keyword, string apiKey, string options = ""); === Lada.Framework\Infrastructures\Services\IAppConfigService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Repositories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; namespace Lada.Framework.Infrastructures.Services { /// /// Interface cho service qun lA cu hAnh cng dng /// public interface IAppConfigService { /// /// Ly giA tr< cu hAnh theo key /// /// Key cu hAnh /// GiA tr< cu hAnh Task GetConfigValueAsync(string key); /// /// Ly giA tr< cu hAnh theo key v>i giA tr< mc ` /// Key cu hAnh /// GiA tr< mc ` /// GiA tr< cu hAnh hoc giA tr< mc ` Task GetConfigValueAsync(string key, string defaultValue); /// /// Load tt c configs vAo cache /// /// Task LoadConfigsToCacheAsync(); /// /// C-p nh-t giA tr< cu hAnh /// /// Key cu hAnh /// GiA tr< m>i /// True nu c-p nh-t thAnh cA'ng Task SetConfigValueAsync(string key, string value); === Lada.Framework\Infrastructures\Services\ImageService.cs === using ImageMagick; using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using Lada.Framework.DTO.Results.Media; using Lada.Framework.DTO.Models.Media; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Data.Repositories; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Lada.Framework.Infrastructures.Helpers; namespace Lada.Framework.Infrastructures.Services { public interface IImageService { /// /// X- lA vA lu nh v>i t`i u hA3a, tr v? URL /// /// File nh cn x- lA /// Loi nh (` t chcc th mc) /// Kt qu x- lA nh v>i URL Task ProcessImageAsync(IFormFile file, ImageType imageType); /// /// X- lA vA lu nh v>i metadata vAo database (optional) /// /// File nh cn x- lA /// TA1y ch?n lu nh vA metadata /// Kt qu x- lA nh v>i metadata Task ProcessAndSaveAsync(IFormFile file, ImageSaveOptions options); /// /// X- lA nhi?u nh cA1ng lAc /// /// Danh sAch file nh /// Loi nh /// Danh sAch kt qu x- lA Task> ProcessMultipleAsync(List files, ImageType imageType); /// === Lada.Framework\Infrastructures\Services\OrderFeeCalculationHelper.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Extensions; using static Lada.Framework.Data.Enums.OrderFinEnum; namespace Lada.Framework.Infrastructures.Services { /// /// Helper class ` tA-ch hp OrderFeeCalculationService vAo cAc service hin ti /// public class OrderFeeCalculationHelper { private readonly IOrderFeeCalculationService _feeCalculationService; public OrderFeeCalculationHelper(IOrderFeeCalculationService feeCalculationService) { _feeCalculationService = feeCalculationService; } /// /// TA-nh toAn vA c-p nh-t c>c cho `n hAng m>i /// /// OrderFin entity /// ID khAch hAng /// ID ph?ng/xA ngu"n /// ID ph?ng/xA `A-ch /// Tr?ng lng (gram) /// API key /// Kt qu tA-nh toAn public async Task CalculateAndUpdateOrderFeeAsync( OrderFin orderFin, int customerId, int sourceWardId, int destWardId, decimal weight, string apiKey = "") { var request = orderFin.ToCalculationRequest(customerId, sourceWardId, destWardId, weight, apiKey); var result = await _feeCalculationService.CalculateOrderFeeAsync(request); === Lada.Framework\Infrastructures\Services\OrderFeeCalculationService.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.Models; using Lada.Framework.DTO.Results; using static Lada.Framework.Data.Enums.OrderFinEnum; namespace Lada.Framework.Infrastructures.Services { /// /// Interface cho service tA-nh toAn c>c `n hAng /// public interface IOrderFeeCalculationService { /// /// TA-nh toAn c>c v-n chuyn c bn /// /// ID khAch hAng /// ID ph?ng/xA ngu"n /// ID ph?ng/xA `A-ch /// Tr?ng lng (gram) /// API key cho Google Maps /// Kt qu tA-nh c>c Task CalculateBaseFeeAsync(int customerId, int sourceWardId, int destWardId, decimal weight, string apiKey); /// /// TA-nh toAn tng c>c `n hAng bao g"m cAc phA- ph /// /// ThA'ng tin yAu cu tA-nh c>c /// Kt qu tA-nh c>c chi tit Task CalculateOrderFeeAsync(OrderFeeCalculationRequest request); /// /// TA-nh toAn phA- VAT t tng c>c `A bao g"m VAT (8%) /// /// Tng c>c `A bao g"m VAT /// PhA- VAT decimal CalculateVatFee(decimal totalFeeAfterVat); /// /// PhAn b c>c theo loi thanh toAn /// === Lada.Framework\Infrastructures\Services\PictureService.cs === using ImageMagick; using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using Lada.Framework.DTO.Results.Media; using Lada.Framework.Infrastructures.AppSettings; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; namespace Lada.Framework.Infrastructures.Services { public interface IPictureService { Task Upload(IFormFile file,PictureType pictureType); } public class PictureService : IPictureService { private MediaSettings _mediaSettings; public PictureService(IOptions mediaSettings) { _mediaSettings = mediaSettings.Value; } public async Task Upload(IFormFile file, PictureType pictureType) { var result = new UploadPictureResult(); #region Luu file g?c var originalFolderName = OriginalFolderPath(pictureType); var originalFileExt = Path.GetExtension(file.FileName).ToLower(); var originalFileName = OriginalFileName(file); var savedOriginalFilePath = await SaveToDisk(file, originalFileName, originalFolderName); #endregion var validFile = ValidatePicture(savedOriginalFilePath); if (string.IsNullOrEmpty(validFile)) === Lada.Framework\Infrastructures\Services\UnifiedMediaService.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.Models.Media; using Lada.Framework.DTO.Results.Media; using Microsoft.AspNetCore.Http; namespace Lada.Framework.Infrastructures.Services { /// /// Unified Media Service - Thay th cho PictureService vA MediaService /// Kt hp tt c u `im ca c hai service cc /// public interface IUnifiedMediaService { #region Image Processing /// /// X- lA nh `n gin (thay th PictureService.UploadPicture) /// /// File nh /// Loi nh /// Kt qu v>i URL Task ProcessImageAsync(IFormFile file, ImageType imageType); /// /// X- lA nh v>i lu database (thay th MediaService image functions) /// /// File nh /// TA1y ch?n lu /// Kt qu v>i metadata Task ProcessImageWithDatabaseAsync(IFormFile file, ImageSaveOptions options); /// /// X- lA nhi?u nh cA1ng lAc /// /// Danh sAch file nh /// Loi nh /// Danh sAch kt qu Task> ProcessMultipleImagesAsync(List files, ImageType imageType); #endregion === Lada.Framework\Infrastructures\Services\VideoService.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.Models.Media; using Lada.Framework.DTO.Results.Media; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Data.Repositories; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using System.Diagnostics; namespace Lada.Framework.Infrastructures.Services { public interface IVideoService { /// /// X- lA vA lu video v>i t`i u hA3a, tr v? URL /// /// File video cn x- lA /// Loi video (` t chcc th mc) /// Kt qu x- lA video v>i URL Task ProcessVideoAsync(IFormFile file, VideoType videoType); /// /// X- lA vA lu video v>i metadata vAo database (optional) /// /// File video cn x- lA /// TA1y ch?n lu video vA metadata /// Kt qu x- lA video v>i metadata Task ProcessAndSaveAsync(IFormFile file, VideoSaveOptions options); /// /// X- lA nhi?u video cA1ng lAc /// /// Danh sAch file video /// Loi video /// Danh sAch kt qu x- lA Task> ProcessMultipleAsync(List files, VideoType videoType); /// /// Chuyn `i SystemPath thAnh URL hin th< /// === Lada.Framework\Swaggers\SwaggerBasicAuthMiddleware.cs === using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using System.Net; using System.Net.Http.Headers; using System.Text; namespace Lada.Framework.Swaggers { public class SwaggerBasicAuthMiddleware { private readonly RequestDelegate next; private readonly IConfiguration _config; public SwaggerBasicAuthMiddleware(RequestDelegate next, IConfiguration configuration) { this.next = next; _config = configuration; } public async Task InvokeAsync(HttpContext context) { if (context.Request.Path.StartsWithSegments("/swagger")) { string authHeader = context.Request.Headers["Authorization"]; if (authHeader != null && authHeader.StartsWith("Basic ")) { // Get the credentials from request header var header = AuthenticationHeaderValue.Parse(authHeader); var inBytes = Convert.FromBase64String(header.Parameter); var credentials = Encoding.UTF8.GetString(inBytes).Split(':'); var username = credentials[0]; var password = credentials[1]; var validUserName = _config.GetSection("SwaggerAuth:UserName").Value; var validPassword = _config.GetSection("SwaggerAuth:Password").Value; // validate credentials if (username.Equals(validUserName) && password.Equals(validPassword)) { await next.Invoke(context).ConfigureAwait(false); return; } } === Lada.Framework\Swaggers\SwaggerOAuthMiddleware.cs === using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; namespace Lada.Framework.Swaggers { public class SwaggerOAuthMiddleware { private readonly RequestDelegate next; public SwaggerOAuthMiddleware(RequestDelegate next) { this.next = next; } public async Task InvokeAsync(HttpContext context) { if (IsSwaggerUI(context.Request.Path)) { // if user is not authenticated if (!context.User.Identity.IsAuthenticated) { await context.ChallengeAsync(); return; } } await next.Invoke(context); } public bool IsSwaggerUI(PathString pathString) { return pathString.StartsWithSegments("/swagger"); } } } === Lada.Framework\Tests\OrderFeeCalculationServiceTests.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.Models; using Lada.Framework.DTO.Results; using Lada.Framework.Infrastructures.Services; using static Lada.Framework.Data.Enums.OrderFinEnum; namespace Lada.Framework.Tests { /// /// Test examples cho OrderFeeCalculationService /// Lu A: ?Ay lA example code, cn thAm test framework thc t (xUnit, NUnit, MSTest) ` chy /// public class OrderFeeCalculationServiceExamples { /// /// Mock implementation ca IFeeService cho testing /// private class MockFeeService : IFeeService { public Task GetFeeByWard(FeeByWardModel model, string apiKey) { return Task.FromResult(new FeeResult { Result = Result.Success, Fee = 50000, RouteName = "Test Route" }); } public Task GetFee(FeeModel model) { return Task.FromResult(new FeeResult { Result = Result.Success, Fee = 50000, RouteName = "Test Route" }); } } === Ladaer.BackEnd\appsettings.Development.json === { "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } } } === Ladaer.BackEnd\Program.cs === using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Startup; using OfficeOpenXml; var builder = WebApplication.CreateBuilder(args); builder.Logging.ClearProviders(); builder.Logging.AddConsole(); // Add services to the container. //builder.Services.AddControllers(); //// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle //builder.Services.AddEndpointsApiExplorer(); //builder.Services.AddSwaggerGen(); builder.Services.RegisterGeneralServices(builder.Configuration); builder.Services.RegisterSwaggerServices(); builder.Services.RegisterSecurityServices(builder.Configuration); builder.Services.RegisterDependency(builder.Configuration); //builder.Services.AddScoped(); builder.Services.AddHttpClient(); //builder.Services.AddScoped(); builder.Services.AddHostedService(); builder.Services.AddHttpContextAccessor(); var app = builder.Build(); // L?y IAppConfigService t? DI container //var appConfigService = app.Services.GetRequiredService(); app.ConfigAndRunApp(); === Ladaer.BackEnd\Controllers\Cms\CategoryController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Cms { /// /// Controller d? x? l cc ho?t d?ng lin quan d?n danh m?c. /// [Route("api/[controller]")] [ApiController] [Authorize] public class CategoryController : ControllerBase { private readonly ICategoryService _categoryService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public CategoryController(ICategoryService categoryService) { _categoryService = categoryService; } #region Search /// /// TAm kim cAc danh mc da trAn cAc tham s` `c cung cp. /// /// CAc tham s` tAm kim. /// Kt qu tAm kim. [HttpPost("Search")] [Authorize(Roles = "Category.Search")] public async Task Search([FromBody] SmartTableParam param) { === Ladaer.BackEnd\Controllers\Cms\PostController.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Cms { /// /// Controller d? x? ly cc ho?t d?ng lin quan d?n bi vi?t. /// [Route("api/[controller]")] [ApiController] [Authorize] public class PostController : ControllerBase { private readonly IPostService _postService; /// /// Kh?i t?o m?t instance m?i c?a l?p . /// /// D?ch v? x? ly bi vi?t. public PostController(IPostService postService) { _postService = postService; } /// /// Tm ki?m cc bi vi?t d?a trn cc tham s? du?c cung c?p. /// /// Cc tham s? tm ki?m. /// K?t qu? tm ki?m. [HttpPost("Search")] [Authorize(Roles = "Post.Search")] public async Task Search([FromBody] SmartTableParam param) { var categories = await _postService.Search(param); === Ladaer.BackEnd\Controllers\Cms\ProductController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Cms { [Route("api/[controller]")] [ApiController] [Authorize] public class ProductController : ControllerBase { private readonly IProductService _productService; /// /// Kh?i t?o m?t instance m?i c?a l?p . /// /// D?ch v? x? ly bi vi?t. public ProductController(IProductService productService) { _productService = productService; } /// /// Tm ki?m cc bi vi?t d?a trn cc tham s? du?c cung c?p. /// /// Cc tham s? tm ki?m. /// K?t qu? tm ki?m. [HttpPost("Search")] [Authorize(Roles = "Product.Search")] public async Task Search([FromBody] SmartTableParam param) { var products = await _productService.Search(param); return Ok(products); } /// === Ladaer.BackEnd\Controllers\Cms\ScriptConfigController.cs === using Ladaer.BackEnd.Infrastructures.Services.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Lada.Framework.DTO.SmartTable; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using Lada.Framework.Infrastructures.Helpers; using Microsoft.AspNetCore.Authorization; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; namespace Ladaer.BackEnd.Controllers.Cms { [ApiController] [Route("api/[controller]")] [Authorize] public class ScriptConfigController : ControllerBase { private readonly IScriptConfigService _service; public ScriptConfigController(IScriptConfigService service) { _service = service; } /// /// TAm kim cu hAnh script /// [HttpPost("Search")] [Authorize(Roles = "ScriptConfig.Search")] public async Task Search([FromBody] SmartTableParam param) { var result = await _service.Search(param); return Ok(result); } /// /// Ly thA'ng tin cu hAnh script theo Id /// [HttpGet("GetById")] [Authorize(Roles = "ScriptConfig.GetById")] public async Task GetById(int id) === Ladaer.BackEnd\Controllers\Cms\TagController.cs === using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Cms { [Route("api/[controller]")] [ApiController] [Authorize] public class TagController : ControllerBase { private readonly ITagService _tagService; public TagController(ITagService tagService) { _tagService = tagService; } /// /// T? d?ng hon thnh t? kha tm ki?m th? /// /// T? kha tm ki?m /// Danh sch cc th? g?i y [HttpGet("Autocomplete")] [Authorize(Roles = "Tag.Autocomplete")] public async Task Autocomplete(string? keyword) { var suggests = await _tagService.TagAutocomplete(keyword); return Ok(suggests); } /// /// Tm ki?m cc th? d?a trn tham s? SmartTableParam /// /// Tham s? tm ki?m /// Danh sch cc th? ph h?p [HttpPost("Search")] [Authorize(Roles = "Tag.Search")] public async Task Search([FromBody] SmartTableParam param) === Ladaer.BackEnd\Controllers\Cms\TopicController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Cms { [Route("api/[controller]")] [ApiController] [Authorize] public class TopicController : ControllerBase { private readonly ITopicService _topicService; public TopicController(ITopicService topicService) { _topicService = topicService; } /// /// Tm ki?m cc bi vi?t d?a trn cc tham s? du?c cung c?p. /// /// Cc tham s? tm ki?m. /// K?t qu? tm ki?m. [HttpPost("Search")] [Authorize(Roles = "Topic.Search")] public async Task Search([FromBody] SmartTableParam param) { var topics = await _topicService.Search(param); return Ok(topics); } /// /// L?y thng tin chi ti?t c?a d?ch v? d?a trn ID. /// /// ID c?a d?ch v?. /// Thng tin chi ti?t c?a d?ch v?. === Ladaer.BackEnd\Controllers\Cms\UrlRecordController.cs === using Ladaer.BackEnd.Infrastructures.Services.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Cms { [Route("api/[controller]")] [ApiController] [Authorize] public class UrlRecordController : ControllerBase { private readonly IUrlRecordService _urlRecordService; public UrlRecordController(IUrlRecordService urlRecordService) { _urlRecordService = urlRecordService; } [HttpGet("GetById")] [Authorize(Roles = "UrlRecord.GetById")] public async Task GetById(int id) { var result = await _urlRecordService.GetById(id); return Ok(result); } [HttpPost("search")] [Authorize(Roles = "UrlRecord.Search")] public async Task Search([FromBody] Lada.Framework.DTO.SmartTable.SmartTableParam param) { var result = await _urlRecordService.Search(param); return Ok(result); } /// /// C?p nh?t thng tin co b?n c?a UrlRecord === Ladaer.BackEnd\Controllers\Crm\CallLogController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Crm { /// /// CallLog Controller - Qun lA cuTc g?i tng `Ai /// [Route("api/[controller]")] [ApiController] [Authorize] public class CallLogController : ControllerBase { private readonly ICallLogService _callLogService; public CallLogController(ICallLogService callLogService) { _callLogService = callLogService; } /// /// TAm kim call log /// /// CAc tham s` tAm kim /// Kt qu tAm kim [HttpPost("Search")] [Authorize(Roles = "CallLog.Search")] public async Task Search([FromBody] SmartTableParam param) { var callLogs = await _callLogService.Search(param); return Ok(callLogs); } /// /// Ly thA'ng tin chi tit call log theo ID === Ladaer.BackEnd\Controllers\Crm\CustomerAddressController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Crm { /// /// Controller d? x? ly cc ho?t d?ng lin quan d?n d?a ch? khch hng. /// [Route("api/[controller]")] [ApiController] [Authorize] public class CustomerAddressController : ControllerBase { private readonly ICustomerAddressService _customerAddressService; /// /// Kh?i t?o m?t instance m?i c?a l?p . /// /// D?ch v? x? ly d?a ch? khch hng. public CustomerAddressController(ICustomerAddressService customerAddressService) { _customerAddressService = customerAddressService; } /// /// Tm ki?m cc d?a ch? khch hng d?a trn cc tham s? du?c cung c?p. /// /// Cc tham s? tm ki?m. /// K?t qu? tm ki?m. [HttpPost("Search")] [Authorize(Roles = "CustomerAddress.Search")] public async Task Search([FromBody] SmartTableParam param) { if (param.Search.PredicateObject != null) { === Ladaer.BackEnd\Controllers\Crm\CustomerBankAccountController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Crm { /// /// Controller qun lA tAi khon ngAn hAng khAch hAng /// [ApiController] [Route("api/[controller]")] [Authorize] public class CustomerBankAccountController : ControllerBase { private readonly ICustomerBankAccountService _customerBankAccountService; /// /// KhYi to controller /// /// Service qun lA tAi khon ngAn hAng public CustomerBankAccountController(ICustomerBankAccountService customerBankAccountService) { _customerBankAccountService = customerBankAccountService; } /// /// Ly danh sAch tAi khon ngAn hAng ca khAch hAng /// /// ID khAch hAng /// Danh sAch tAi khon ngAn hAng [HttpGet("GetByCustomerId/{customerId}")] [Authorize(Roles = "CustomerBankAccount.View")] public async Task GetByCustomerId(int customerId) { if (customerId <= 0) { return BadRequest("ID khAch hAng khA'ng hp l"); === Ladaer.BackEnd\Controllers\Crm\CustomerController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Crm { /// /// Controller d [Route("api/[controller]")] [ApiController] [Authorize] public class CustomerController : ControllerBase { private readonly ICustomerService _customerService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public CustomerController(ICustomerService customerService) { _customerService = customerService; } #region SEARCH / AUTOCOMPLETE /// /// TAm kim cAc khAch hAng da trAn cAc tham s` `c cung cp. /// /// CAc tham s` tAm kim. /// Kt qu tAm kim. [HttpPost("Search")] [Authorize(Roles = "Customer.Search")] public async Task Search([FromBody] SmartTableParam param) { === Ladaer.BackEnd\Controllers\Crm\LeadController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Crm { [Route("api/[controller]")] [ApiController] [Authorize] public class LeadController : ControllerBase { private readonly ILeadService _leadService; public LeadController(ILeadService leadService) { _leadService = leadService; } /// /// Tm ki?m lead /// /// Cc tham s? tm ki?m. /// K?t qu? tm ki?m. [HttpPost("Search")] [Authorize(Roles = "Lead.Search")] public async Task Search([FromBody] SmartTableParam param) { var agencies = await _leadService.Search(param); return Ok(agencies); } /// /// T?o ho?c c?p nh?t lead /// === Ladaer.BackEnd\Controllers\Crm\VatInfoController.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Results.Crm; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; namespace Ladaer.BackEnd.Controllers.Crm { /// /// Controller qun lA thA'ng tin xut hA3a `n VAT ca khAch hAng /// [ApiController] [Route("api/[controller]")] [Authorize] public class VatInfoController : ControllerBase { private readonly IVatInfoService _vatInfoService; public VatInfoController(IVatInfoService vatInfoService) { _vatInfoService = vatInfoService; } /// /// Ly danh sAch thA'ng tin xut hA3a `n VAT /// /// Model tAm kim /// Danh sAch thA'ng tin xut hA3a `n VAT [HttpPost("Search")] [Authorize(Roles = "VatInfo.Search")] public async Task Search([FromBody] SmartTableParam param) { var result = await _vatInfoService.Search(param); return Ok(result); } === Ladaer.BackEnd\Controllers\DriverApp\DriverDashboardController.cs === using System.Threading.Tasks; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.Services.DriverApp; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.DriverApp { [Route("api/[controller]")] [ApiController] [Authorize] public class DriverDashboardController : ControllerBase { private readonly IDriverAppService _driverAppService; public DriverDashboardController(IDriverAppService driverAppService) { _driverAppService = driverAppService; } /// /// Ly thA'ng tin dashboard cho cng dng tAi x /// [HttpGet("GetDashboard")] [Authorize(Roles = "DriverApp.GetDashboard")] public async Task GetDashboard() { var currentUser = User.GetCurrentUser(); if (currentUser == null) { return BadRequest("KhA'ng cA3 ng?i dA1ng"); } if (currentUser.UserId <= 0) { return BadRequest("KhA'ng xAc ` /// Ly thA'ng tin tAi chA-nh ca lAi xe /// [HttpGet("GetFinancialInfo")] [Authorize(Roles = "DriverApp.GetFinancialInfo")] public async Task GetFinancialInfo() { var currentUser = User.GetCurrentUser(); if (currentUser == null) { return BadRequest("KhA'ng cA3 ng?i dA1ng"); } if (currentUser.UserId <= 0) { return BadRequest("KhA'ng xAc ` /// TAm kim danh sAch `n hAng ca lAi xe cA3 phAn trang /// [HttpPost("SearchOrders")] [Authorize(Roles = "DriverApp.SearchOrders")] public async Task SearchOrders([FromBody] SmartTableParam param) { var currentUser = User.GetCurrentUser(); if (currentUser == null) { return BadRequest("KhA'ng cA3 ng?i dA1ng"); } if (currentUser.UserId <= 0) { return BadRequest("KhA'ng xAc ` /// C-p nh-t trng thAi ly hAng thAnh cA'ng /// [HttpPost("Pickup")] [Authorize(Roles = "DriverApp.Pickup")] public async Task Pickup([FromForm] DriverAppPickupModel model) { var currentUser = User.GetCurrentUser(); if (currentUser == null) { return BadRequest("KhA'ng cA3 ng?i dA1ng"); } if (currentUser.UserId <= 0) === Ladaer.BackEnd\Controllers\DriverApp\DriverProfileController.cs === using System.Threading.Tasks; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Accounts; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Models.Users; using Ladaer.BackEnd.Infrastructures.Services.Hr; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Report.OperationReports; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.DriverApp { [Route("api/[controller]")] [ApiController] [Authorize] public class DriverProfileController : ControllerBase { private readonly IUserService _userService; private readonly IAttendanceService _attendanceService; private readonly IDriverReportService _driverReportService; public DriverProfileController( IUserService userService, IAttendanceService attendanceService, IDriverReportService driverReportService) { _userService = userService; _attendanceService = attendanceService; _driverReportService = driverReportService; } /// /// ?ng nh-p dAnh cho tAi x /// [HttpPost("Login")] [AllowAnonymous] public async Task Login([FromBody] LoginModel model) { === Ladaer.BackEnd\Controllers\DriverApp\DriverTruckController.cs === using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Trucks; using Ladaer.BackEnd.Infrastructures.Services.FuelCards; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Trucks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.DriverApp { [Route("api/[controller]")] [ApiController] [Authorize] public class DriverTruckController : ControllerBase { private readonly ITruckService _truckService; private readonly ITruckActivityService _truckActivityService; private readonly IUserService _userService; private readonly IFuelRefillService _fuelRefillService; public DriverTruckController( ITruckService truckService, ITruckActivityService truckActivityService, IUserService userService, IFuelRefillService fuelRefillService) { _truckService = truckService; _truckActivityService = truckActivityService; _userService = userService; _fuelRefillService = fuelRefillService; } /// /// Ly danh sAch tt c xe ti thuTc chi nhAnh ca ng?i dA1ng hin ti /// /// Danh sAch tt c xe ti thuTc chi nhAnh [HttpGet("GetTrucksByAgency")] === Ladaer.BackEnd\Controllers\Finance\BankAccountController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA tAi khon ngAn hAng /// [ApiController] [Route("api/[controller]")] [Authorize] public class BankAccountController : ControllerBase { private readonly IBankAccountService _bankAccountService; public BankAccountController(IBankAccountService bankAccountService) { _bankAccountService = bankAccountService; } /// /// TAm kim tAi khon ngAn hAng /// /// Tham s` tAm kim /// Danh sAch tAi khon ngAn hAng [HttpPost("Search")] [Authorize(Roles = "BankAccount.Search")] public async Task Search([FromBody] SmartTableParam param) { try { var result = await _bankAccountService.Search(param); return Ok(result); } catch (Exception ex) { === Ladaer.BackEnd\Controllers\Finance\BankController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA thA'ng tin ngAn hAng /// [ApiController] [Route("api/[controller]")] [Authorize] public class BankController : ControllerBase { private readonly IBankService _bankService; private readonly BankSeedService _bankSeedService; private readonly ILogger _logger; public BankController( IBankService bankService, BankSeedService bankSeedService, ILogger logger) { _bankService = bankService; _bankSeedService = bankSeedService; _logger = logger; } /// /// TAm kim ngAn hAng v>i phAn trang /// [HttpPost("Search")] public async Task Search([FromBody] SmartTableParam param) { try { === Ladaer.BackEnd\Controllers\Finance\CashierController.cs === using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; namespace Ladaer.BackEnd.Controllers.Finance { [Route("api/[controller]")] [ApiController] [Authorize] public class CashierController : ControllerBase { private readonly ICashierService _cashierService; public CashierController(ICashierService cashierService) { _cashierService = cashierService; } [HttpPost("Search")] [Authorize(Roles = "Cashier.Search")] public async Task Search(SmartTableParam param) { var currentUser = User.GetCurrentUser(); if (currentUser == null) { return BadRequest("KhA'ng cA3 ng?i dA1ng"); } if (currentUser.UserId <= 0 || string.IsNullOrEmpty(currentUser.UserName)) { return BadRequest("KhA'ng xAc ` /// Ly danh sAch khAch hAng cn ``i soAt /// [HttpPost("GetCustomersOverview")] [Authorize(Roles = "CustomerReconciliationSlip.View,CustomerReconciliationSlip.Create,Founder")] public async Task> GetCustomersOverview([FromBody] SmartTableParam param) { === Ladaer.BackEnd\Controllers\Finance\ExpenseCategoryController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA danh mc chi phA- /// [Route("api/[controller]")] [ApiController] [Authorize] public class ExpenseCategoryController : ControllerBase { private readonly IExpenseCategoryService _expenseCategoryService; public ExpenseCategoryController(IExpenseCategoryService expenseCategoryService) { _expenseCategoryService = expenseCategoryService; } /// /// TAm kim danh mc chi phA- v>i phAn trang /// /// Tham s` tAm kim vA phAn trang /// Danh sAch danh mc chi phA- [HttpPost("Search")] [Authorize(Roles = "ExpenseCategory.Search")] public async Task Search([FromBody] SmartTableParam param) { try { var result = await _expenseCategoryService.Search(param); return Ok(result); } catch (Exception ex) { === Ladaer.BackEnd\Controllers\Finance\ExpenseController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA chi phA- /// [Route("api/[controller]")] [ApiController] [Authorize] public class ExpenseController : ControllerBase { private readonly IExpenseService _expenseService; public ExpenseController(IExpenseService expenseService) { _expenseService = expenseService; } /// /// TAm kim chi phA- v>i phAn trang /// /// Tham s` tAm kim vA phAn trang /// Danh sAch chi phA- [HttpPost("Search")] [Authorize(Roles = "Expense.Search")] public async Task Search([FromBody] SmartTableParam param) { try { var currentUser = User.GetCurrentUser(); if (currentUser == null || currentUser.UserId <= 0) { return BadRequest("KhA'ng xAc ` /// Controller cho vic xut Excel thA'ng tin `n hAng /// [ApiController] [Route("api/[controller]")] [Authorize] public class ExportOrderController : ControllerBase { private readonly IExportOrderService _exportOrderService; private readonly IUserService _userService; public ExportOrderController( IExportOrderService exportOrderService, IUserService userService) { _exportOrderService = exportOrderService; _userService = userService; } /// /// Xut Excel thA'ng tin `n hAng theo danh sAch OrderId hoc OrderCode /// /// ThA'ng tin `u vAo /// Kt qu xut file [HttpPost("export")] public async Task> ExportOrders([FromBody] ExportOrderModel model) { try { === Ladaer.BackEnd\Controllers\Finance\FinanceExcelExportController.cs === using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller tng hp cho vic xut Excel cAc phiu tAi chA-nh /// [ApiController] [Route("api/[controller]")] [Authorize] public class FinanceExcelExportController : ControllerBase { private readonly IReconciliationExcelService _reconciliationExcelService; private readonly ITransferPaymentBillExcelService _transferPaymentBillExcelService; public FinanceExcelExportController( IReconciliationExcelService reconciliationExcelService, ITransferPaymentBillExcelService transferPaymentBillExcelService) { _reconciliationExcelService = reconciliationExcelService; _transferPaymentBillExcelService = transferPaymentBillExcelService; } #region Reconciliation Excel Export /// /// Xut Excel danh sAch phiu ``i soAt /// /// Model xut Excel /// Kt qu xut file [HttpPost("Reconciliation/Export")] [Authorize(Roles = "Reconciliation.ExportExcel")] public async Task ExportReconciliations([FromBody] ReconciliationExcelExportModel model) { === Ladaer.BackEnd\Controllers\Finance\FuelCardController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Results.FuelCards; using Ladaer.BackEnd.Infrastructures.Services.FuelCards; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance; /// /// Controller qun lA th xng du (th tA-n dng), ` du vA thanh toAn ti?n du khoAn /// [Route("api/[controller]")] [ApiController] [Authorize] public class FuelCardController : ControllerBase { private readonly IFuelCardService _fuelCardService; private readonly IFuelCardTransactionService _fuelCardTransactionService; private readonly IFuelRefillService _fuelRefillService; private readonly IFuelRefillExcelService _fuelRefillExcelService; public FuelCardController( IFuelCardService fuelCardService, IFuelCardTransactionService fuelCardTransactionService, IFuelRefillService fuelRefillService, IFuelRefillExcelService fuelRefillExcelService) { _fuelCardService = fuelCardService; _fuelCardTransactionService = fuelCardTransactionService; _fuelRefillService = fuelRefillService; _fuelRefillExcelService = fuelRefillExcelService; } #region FuelCard Management /// /// TAm kim th xng du v>i phAn trang /// === Ladaer.BackEnd\Controllers\Finance\IncomeCategoryController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA danh mc doanh thu /// [Route("api/[controller]")] [ApiController] [Authorize] public class IncomeCategoryController : ControllerBase { private readonly IIncomeCategoryService _incomeCategoryService; public IncomeCategoryController(IIncomeCategoryService incomeCategoryService) { _incomeCategoryService = incomeCategoryService; } /// /// TAm kim danh mc doanh thu v>i phAn trang /// /// Tham s` tAm kim vA phAn trang /// Danh sAch danh mc doanh thu [HttpPost("Search")] [Authorize(Roles = "IncomeCategory.Search")] public async Task Search([FromBody] SmartTableParam param) { try { var result = await _incomeCategoryService.Search(param); return Ok(result); } catch (Exception ex) { === Ladaer.BackEnd\Controllers\Finance\IncomeController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA doanh thu /// [Route("api/[controller]")] [ApiController] [Authorize] public class IncomeController : ControllerBase { private readonly IIncomeService _incomeService; public IncomeController(IIncomeService incomeService) { _incomeService = incomeService; } /// /// TAm kim doanh thu v>i phAn trang /// /// Tham s` tAm kim vA phAn trang /// Danh sAch doanh thu [HttpPost("Search")] [Authorize(Roles = "Income.Search")] public async Task Search([FromBody] SmartTableParam param) { try { var currentUser = User.GetCurrentUser(); if (currentUser == null || currentUser.UserId <= 0) { return BadRequest("KhA'ng xAc ` /// Controller cho bAo cAo thu chi /// [Route("api/[controller]")] [ApiController] [Authorize] public class IncomeExpenseReportController : ControllerBase { private readonly IIncomeExpenseReportService _service; /// /// KhYi to mTt th hin ca . /// /// Service bAo cAo thu chi. public IncomeExpenseReportController(IIncomeExpenseReportService service) { _service = service; } /// /// Ly bAo cAo thu chi theo khong th?i gian /// /// ThA'ng tin khong th?i gian bAo cAo /// BAo cAo thu chi theo ngAy [HttpPost("GetReport")] [Authorize(Roles = "IncomeExpenseReport.View")] public async Task GetReport([FromBody] IncomeExpenseReportRequest request) { var currentUser = User.GetCurrentUser(); var result = await _service.GetIncomeExpenseReportAsync(request, currentUser.UserId); return Ok(result); === Ladaer.BackEnd\Controllers\Finance\MyBankAccountController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA tAi khon ngAn hAng cA nhAn ca ng?i dA1ng `ang `ng nh-p /// [Route("api/[controller]")] [ApiController] [Authorize] public class MyBankAccountController : ControllerBase { private readonly IUserBankAccountService _userBankAccountService; public MyBankAccountController(IUserBankAccountService userBankAccountService) { _userBankAccountService = userBankAccountService; } /// /// Ly danh sAch tAi khon ngAn hAng ca tA'i /// /// Danh sAch tAi khon ngAn hAng [HttpGet("GetAll")] public async Task GetAll() { try { var currentUser = User.GetCurrentUser(); if (currentUser == null || currentUser.UserId <= 0) { return BadRequest("KhA'ng xAc ` /// Controller d? x? ly cc ho?t d?ng lin quan d?n gi c?. /// [Route("api/[controller]")] [ApiController] [Authorize] public class PriceController : ControllerBase { private readonly IPriceService _priceService; private readonly IBackFeeService _backFeeService; private readonly IWebHostEnvironment _hostEnvironment; private readonly IHttpContextAccessor _httpContextAccessor; private readonly string _mapApiKey; /// /// Kh?i t?o m?t instance m?i c?a l?p . /// /// Ty ch?n c?u hnh ?ng d?ng. /// D?ch v? x? ly gi c?. /// D?ch v? x? ly ph tr? l?i. /// Mi tru?ng luu tr? web. /// Truy c?p ng? c?nh HTTP. public PriceController(IOptions options, IPriceService priceService, IBackFeeService backFeeService, IWebHostEnvironment hostEnvironment, IHttpContextAccessor httpContextAccessor) { _priceService = priceService; === Ladaer.BackEnd\Controllers\Finance\ReconciliationController.cs === using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Data.Domains.Finance; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA ``i soAt `n hAng /// [ApiController] [Route("api/[controller]")] [Authorize] public class ReconciliationController : ControllerBase { private readonly IReconciliationService _reconciliationService; /// /// KhYi to controller /// /// Service qun lA ``i soAt public ReconciliationController(IReconciliationService reconciliationService) { _reconciliationService = reconciliationService; } /// /// TAm kim khAch hAng cn ``i soAt v>i phAn trang /// /// Tham s` tAm kim /// Kt qu tAm kim khAch hAng cn ``i soAt [HttpPost("SearchCustomersForReconciliation")] [Authorize(Roles = "Reconciliation.View")] === Ladaer.BackEnd\Controllers\Finance\TaxInvoiceController.cs === using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { [Route("api/[controller]")] [ApiController] [Authorize] public class TaxInvoiceController : ControllerBase { private readonly ITaxInvoiceService _service; private readonly ICustomerReconciliationSlipService _reconciliationService; public TaxInvoiceController( ITaxInvoiceService service, ICustomerReconciliationSlipService reconciliationService) { _service = service; _reconciliationService = reconciliationService; } /// /// To hA3a `n thu m>i /// /// ThA'ng tin to hA3a `n (CustomerReconciliationSlipId, VatInfoId, Note) /// Kt qu to hA3a `n [HttpPost("Create")] [Authorize(Roles = "TaxInvoice.Create,Founder")] public async Task Create([FromBody] CreateTaxInvoiceModel model) { var currentUser = User.GetCurrentUser(); if (currentUser == null) { return Unauthorized(); === Ladaer.BackEnd\Controllers\Finance\TransactionController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { [ApiController] [Route("api/[controller]")] [Authorize] public class TransactionController : ControllerBase { private readonly ITransactionService _transactionService; public TransactionController(ITransactionService transactionService) { _transactionService = transactionService; } /// /// TAm kim giao di xem tt c, user khAc ch% xem vA- ca mAnh. /// /// Tham s` tAm kim /// Danh sAch giao di tng thu vA tng chi [HttpPost("SearchWalletTransactions")] [Authorize(Roles = "Transaction.SearchWalletTransactions")] public async Task SearchWalletTransactions([FromBody] SmartTableParam param) { var currentUser = User.GetCurrentUser(); if (currentUser == null) { return Unauthorized(); } var result = await _transactionService.SearchWalletTransactions(param, currentUser.UserId); return Ok(result); } === Ladaer.BackEnd\Controllers\Finance\TransferPaymentBillController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA hA3a `n thanh toAn chuyn khon /// [ApiController] [Route("api/[controller]")] [Authorize] public class TransferPaymentBillController : ControllerBase { private readonly ITransferPaymentBillService _transferPaymentBillService; private readonly ITransferPaymentBillExcelService _transferPaymentBillExcelService; public TransferPaymentBillController( ITransferPaymentBillService transferPaymentBillService, ITransferPaymentBillExcelService transferPaymentBillExcelService) { _transferPaymentBillService = transferPaymentBillService; _transferPaymentBillExcelService = transferPaymentBillExcelService; } #region Search Operations /// /// TAm kim khAch hAng cA3 `n hAng cn to hA3a `n thanh toAn chuyn khon /// /// Tham s` tAm kim /// Danh sAch khAch hAng [HttpPost("SearchCustomersForTransferPayment")] === Ladaer.BackEnd\Controllers\Finance\UserBankAccountController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA tAi khon ngAn hAng ng?i dA1ng /// [Route("api/[controller]")] [ApiController] [Authorize] public class UserBankAccountController : ControllerBase { private readonly IUserBankAccountService _userBankAccountService; public UserBankAccountController(IUserBankAccountService userBankAccountService) { _userBankAccountService = userBankAccountService; } /// /// TAm kim tAi khon ngAn hAng ng?i dA1ng v>i phAn trang /// /// Tham s` tAm kim vA phAn trang /// Danh sAch tAi khon ngAn hAng ng?i dA1ng [HttpPost("Search")] [Authorize(Roles = "UserBankAccount.Search")] public async Task Search([FromBody] SmartTableParam param) { try { var result = await _userBankAccountService.Search(param); return Ok(result); } catch (Exception ex) { === Ladaer.BackEnd\Controllers\Finance\VatInvoiceController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller qun lA hA3a `n VAT t Tng cc Thu /// [ApiController] [Route("api/[controller]")] [Authorize] public class VatInvoiceController : ControllerBase { private readonly IVatInvoiceService _vatInvoiceService; private readonly IVatInvoiceSyncService _vatInvoiceSyncService; public VatInvoiceController(IVatInvoiceService vatInvoiceService, IVatInvoiceSyncService vatInvoiceSyncService) { _vatInvoiceService = vatInvoiceService; _vatInvoiceSyncService = vatInvoiceSyncService; } /// /// TAm kim hA3a `n VAT /// /// Tham s` tAm kim /// Danh sAch hA3a `n VAT [HttpPost("Search")] [Authorize(Roles = "VatInvoice.Search")] public async Task Search([FromBody] SmartTableParam param) { var result = await _vatInvoiceService.Search(param); return Ok(result); } /// === Ladaer.BackEnd\Controllers\Finance\WalletController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.Services.Business; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Finance { /// /// Controller x- lA cAc yAu cu liAn quan `n vA- `in t-. /// [Route("api/[controller]")] [ApiController] [Authorize] public class WalletController : ControllerBase { private readonly IWalletService _walletService; private readonly IWalletTransferService _walletTransferService; private readonly IUserService _userService; public WalletController( IWalletService walletService, IWalletTransferService walletTransferService, IUserService userService) { _walletService = walletService; _walletTransferService = walletTransferService; _userService = userService; } /// /// TAm kim danh sAch cAc vA- `in t- da trAn cAc tham s` `c cung cp. /// /// CAc tham s` tAm kim. === Ladaer.BackEnd\Controllers\Hr\AttendanceController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Results.Export; using Ladaer.BackEnd.Infrastructures.Services.Hr; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Hr { [ApiController] [Route("api/[controller]")] [Authorize] public class AttendanceController : ControllerBase { private readonly IAttendanceService _attendanceService; private readonly IWebHostEnvironment _hostEnvironment; public AttendanceController(IAttendanceService attendanceService, IWebHostEnvironment hostEnvironment) { _attendanceService = attendanceService; _hostEnvironment = hostEnvironment; } [HttpPost("Punch")] [Authorize(Roles = "Attendance.PunchAsync")] public async Task PunchAsync([FromForm] CheckInOutModel model) { var currentUser = User.GetCurrentUser(); model.UpdatedBy = currentUser.UserId; model.UpdatedByUserName = currentUser.UserName; if (model.UpdatedBy <= 0 || string.IsNullOrEmpty(model.UpdatedByUserName)) { return BadRequest("Khng xc d?nh du?c ngu?i dng"); } model.UserId = model.UpdatedBy; var result = await _attendanceService.PunchAsync(model); return Ok(result); === Ladaer.BackEnd\Controllers\Hr\CandidateController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Results.Users; using Ladaer.BackEnd.Infrastructures.Services.Hr; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; namespace Ladaer.BackEnd.Controllers.Hr { /// /// Controller d? x? ly cc ho?t d?ng lin quan d?n ?ng vin. /// [Route("api/[controller]")] [ApiController] [Authorize] public class CandidateController : ControllerBase { private readonly ICandidateService _candidateService; /// /// Kh?i t?o m?t instance m?i c?a l?p . /// /// D?ch v? x? ly ?ng vin. public CandidateController(ICandidateService candidateService) { _candidateService = candidateService; } /// /// Tm ki?m cc ?ng vin d?a trn cc tham s? du?c cung c?p. /// /// Cc tham s? tm ki?m. /// K?t qu? tm ki?m. [HttpPost("Search")] [Authorize(Roles = "Candidate.Search")] public async Task Search([FromBody] SmartTableParam param) { === Ladaer.BackEnd\Controllers\Hr\JobController.cs === using Lada.Framework.Data.Domains.Hr; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Ladaer.BackEnd.Infrastructures.Services.Hr; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Hr { /// /// Controller d? x? ly cc ho?t d?ng lin quan d?n cng vi?c. /// [Route("api/[controller]")] [ApiController] [Authorize] public class JobController : ControllerBase { private readonly IJobPostService _jobPostService; /// /// Kh?i t?o m?t instance m?i c?a l?p . /// /// D?ch v? x? ly cng vi?c. public JobController(IJobPostService jobPostService) { _jobPostService = jobPostService; } /// /// Tm ki?m cc cng vi?c d?a trn cc tham s? du?c cung c?p. /// /// Cc tham s? tm ki?m. /// K?t qu? tm ki?m. [HttpPost("Search")] [Authorize(Roles = "Job.Search")] public async Task Search([FromBody] SmartTableParam param) { var jobs = await _jobPostService.Search(param); return Ok(jobs); === Ladaer.BackEnd\Controllers\Hr\README_AttendanceAPI.md === # Attendance API Documentation ## Tng quan API endpoints m>i cho bAo cAo chm cA'ng vA tA-nh s` cA'ng ca nhAn viAn. ## Endpoints ### 1. GET `/api/Attendance/GetMonthlySummary` **MA' t**: Ly tng hp s` cA'ng ca tt c nhAn viAn theo thAng. **Authorization**: Required (Role: `Attendance.GetMonthlySummary`) **Query Parameters**: - `month` (int, required): ThAng cn bAo cAo (1-12) - `year` (int, required): Nm cn bAo cAo (vA- d: 2025) **Response Success (200 OK)**: ```json [ { "UserId": 1, "UserName": "johndoe", "FullName": "Nguy.n Vn A", "TotalWorkDays": 22, "TotalWorkingHours": 176.5, "TotalWorkCredits": 21.75, "Month": 1, "Year": 2025 }, { "UserId": 2, "UserName": "janedoe", "FullName": "Trn Th< B", "TotalWorkDays": 20, "TotalWorkingHours": 160.0, "TotalWorkCredits": 20.0, "Month": 1, "Year": 2025 === Ladaer.BackEnd\Controllers\Identity\AccountController.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Accounts; using Ladaer.BackEnd.Infrastructures.DTO.Models.Users; using Ladaer.BackEnd.Infrastructures.DTO.Results.Accounts; using Ladaer.BackEnd.Infrastructures.DTO.Results.Users; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; using SixLabors.ImageSharp; using System.IdentityModel.Tokens.Jwt; namespace Ladaer.BackEnd.Controllers.Identity { [Route("api/[controller]")] [ApiController] [Authorize] public class AccountController : ControllerBase { IConfiguration _configuration; private int STAFF_USER_TYPE = 10; private readonly UserManager _userManager; private readonly IUserService _userService; public AccountController(IConfiguration configuration, UserManager userManager, IUserService userService) { _configuration = configuration; _userManager = userManager; _userService = userService; } [HttpPost("Login")] [AllowAnonymous] public async Task Login([FromBody] LoginModel model) { var result = new LoginResult(); if (!ModelState.IsValid) { === Ladaer.BackEnd\Controllers\Identity\PermissionController.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Itentity; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Identity { /// /// Controller ` qun lA Permission Groups (t-p hp cAc Role) /// [Route("api/[controller]")] [ApiController] [Authorize(Roles = "Founder")] // S- dng pattern m>i: Controller.Action public class PermissionController : ControllerBase { private readonly IPermissionService _permissionService; public PermissionController(IPermissionService permissionService) { _permissionService = permissionService; } [HttpGet("GetPermissions")] [Authorize(Roles = "Permission.Search")] public async Task GetPermissions() { var roles = await _permissionService.GetAllPermissionsAsync(); return Ok(roles); } /// /// XA3a Permission Group /// [HttpDelete("{id}")] [Authorize(Roles = "Permission.Delete")] === Ladaer.BackEnd\Controllers\Identity\RoleController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Models.Itentity; using Ladaer.BackEnd.Infrastructures.DTO.Models.Users; using Ladaer.BackEnd.Infrastructures.DTO.Results.Users; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using static IdentityServer4.IdentityServerConstants; namespace Ladaer.BackEnd.Controllers.Identity { [Route("api/[controller]")] [ApiController] [Authorize] public class RoleController : ControllerBase { private readonly IRoleService _roleService; public RoleController(IRoleService roleService) { _roleService = roleService; } [HttpPost("Search")] [Authorize(Roles = "Role.Search")] public async Task Search(SmartTableParam param) { var result = await _roleService.SearchAsync(param); return Ok(result); } [HttpGet("GetRoles")] [Authorize(Roles = "Role.GetRoles")] public async Task GetRoles() === Ladaer.BackEnd\Controllers\Identity\RoleMigrationController.cs === using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Identity { /// /// Controller ` qun lA migration t old role system sang new Permission system /// [Route("api/[controller]")] [ApiController] [Authorize(Roles = "Founder")] // Ch% Founder m>i cA3 quy?n chy migration public class RoleMigrationController : ControllerBase { private readonly IRoleMigrationService _migrationService; public RoleMigrationController(IRoleMigrationService migrationService) { _migrationService = migrationService; } /// /// Kim tra trng thAi migration /// [HttpGet("status")] [Authorize(Roles = "RoleMigration.GetMigrationStatus")] public async Task GetMigrationStatus() { var isCompleted = await _migrationService.IsMigrationCompletedAsync(); return Ok(new { IsCompleted = isCompleted }); } /// /// Ly danh sAch Role m>i s `c to /// [HttpGet("preview-roles")] public IActionResult PreviewNewRoles() { var roles = _migrationService.GetNewRolesToCreate(); return Ok(roles); === Ladaer.BackEnd\Controllers\Identity\UserController.cs === using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Models.Users; using Ladaer.BackEnd.Infrastructures.DTO.Results.Users; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Controllers.Identity { [Route("api/[controller]")] [ApiController] [Authorize] public class UserController : ControllerBase { //private readonly UserManager _userManager; private readonly IUserService _userService; public UserController(IUserService userService) { //_userManager = userManager; _userService = userService; } #region Suggestions [HttpGet("SugStaff")] [Authorize(Roles = "User.SugStaff")] public async Task> SugStaff(string keyword = "") { return await _userService.SugUser(keyword, UserType.Staff); === Ladaer.BackEnd\Controllers\Medias\NewMediaController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.Models.Media; using Lada.Framework.Infrastructures.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Medias { /// /// Controller demo cho New Media Services /// [ApiController] [Route("api/[controller]")] [Authorize] public class NewMediaController : ControllerBase { private readonly IUnifiedMediaService _unifiedMediaService; public NewMediaController(IUnifiedMediaService unifiedMediaService) { _unifiedMediaService = unifiedMediaService; } #region Basic Image Processing /// /// Upload nh `n gin (khA'ng lu database) /// /// File nh /// Loi nh (avatar, product, general, etc.) /// URL nh `A x- lA [HttpPost("upload-image")] [Authorize(Roles = "NewMedia.UploadImage")] public async Task UploadImage(IFormFile file, [FromForm] string imageType = "general") { try { if (file == null || file.Length == 0) { return BadRequest("KhA'ng cA3 file `c upload"); === Ladaer.BackEnd\Controllers\Medias\PictureController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.Results.Media; using Lada.Framework.Infrastructures.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Medias { /// /// Controller to handle operations related to pictures. /// Updated to use UnifiedMediaService from Framework. /// [Route("api/[controller]")] [ApiController] [Authorize] public class PictureController : ControllerBase { private readonly IUnifiedMediaService _unifiedMediaService; /// /// Initializes a new instance of the class. /// /// Unified media service from Framework. public PictureController(IUnifiedMediaService unifiedMediaService) { _unifiedMediaService = unifiedMediaService; } /// /// Uploads a picture for post content. /// /// The picture file to upload. /// The result of the upload operation. [HttpPost("UploadPostContentPicture")] [Authorize(Roles = "Picture.UploadPostContentPicture")] public async Task UploadPostContentPicture(IFormFile file) { if (file == null || file.Length == 0) === Ladaer.BackEnd\Controllers\Monitor\OrderMonitor\OrderRiskController.cs === using Ladaer.BackEnd.Infrastructures.DTO.Models.Monitor; using Ladaer.BackEnd.Infrastructures.Services.Monitor; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Monitor.OrderMonitor { [Authorize] [ApiController] [Area("Monitor")] [Route("api/Monitor/[controller]")] public class OrderRiskController : ControllerBase { private readonly IOrderRiskService _orderRiskService; public OrderRiskController(IOrderRiskService orderRiskService) { _orderRiskService = orderRiskService; } #region Source Fee /// /// Ly danh sAch `n hAng thu ng?i g-i nhng khA'ng cA3 SourceCashierId /// /// T ngAy (optional) /// ?n ngAy (optional) /// Trang (default: 1) /// S` bn ghi/trang (default: 50) [HttpGet("NoSourceCashier")] public async Task GetOrdersWithoutSourceCashier( [FromQuery] DateTime? fromDate = null, [FromQuery] DateTime? toDate = null, [FromQuery] int page = 1, [FromQuery] int pageSize = 50) { try { var param = new OrderRiskSearchParam { FromDate = fromDate, === Ladaer.BackEnd\Controllers\Ops\DeployController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Business.Deploy; using Ladaer.BackEnd.Infrastructures.DTO.Models.Business; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.Services.Business; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using Ladaer.BackEnd.Infrastructures.DTO.Models.DriverApp; namespace Ladaer.BackEnd.Controllers.Ops { /// /// Controller qun lA cAc hot `Tng liAn quan `n trin khai `n hAng. /// [Route("api/[controller]")] [ApiController] [Authorize] public class DeployController : ControllerBase { private readonly IDeployService _deployService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public DeployController(IDeployService deployService) { _deployService = deployService; } /// /// Ly danh sAch cAc ` /// Danh sAch cAc ` [HttpGet("GetDeployLocations")] [Authorize(Roles = "Deploy.GetDeployLocations")] === Ladaer.BackEnd\Controllers\Ops\OperationController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Business.Operations; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; using Ladaer.BackEnd.Infrastructures.Services.Business; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Ops { /// /// Controller ` x- lA cAc hot `Tng liAn quan t>i quy trAnh kinh doanh /// CAc chcc nng Pickup, Delivery `A `c di chuyn sang DriverAppController /// [Route("api/[controller]")] [ApiController] [Authorize] public class OperationController : ControllerBase { private readonly IOperationService _operationService; private readonly IUserService _userService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D /// D public OperationController(IOperationService operationService, IUserService userService) { _operationService = operationService; _userService = userService; } /// /// TAm kim cAc hot `Tng da trAn cAc tham s` `c cung cp. /// /// CAc tham s` tAm kim. /// Kt qu tAm kim. === Ladaer.BackEnd\Controllers\Ops\RouteController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Ops { [Route("api/[controller]")] [ApiController] [Authorize] public class RouteController : ControllerBase { private readonly IRouteService _routeService; public RouteController(IRouteService routeService) { _routeService = routeService; } #region SEARCH /// /// Tm ki?m cc tuy?n d?a trn tham s? SmartTableParam /// /// Tham s? tm ki?m /// Danh sch cc tuy?n ph h?p [HttpPost("Search")] [Authorize(Roles = "Route.Search")] public async Task Search([FromBody] SmartTableParam param) { var routes = await _routeService.Search(param); return Ok(routes); } #endregion #region CRUD /// /// L?y thng tin tuy?n theo ID /// === Ladaer.BackEnd\Controllers\Ops\TruckController.cs === using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models; using Ladaer.BackEnd.Infrastructures.DTO.Models.Trucks; using Ladaer.BackEnd.Infrastructures.DTO.Results.Trucks; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Trucks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Ops { [Route("api/[controller]")] [ApiController] [Authorize] public class TruckController : ControllerBase { private readonly ITruckService _truckService; private readonly ITruckAssetService _truckAssetService; private readonly ITruckActivityService _truckActivityService; private readonly IUserService _userService; private readonly IRepository _truckRepository; public TruckController(ITruckService truckService, ITruckAssetService truckAssetService, ITruckActivityService truckActivityService, IUserService userService, IRepository truckRepository) { _truckService = truckService; _truckAssetService = truckAssetService; _truckActivityService = truckActivityService; _userService = userService; _truckRepository = truckRepository; } #region Truck Management === Ladaer.BackEnd\Controllers\OrderBusiness\OrderFailReasonController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.OrderBusiness; using Ladaer.BackEnd.Infrastructures.Services.OrderBusiness; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.OrderBusiness { /// /// Controller qun lA lA do tht bi ly/giao hAng (Admin) /// [Route("api/[controller]")] [ApiController] [Authorize] public class OrderFailReasonController : ControllerBase { private readonly IOrderFailReasonService _service; public OrderFailReasonController(IOrderFailReasonService service) { _service = service; } /// /// TAm kim lA do tht bi /// [HttpPost("Search")] [Authorize(Roles = "OrderFailReason.Search")] public async Task Search([FromBody] SmartTableParam param) { var result = await _service.Search(param); return Ok(result); } /// /// Ly thA'ng tin lA do tht bi theo ID /// [HttpGet("GetById/{id}")] [Authorize(Roles = "OrderFailReason.GetById")] === Ladaer.BackEnd\Controllers\Orders\OrderAddressController.cs === using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Shared; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Orders { /// /// Controller x- lA cAc hot `Tng liAn quan `n ` [Route("api/[controller]")] [ApiController] [Authorize] public class OrderAddressController : ControllerBase { private readonly IOrderAddressService _orderAddressService; private readonly ICustomerService _customerService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public OrderAddressController(IOrderAddressService orderAddressService, ICustomerService customerService) { _orderAddressService = orderAddressService; _customerService = customerService; } /// /// Ly thA'ng tin chi tit ca mTt ` /// ID ca ` /// ThA'ng tin chi tit ca ` [HttpGet("GetById")] [Authorize(Roles = "OrderAddress.GetById")] public async Task GetById(int id) { === Ladaer.BackEnd\Controllers\Orders\OrderController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Updates; using Ladaer.BackEnd.Infrastructures.DTO.Results; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; using Ladaer.BackEnd.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Lada.Framework.Data.Enums; using System.ComponentModel; using Lada.Framework.Infrastructures.Extensions; using System.Reflection; using Lada.Framework.DTO; namespace Ladaer.BackEnd.Controllers.Orders { /// /// Controller ` x- lA cAc hot `Tng liAn quan t>i `n hAng /// [Route("api/[controller]")] [ApiController] [Authorize] public class OrderController : ControllerBase { private readonly IOrderService _orderService; private readonly string _mapApiKey; /// /// KhYi to mTt instance m>i ca l>p . /// /// TA1y ch?n cu hAnh cng dng. /// D public OrderController(IOptions options, IOrderService orderService) { _orderService = orderService; _mapApiKey = options.Value.GoogleMapsApi.ApiKey; === Ladaer.BackEnd\Controllers\Orders\OrderExportController.cs === using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Orders.Exports; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Orders { /// /// Controller cho vic xut Excel `n hAng (Generic) /// [ApiController] [Route("api/[controller]")] [Authorize] public class OrderExportController : ControllerBase { private readonly IOrderExportService _orderExportService; private readonly IUserService _userService; public OrderExportController( IOrderExportService orderExportService, IUserService userService) { _orderExportService = orderExportService; _userService = userService; } /// /// Xut Excel `n hAng v>i template `c ch% ` /// Model xut Excel /// Kt qu xut file [HttpPost("export")] public async Task> ExportOrders([FromBody] OrderExportModel model) { try { === Ladaer.BackEnd\Controllers\Orders\OrderFinController.cs === using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Shared; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Orders { /// /// Controller ` x- lA cAc hot `Tng liAn quan `n tAi chA-nh `n hAng. /// [Route("api/[controller]")] [ApiController] [Authorize] public class OrderFinController : ControllerBase { private readonly IOrderFinService _orderFinService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public OrderFinController(IOrderFinService orderFinService) { _orderFinService = orderFinService; } /// /// Ly thA'ng tin chi tit ca tAi chA-nh `n hAng da trAn ID. /// /// ID ca tAi chA-nh `n hAng. /// ThA'ng tin chi tit ca tAi chA-nh `n hAng. [HttpGet("GetById")] [Authorize(Roles = "OrderFin.GetById")] public async Task GetById(int id) { var result = await _orderFinService.GetById(id); return Ok(result); === Ladaer.BackEnd\Controllers\Orders\OrderPackageController.cs === using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Shared; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Orders { /// /// Controller ` x- lA cAc hot `Tng liAn quan `n kin hAng `n hAng. /// [Route("api/[controller]")] [ApiController] [Authorize] public class OrderPackageController : ControllerBase { private readonly IOrderPackageService _orderPackageService; /// /// Initializes a new instance of the class. /// /// D public OrderPackageController(IOrderPackageService orderPackageService) { _orderPackageService = orderPackageService; } /// /// Ly thA'ng tin chi tit ca kin hAng `n hAng da trAn ID. /// /// ID ca `n hAng. /// ThA'ng tin chi tit ca kin hAng `n hAng. [HttpGet("GetByOrderId")] [Authorize(Roles = "OrderPackage.GetByOrderId")] public async Task GetByOrderId(int id) { var result = await _orderPackageService.GetByOrderId(id); return Ok(result); } === Ladaer.BackEnd\Controllers\Premises\PremiseController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Premises; using Ladaer.BackEnd.Infrastructures.DTO.Models.Premises; using Ladaer.BackEnd.Infrastructures.DTO.Results.Premises; using Ladaer.BackEnd.Infrastructures.Services.Premises; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Premises { [Route("api/[controller]")] [ApiController] [Authorize] public class PremiseController : ControllerBase { private readonly IPremiseService _service; public PremiseController(IPremiseService service) { _service = service; } /// /// TAm kim danh sAch mt bng /// [HttpPost("Search")] [Authorize(Roles = "Premise.Search")] public async Task Search([FromBody] SmartTableParam param) { var result = await _service.Search(param); return Ok(result); } /// /// Ly chi tit mt bng theo ID /// [HttpGet("GetById/{id}")] [Authorize(Roles = "Premise.GetById")] public async Task GetById(int id) === Ladaer.BackEnd\Controllers\Premises\PremiseScoringController.cs === using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Premises; using Ladaer.BackEnd.Infrastructures.DTO.Models.Premises; using Ladaer.BackEnd.Infrastructures.Services.Premises; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Premises { [Route("api/[controller]")] [ApiController] [Authorize] public class PremiseScoringController : ControllerBase { private readonly IPremiseScoringService _service; public PremiseScoringController(IPremiseScoringService service) { _service = service; } /// /// TAm kim tiAu chA- chm `im /// [HttpPost("SearchCriteria")] [Authorize(Roles = "PremiseScoring.SearchCriteria")] public async Task SearchCriteria([FromBody] SmartTableParam param) { var result = await _service.SearchCriteria(param); return Ok(result); } /// /// Ly tiAu chA- theo ID /// [HttpGet("GetCriteriaById/{id}")] [Authorize(Roles = "PremiseScoring.GetCriteriaById")] public async Task GetCriteriaById(int id) { var result = await _service.GetCriteriaById(id); === Ladaer.BackEnd\Controllers\Reports\ReportController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.Services.Report.Orders; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Reports { [Route("api/[controller]")] [ApiController] [Authorize] public class ReportController : ControllerBase { private readonly IOrderReportService _orderReportService; public ReportController(IOrderReportService orderReportService) { _orderReportService = orderReportService; } [HttpPost("OrderProduction")] [Authorize(Roles = "Report.OrderProduction")] public async Task OrderProduction([FromBody] SmartTableParam param) { var currentUser = User.GetCurrentUser(); var result = await _orderReportService.GetOrderProductionAsync(param, currentUser.UserId); return Ok(result); } /// /// Ly bAo cAo s` lng `n vA doanh s` theo tuyn /// /// Tham s` bng thA'ng minh chca cAc `i?u kin l?c: /// - StartDate/EndDate: Khong th?i gian /// - SaleId: L?c theo sale (ch% Founder) /// - SourceCityId: L?c theo t%nh/thAnh ph` g-i /// - DestCityId: L?c theo t%nh/thAnh ph` nh-n /// /// Danh sAch bAo cAo theo tuyn vA trng thAi === Ladaer.BackEnd\Controllers\Reports\FuelCards\FuelRefillReportController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Results; using Ladaer.BackEnd.Infrastructures.DTO.Results.FuelCards; using Ladaer.BackEnd.Infrastructures.Services.Report.FuelCards; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Reports.FuelCards { /// /// Controller ` x- lA cAc bAo cAo ` du /// [Route("api/[controller]")] [ApiController] [Authorize] public class FuelRefillReportController : ControllerBase { private readonly IFuelRefillReportService _fuelRefillReportService; private readonly IFuelRefillReportExcelService _fuelRefillReportExcelService; /// /// KhYi to mTt th hin ca . /// /// D /// D public FuelRefillReportController( IFuelRefillReportService fuelRefillReportService, IFuelRefillReportExcelService fuelRefillReportExcelService) { _fuelRefillReportService = fuelRefillReportService; _fuelRefillReportExcelService = fuelRefillReportExcelService; } /// /// Ly bAo cAo ` du theo lAi xe /// /// Tham s` bng thA'ng minh /// Danh sAch bAo cAo ` du theo lAi xe === Ladaer.BackEnd\Controllers\Reports\Operations\DriverReportController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.Services.Report.OperationReports; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Results; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Reports.Operations { /// /// Controller ` x- lA cAc bAo cAo hot `Tng lAi xe /// [Route("api/[controller]")] [ApiController] [Authorize] public class DriverReportController : ControllerBase { private readonly IDriverReportService _driverReportService; /// /// KhYi to mTt th hin ca . /// /// D public DriverReportController(IDriverReportService driverReportService) { _driverReportService = driverReportService; } /// /// Ly bAo cAo nng sut lAi xe theo tng ngAy /// /// Tham s` bng thA'ng minh /// Danh sAch bAo cAo nng sut lAi xe theo ngAy [HttpPost("GetDriverProductivityReportByDate")] [Authorize(Roles = "DriverReport.GetDriverProductivityReportByDate")] public async Task GetDriverProductivityReportByDate([FromBody] SmartTableParam param) { try { var currentUser = User.GetCurrentUser(); === Ladaer.BackEnd\Controllers\Reports\Orders\OrderFinReportController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Data.Enums; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Reports; using Ladaer.BackEnd.Infrastructures.DTO.StoredProcedureResults; using Ladaer.BackEnd.Infrastructures.Services.Report.Orders; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Reports.Orders { /// /// Controller ` x- lA cAc bAo cAo tAi chA-nh `n hAng /// [Route("api/[controller]")] [ApiController] [Authorize] public class OrderFinReportController : ControllerBase { private readonly IOrderFinReportService _orderFinReportService; /// /// KhYi to mTt th hin ca . /// /// D public OrderFinReportController(IOrderFinReportService orderFinReportService) { _orderFinReportService = orderFinReportService; } /// /// Chucn b< d_ liu bT l?c: trng thAi vA trng thAi v-t lA /// /// Model chca danh sAch option trng thAi vA trng thAi v-t lA [HttpGet("PrepareBankTransferSummaryBySaleModel")] [Authorize(Roles = "OrderFinReport.GetBankTransferSummaryBySale")] === Ladaer.BackEnd\Controllers\Reports\Sales\RevenueReportController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.Services.Report.SaleReports; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Reports.Sales { [Route("api/[controller]")] [ApiController] [Authorize] public class RevenueReportController : ControllerBase { private readonly ISaleReportService _saleReportService; public RevenueReportController(ISaleReportService saleReportService) { _saleReportService = saleReportService; } /// /// Th`ng kA doanh thu bAn hAng /// /// Tham s` tAm kim /// Kt qu th`ng kA doanh thu [HttpPost("SaleRevenueStatistics")] [Authorize(Roles = "Report.SaleRevenueStatistics")] public async Task SaleRevenueStatistics([FromBody] SmartTableParam param) { var currentUser = User.GetCurrentUser(); var result = await _saleReportService.GetSaleRevenueStatisticsAsync(param, currentUser.UserId); return Ok(result); } /// /// Th`ng kA `n hAng vA doanh thu theo ngAy /// /// Tham s` tAm kim /// Kt qu th`ng kA `n hAng vA doanh thu theo ngAy === Ladaer.BackEnd\Controllers\Rewards\AutoPenaltyConfigController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.Services.Rewards; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Rewards { /// /// Controller qun lA cu hAnh pht t `Tng /// [Route("api/[controller]")] [ApiController] [Authorize] public class AutoPenaltyConfigController : ControllerBase { private readonly IAutoPenaltyConfigService _configService; public AutoPenaltyConfigController(IAutoPenaltyConfigService configService) { _configService = configService; } /// /// Ly cu hAnh `ang hiu lc /// [HttpGet] [Authorize(Roles = "AutoPenaltyConfig.GetCurrentConfig")] public async Task GetCurrentConfig() { try { var result = await _configService.GetCurrentConfig(); if (result == null) { return NotFound("Cha cA3 cu hAnh nAo"); } return Ok(result); } catch (Exception ex) === Ladaer.BackEnd\Controllers\Rewards\RewardPenaltyController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Rewards; using Ladaer.BackEnd.Infrastructures.Services.Rewards; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Rewards { /// /// Controller qun lA phiu thYng/pht /// [Route("api/[controller]")] [ApiController] [Authorize] public class RewardPenaltyController : ControllerBase { private readonly IRewardPenaltyService _rewardPenaltyService; public RewardPenaltyController(IRewardPenaltyService rewardPenaltyService) { _rewardPenaltyService = rewardPenaltyService; } /// /// TAm kim phiu thYng/pht /// [HttpPost("Search")] [Authorize(Roles = "RewardPenalty.Search")] public async Task Search([FromBody] SmartTableParam param) { var result = await _rewardPenaltyService.Search(param); return Ok(result); } /// /// Ly phiu thYng/pht theo ID /// [HttpGet("{id}")] [Authorize(Roles = "RewardPenalty.GetById")] === Ladaer.BackEnd\Controllers\Systems\AgencyController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller ` x- lA cAc hot `Tng liAn quan `n `i lA. /// [Route("api/[controller]")] [ApiController] [Authorize] public class AgencyController : ControllerBase { private readonly IAgencyService _agencyService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public AgencyController(IAgencyService agencyService) { _agencyService = agencyService; } /// /// TAm kim cAc `i lA da trAn cAc tham s` `c cung cp. /// /// CAc tham s` tAm kim. /// Kt qu tAm kim. [HttpPost("Search")] [Authorize(Roles = "Agency.Search")] public async Task Search([FromBody] SmartTableParam param) { var agencies = await _agencyService.Search(param); return Ok(agencies); } === Ladaer.BackEnd\Controllers\Systems\AgencyLocationController.cs === using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller ` x- lA cAc hot `Tng liAn quan `n vA1ng ph ca `i lA /// [Route("api/[controller]")] [ApiController] [Authorize] public class AgencyLocationController : ControllerBase { private readonly IAgencyLocationService _agencyLocationService; /// /// KhYi to mTt instance m>i ca l>p . /// /// Service x- lA vA1ng ph ca `i lA public AgencyLocationController(IAgencyLocationService agencyLocationService) { _agencyLocationService = agencyLocationService; } /// /// Ly thA'ng tin vA1ng ph ca `i lA /// /// ID ca `i lA /// ThA'ng tin vA1ng ph bao g"m danh sAch location [HttpGet("GetAgencyCoverage")] [Authorize(Roles = "AgencyLocation.GetAgencyCoverage")] public async Task GetAgencyCoverage(int agencyId) { if (agencyId <= 0) { return BadRequest("AgencyId khA'ng hp l"); } === Ladaer.BackEnd\Controllers\Systems\AiController.cs === using Ladaer.BackEnd.Infrastructures.Services.AI; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { [Route("api/[controller]")] [ApiController] [Authorize] public class AiController : ControllerBase { private readonly IOpenAiService _openAiService; private readonly IPostService _postService; public AiController(IOpenAiService openAiService, IPostService postService) { _openAiService = openAiService; _postService = postService; } public class PromptCallRequest { public int TemplateId { get; set; } public string Input { get; set; } } [HttpGet("CallPostAi")] [Authorize(Roles = "Ai.CallPrompt")] public async Task CallPrompt(int id) { try { var post = await _postService.GetById(id); var result = await _openAiService.CallPromptTemplateAsync(1, post.Description); return Ok(result); } catch (Exception ex) { === Ladaer.BackEnd\Controllers\Systems\AppConfigController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.AppConfig; using Ladaer.BackEnd.Infrastructures.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller qun lA cu hAnh cng dng (AppConfig) /// [Route("api/[controller]")] [ApiController] [Authorize] public class AppConfigController : ControllerBase { private readonly IAppConfigManagementService _appConfigService; public AppConfigController(IAppConfigManagementService appConfigService) { _appConfigService = appConfigService; } /// /// TAm kim AppConfig v>i SmartTable /// /// Tham s` tAm kim /// Kt qu tAm kim [HttpPost("Search")] [Authorize(Roles = "AppConfig.Search")] public async Task Search([FromBody] SmartTableParam param) { var result = await _appConfigService.Search(param); return Ok(result); } /// /// Ly AppConfig theo Id /// === Ladaer.BackEnd\Controllers\Systems\CallPathController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Settings; using Ladaer.BackEnd.Infrastructures.Services.Settings; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller ` x- lA cAc hot `Tng liAn quan `n call path. /// [Route("api/[controller]")] [ApiController] [Authorize] public class CallPathController : ControllerBase { private readonly ICallPathService _callPathService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public CallPathController(ICallPathService callPathService) { _callPathService = callPathService; } /// /// Ly danh sAch tt c call path. /// /// Danh sAch tt c call path. [HttpGet("GetAll")] public async Task GetAll() { var result = await _callPathService.GetAllAsync(); return Ok(result); } === Ladaer.BackEnd\Controllers\Systems\CallPathVersionController.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Settings; using Ladaer.BackEnd.Infrastructures.Services.Settings; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller ` qun lA cAc phiAn bn `?ng dn (CallPathVersion). /// [Route("api/[controller]")] [ApiController] [Authorize] public class CallPathVersionController : ControllerBase { private readonly ICallPathVersionService _callPathVersionService; public CallPathVersionController(ICallPathVersionService callPathVersionService) { _callPathVersionService = callPathVersionService; } /// /// Ly tt c phiAn bn (dA1ng cho dropdown). /// [HttpGet("GetAll")] public async Task GetAll() { var result = await _callPathVersionService.GetAllAsync(); return Ok(result); } #region Search /// /// TAm kim phiAn bn theo cAc tham s`. /// === Ladaer.BackEnd\Controllers\Systems\EndPointsController.cs === using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller ` x- lA cAc hot `Tng liAn quan t>i `im `u cu`i. /// [Route("api/[controller]")] [ApiController] [Authorize] public class EndPointsController : ControllerBase { private readonly IEndPointsService _endPointsService; /// /// KhYi to mA't instance m>i ca l>p . /// /// D public EndPointsController(IEndPointsService endPointsService) { _endPointsService = endPointsService; } /// /// TAm kim cAc `im `u cu`i da trAn cAc tham s` tAm kim. /// /// CAc tham s` tAm kim. /// Kt qu tAm kim. [HttpPost("Search")] [Authorize(Roles = "EndPoints.Search")] public async Task Search([FromBody] SmartTableParam param) { var locations = await _endPointsService.Search(param); return Ok(locations); } === Ladaer.BackEnd\Controllers\Systems\ErrorReportController.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Models.ErrorReports; using Ladaer.BackEnd.Infrastructures.Services.ErrorReports; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { [Route("api/[controller]")] [ApiController] [Authorize] public class ErrorReportController : ControllerBase { private readonly IErrorReportService _errorReportService; public ErrorReportController(IErrorReportService errorReportService) { _errorReportService = errorReportService; } /// /// To m>i bAo l-i (khA'ng cn `ng nh-p) /// /// ThA'ng tin bAo l-i /// Kt qu to bAo l-i [HttpPost("Create")] [AllowAnonymous] public async Task Create([FromForm] ErrorReportModel model) { if (!ModelState.IsValid) { var errors = ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage) .ToList(); return BadRequest(new { success = false, === Ladaer.BackEnd\Controllers\Systems\GoogleMapController.cs === using System.Threading.Tasks; using Hangfire; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller ` x- lA cAc hot `Tng liAn quan t>i Google Maps. /// [Route("api/[controller]")] [ApiController] [Authorize] public class GoogleMapController : ControllerBase { private readonly IGoogleMapService _googleMapService; private readonly ILocationService _locationService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D /// D public GoogleMapController(IGoogleMapService googleMapService, ILocationService locationService) { _googleMapService = googleMapService; _locationService = locationService; } /// /// KA-ch hot cA'ng vic ly t?a `T (lat, long) ca ph?ng/xA. /// /// ThA'ng bAo kt qu kA-ch hot cA'ng vic. [HttpGet("GetLatLngJob")] [AllowAnonymous] public IActionResult GetLatLngJob() === Ladaer.BackEnd\Controllers\Systems\LocationController.cs === using Hangfire; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller ` x- lA cAc hot `Tng liAn quan t>i ` [Route("api/[controller]")] [ApiController] [Authorize] public class LocationController : ControllerBase { private readonly ILocationService _locationService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public LocationController(ILocationService locationService, IGoogleMapService googleMapService) { _locationService = locationService; } #region SEARCH /// /// TAm kim cAc ` /// CAc tham s` tAm kim. /// Kt qu tAm kim. [HttpPost("Search")] === Ladaer.BackEnd\Controllers\Systems\MenuController.cs === using Lada.Framework.Data.Domains.Categories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Results.Categories; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller x- lA cAc hot `Tng liAn quan `n menu. /// [Route("api/[controller]")] [ApiController] [Authorize] public class MenuController : ControllerBase { private readonly IMenuService _menuService; /// /// KhYi to mTt instance m>i ca l>p . /// /// D public MenuController(IMenuService menuService) { _menuService = menuService; } #region Search /// /// TAm kim cAc menu da trAn cAc tham s` `c cung cp. /// /// CAc tham s` tAm kim. /// Kt qu tAm kim. === Ladaer.BackEnd\Controllers\Systems\WarehouseController.cs === using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Business.Warehouses; using Ladaer.BackEnd.Infrastructures.Services.Business; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Ladaer.BackEnd.Controllers.Systems { /// /// Controller x- lA cAc yAu cu liAn quan `n kho hAng. /// [Route("api/[controller]")] [ApiController] [Authorize] public class WarehouseController : ControllerBase { private readonly IWarehouseService _warehouseService; private readonly IUserService _userService; /// /// KhYi to mTt th hin m>i ca l>p . /// /// D /// D public WarehouseController(IUserService userService, IWarehouseService warehouseService) { _userService = userService; _warehouseService = warehouseService; } /// /// X- lA yAu cu nh-p kho cho mTt `n hAng. /// /// MA' hAnh chca thA'ng tin `n hAng. /// Kt qu ca quA trAnh nh-p kho. [HttpPost("Inbound")] [Authorize(Roles = "Warehouse.Inbound")] public async Task Inbound([FromBody] InboundModel model) === Ladaer.BackEnd\Infrastructures\AppSettings\AppSetting.cs === namespace Ladaer.BackEnd.Infrastructures.AppSettings { public class AppSetting { public GoogleMapsApi GoogleMapsApi { get; set; } } public class GoogleMapsApi { public string ApiKey { get; set; } } } === Ladaer.BackEnd\Infrastructures\AppSettings\CmsSetting.cs === namespace Ladaer.BackEnd.Infrastructures.AppSettings { public class CmsSetting { public SeoSetting SeoSetting { get; set; } } public class SeoSetting { public int MetaTitleLength { get; set; } public int MetaDescriptionLength { get; set; } } } === Ladaer.BackEnd\Infrastructures\AppSettings\JwtSettings.cs === namespace Ladaer.BackEnd.Infrastructures.AppSettings { public class JwtSettings { public string Secret { get; set; } public string Issuer { get; set; } public string Audience { get; set; } public double ExpiryMinutes { get; set; } } } === Ladaer.BackEnd\Infrastructures\Authorization\FounderBypassAuthorizationHandler.cs === using Microsoft.AspNetCore.Authorization; using System.Security.Claims; namespace Ladaer.BackEnd.Infrastructures.Authorization { /// /// Custom Authorization Handler cho phAcp Founder bypass tt c role checks /// public class FounderBypassAuthorizationHandler : IAuthorizationHandler { private readonly ILogger _logger; public FounderBypassAuthorizationHandler(ILogger logger) { _logger = logger; } public Task HandleAsync(AuthorizationHandlerContext context) { // Kim tra nu user `A authenticated if (!context.User.Identity?.IsAuthenticated ?? true) { return Task.CompletedTask; } // Kim tra nu user cA3 role "Founder" if (context.User.IsInRole("Founder")) { _logger.LogInformation("Founder access granted for user: {UserId} to resource: {Resource}", context.User.FindFirst(ClaimTypes.NameIdentifier)?.Value, context.Resource?.ToString() ?? "Unknown"); // Founder `c phAcp truy c-p tt c - mark tt c requirements lA succeeded foreach (var requirement in context.Requirements) { if (!context.HasSucceeded) { context.Succeed(requirement); } } === Ladaer.BackEnd\Infrastructures\Extensions\MediaServiceExtensions.cs === using Lada.Framework.Data.Enums; using Lada.Framework.DTO.Results.Media; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Services; using Lada.Framework.Data.Repositories; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace Ladaer.BackEnd.Infrastructures.Extensions { /// /// Extension methods ` cu hAnh Media Services /// public static class MediaServiceExtensions { /// /// ?ng kA tt c Media Services m>i (ImageService, VideoService, UnifiedMediaService) /// /// Service collection /// Configuration /// Service collection public static IServiceCollection AddNewMediaServices(this IServiceCollection services, IConfiguration configuration) { // 1. Cu hAnh MediaProcessingSettings t appsettings.json services.Configure(configuration.GetSection("MediaProcessingSettings")); // 2. ?ng kA core services v>i dependency injection services.AddScoped(provider => { var settings = provider.GetRequiredService>(); var appConfigService = provider.GetService(); var mediaRepository = provider.GetService>(); return new ImageService(settings, appConfigService, mediaRepository); }); services.AddScoped(provider => { var settings = provider.GetRequiredService>(); === Ladaer.BackEnd\Infrastructures\Hangfires\DashboardAuthorizationFilter.cs === using Hangfire.Annotations; using Hangfire.Dashboard; namespace Ladaer.BackEnd.Infrastructures.Hangfires { public class DashboardAuthorizationFilter : IDashboardAuthorizationFilter { public bool Authorize([NotNull] DashboardContext context) { return true; //return context.GetHttpContext().User.Identity.IsAuthenticated; } } } === Ladaer.BackEnd\Infrastructures\Services\AppConfigManagementService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.AppConfig; using Ladaer.BackEnd.Infrastructures.DTO.Models.AppConfig; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.AppConfig; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; namespace Ladaer.BackEnd.Infrastructures.Services { /// /// Interface cho service qun lA AppConfig /// public interface IAppConfigManagementService { /// /// TAm kim AppConfig v>i SmartTable /// /// Tham s` tAm kim /// Kt qu tAm kim Task> Search(SmartTableParam param); /// /// To hoc c-p nh-t AppConfig /// /// Model AppConfig /// Kt qu thao tAc Task CreateOrUpdate(CreateAppConfigModel model); /// /// Ly AppConfig theo Id /// /// Id ca AppConfig /// AppConfig model Task GetById(int id); === Ladaer.BackEnd\Infrastructures\Services\AppConfigService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Repositories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; namespace Ladaer.BackEnd.Infrastructures.Services { public interface IAppConfigService { Task GetConfigValueAsync(string key); Task LoadConfigsToCacheAsync(); } public class AppConfigService : IAppConfigService { private readonly IRepository _appConfigRepository; private readonly IMemoryCache _memoryCache; private readonly string _cacheKeyPrefix = "AppConfig_"; public AppConfigService(IRepository appConfigRepository, IMemoryCache memoryCache) { _appConfigRepository = appConfigRepository; _memoryCache = memoryCache; } public async Task GetConfigValueAsync(string key) { if (!_memoryCache.TryGetValue($"{_cacheKeyPrefix}{key}", out string value)) { var config = await _appConfigRepository.Query().FirstOrDefaultAsync(c=>c.Key == key); if (config != null) { value = config.Value; _memoryCache.Set($"{_cacheKeyPrefix}{key}", value, TimeSpan.FromHours(1)); } } === Ladaer.BackEnd\Infrastructures\Services\AppConfigServiceAdapter.cs === using Lada.Framework.Infrastructures.Services; namespace Ladaer.BackEnd.Infrastructures.Services { /// /// Adapter ` chuyn `i Framework IAppConfigService thAnh Backend IAppConfigService /// (Backward compatibility) /// public class BackendAppConfigServiceAdapter : Ladaer.BackEnd.Infrastructures.Services.IAppConfigService { private readonly Lada.Framework.Infrastructures.Services.IAppConfigService _frameworkService; public BackendAppConfigServiceAdapter(Lada.Framework.Infrastructures.Services.IAppConfigService frameworkService) { _frameworkService = frameworkService; } public async Task GetConfigValueAsync(string key) { return await _frameworkService.GetConfigValueAsync(key); } public async Task LoadConfigsToCacheAsync() { await _frameworkService.LoadConfigsToCacheAsync(); } } } === Ladaer.BackEnd\Infrastructures\Services\AuthService.cs === using IdentityModel.Client; namespace Ladaer.BackEnd.Infrastructures.Services { public class AuthService { private readonly HttpClient _httpClient; public AuthService(HttpClient httpClient) { _httpClient = httpClient; } public async Task LoginAsync(string username, string password) { var disco = await _httpClient.GetDiscoveryDocumentAsync("https://id.ladaexpress.vn"); if (disco.IsError) { throw new Exception(disco.Error); } var tokenResponse = await _httpClient.RequestPasswordTokenAsync(new PasswordTokenRequest { Address = disco.TokenEndpoint, ClientId = "AppClients", ClientSecret = "kNbPZcuUMc6nufZ2oIJN", Scope = "BackEnd", UserName = username, Password = password }); if (tokenResponse.IsError) { throw new Exception(tokenResponse.Error); } return tokenResponse; } } } === Ladaer.BackEnd\Infrastructures\Services\AI\OpenAiService.cs === using IdentityServer4.Models; using Lada.Framework.Data.Domains.AI; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using OpenAI; using OpenAI.Chat; using OpenAI.Models; namespace Ladaer.BackEnd.Infrastructures.Services.AI { public interface IOpenAiService { Task CallPromptTemplateAsync(int templateId, string input); } public class OpenAiService : IOpenAiService { private readonly OpenAIClient _openAiClient; private readonly IRepository _aiCalllogRepository; private readonly IRepository _promptTemplateRepository; public OpenAiService(OpenAIClient openAiClient, IRepository aiCalllogRepository, IRepository promptTemplateRepository) { _openAiClient = openAiClient; _aiCalllogRepository = aiCalllogRepository; _promptTemplateRepository = promptTemplateRepository; } public async Task CallPromptTemplateAsync(int templateId, string input) { var promptTemplate = await _promptTemplateRepository.GetByIdAsync(templateId); if (promptTemplate == null) throw new Exception($"Prompt ID {templateId} khng tm th?y."); string prompt = promptTemplate.Template.Replace("{{input}}", input); === Ladaer.BackEnd\Infrastructures\Services\Business\DeployService.cs === using System.Data; using Dapper; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Business.Deploy; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Items.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Business; using Ladaer.BackEnd.Infrastructures.DTO.Models.DriverApp; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Results.Business; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; namespace Ladaer.BackEnd.Infrastructures.Services.Business { /// /// Interface cho d?ch v? tri?n khai /// public interface IDeployService { /// /// L?y danh sch v? tr tri?n khai /// /// Tr?ng thi don hng /// Tr?ng thi v?t ly don hng /// Lo?i d?a ch? /// Danh sch v? tr tri?n khai Task> GetDeployLocations(OrderStatus status, OrderPhysicalStatus physicalStatus, AddressType addressType); === Ladaer.BackEnd\Infrastructures\Services\Business\OperationService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Business.Operations; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Models.Business.Operations; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Updates; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; using Xabe.FFmpeg; using Dapper; using System.Data; namespace Ladaer.BackEnd.Infrastructures.Services.Business { /// /// Interface for operation service. /// public interface IOperationService { /// /// Searches for orders based on the provided parameters. /// /// Search parameters. /// User ID. /// Search results. Task> Search(SmartTableParam param, int userId); /// === Ladaer.BackEnd\Infrastructures\Services\Business\WarehouseService.cs === using Dapper; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Business.Deploy; using Ladaer.BackEnd.Infrastructures.DTO.Items.Business.Warehouse; using Ladaer.BackEnd.Infrastructures.DTO.Models.Business.Warehouses; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Results.Business; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.EntityFrameworkCore; using System.Data; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; namespace Ladaer.BackEnd.Infrastructures.Services.Business { /// /// Giao di?n cho WarehouseService /// public interface IWarehouseService { /// /// X? ly qu trnh nh?p kho cho m?t don hng. /// /// M hnh nh?p kho ch?a thng tin don hng. /// K?t qu? nh?p kho ch? ra k?t qu? c?a thao tc. Task Inbound(InboundModel model); /// /// L?y danh sch ti x? theo ID c?a d?i ly v?i ty ch?n l?c t? kha v phn trang. /// /// ID c?a d?i ly. /// T? kha ty ch?n d? l?c ti x?. /// S? trang cho phn trang. /// Kch thu?c trang cho phn trang. === Ladaer.BackEnd\Infrastructures\Services\Categories\AgencyLocationService.cs === using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Categories { /// /// Interface cho service qun lA vA1ng ph ca `i lA /// public interface IAgencyLocationService { /// /// Ly thA'ng tin vA1ng ph ca agency /// /// ID ca `i lA /// ThA'ng tin vA1ng ph Task GetAgencyCoverage(int agencyId); /// /// ThAm location vAo agency /// /// ThA'ng tin cAc location cn thAm /// Kt qu thAm Task AddLocationToAgency(AddLocationsToAgencyModel model); /// /// XA3a location kh?i agency /// /// ThA'ng tin cAc location cn xA3a /// Kt qu xA3a Task RemoveLocationFromAgency(AddLocationsToAgencyModel model); /// /// Ly danh sAch location cha `c ch?n cho agency d>i dng cAy /// /// ID ca `i lA === Ladaer.BackEnd\Infrastructures\Services\Categories\AgencyService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Results.Categories; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Categories { public interface IAgencyService { /// /// Tm ki?m d?i ly /// /// /// Task> Search(SmartTableParam param); /// /// T?o/c?p nh?t d?i ly /// /// /// Task CreateOrUpdate(AgencyModel model); /// /// L?y thng tin d?i ly /// /// /// Task GetById(int id); /// /// Xa d?i ly === Ladaer.BackEnd\Infrastructures\Services\Categories\EndPointsService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Results.Categories; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Categories { /// /// Interface cho d?ch v? EndPoints. /// public interface IEndPointsService { /// /// Tm ki?m EndPoints d?a trn tham s? SmartTable. /// /// Tham s? SmartTable. /// K?t qu? tm ki?m du?i d?ng SmartTableResult. Task> Search(SmartTableParam param); /// /// T?o m?i ho?c c?p nh?t EndPoints. /// /// M hnh EndPoints. /// K?t qu? c?a vi?c t?o m?i ho?c c?p nh?t. Task CreateOrUpdate(EndPointsModel model); /// /// L?y EndPoints theo Id. /// /// Id c?a EndPoints. /// M hnh EndPoints. Task GetById(int id); === Ladaer.BackEnd\Infrastructures\Services\Categories\LocationService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.GoogleMap.PlaceAutocomplete; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Results.GoogleMap; using Lada.Framework.DTO.Results.GoogleMap.PlaceAutocomplete; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Results.Categories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using static IdentityServer4.Models.IdentityResources; namespace Ladaer.BackEnd.Infrastructures.Services.Categories { /// /// D?ch v? x? ly cc thao tc lin quan d?n d?a di?m /// public interface ILocationService { /// /// Tm ki?m d?a di?m theo tham s? SmartTable /// /// Tham s? tm ki?m /// K?t qu? tm ki?m Task> Search(SmartTableParam param); /// /// T?o m?i ho?c c?p nh?t d?a di?m /// /// Thng tin d?a di?m === Ladaer.BackEnd\Infrastructures\Services\Categories\MenuService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Results.Categories; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Categories { public interface IMenuService { Task> Search(SmartTableParam param); Task> GetTree(AppType appType, string keyword); Task> GetMenuList(int userId, AppType appType); Task CreateOrUpdate(MenuModel model); Task GetById(int menuId); Task Delete(int menuId); Task UpdateStatus(MenuStatusModel model, MenuStatus newStatus); } public class MenuService : IMenuService { private readonly IRepository _menuRepository; private readonly IUserService _userService; public MenuService(IRepository menuRepository, IUserService userService) { _menuRepository = menuRepository; _userService = userService; } #region SEARCH - GET public async Task> Search(SmartTableParam param) { === Ladaer.BackEnd\Infrastructures\Services\Cms\CategoryService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Results.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Hosting; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { /// /// Giao di?n cho d?ch v? qu?n ly danh m?c. /// public interface ICategoryService { /// /// Tm ki?m danh m?c. /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m danh m?c. Task> Search(SmartTableParam param); /// /// L?y cy danh m?c. /// /// T? kha tm ki?m. /// Danh sch cy danh m?c. Task> GetTree(string keyword, ContentType contentType = ContentType.Post); === Ladaer.BackEnd\Infrastructures\Services\Cms\PostCategoryService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { public interface IPostCategoryService { Task RemovePostCategoryByPostIdAsync(int postId); } public class PostCategoryService: IPostCategoryService { private readonly IRepository _postCategoryRepository; public PostCategoryService(IRepository postCategoryRepository) { _postCategoryRepository = postCategoryRepository; } public async Task RemovePostCategoryByPostIdAsync(int postId) { var result = new BaseResult(); var postCategories = _postCategoryRepository.Query().Where(pt => pt.PostId == postId).ToList(); try { if (postCategories != null && postCategories.Any()) { foreach (var postCategory in postCategories) { await _postCategoryRepository.RemoveAsync(postCategory); } } } catch (Exception ex) { result.Result = Result.Failed; result.Message = ex.Message; } return result; === Ladaer.BackEnd\Infrastructures\Services\Cms\PostService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using System.Drawing.Imaging; using System.Linq; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { /// /// Giao di?n cho d?ch v? qu?n ly bi vi?t. /// public interface IPostService { /// /// Tm ki?m bi vi?t /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m bi vi?t. Task> Search(SmartTableParam param); /// /// T?o / c?p nh?t bi vi?t /// /// Thng tin bi vi?t. /// K?t qu? c?a thao tc. Task CreateOrUpdate(PostModel model); === Ladaer.BackEnd\Infrastructures\Services\Cms\ProductCategoryService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { public interface IProductCategoryService { Task RemoveProductCategoryByProductIdAsync(int productId); } public class ProductCategoryService : IProductCategoryService { private readonly IRepository _productCategoryRepository; public ProductCategoryService(IRepository productCategoryRepository) { _productCategoryRepository = productCategoryRepository; } public async Task RemoveProductCategoryByProductIdAsync(int productId) { var result = new BaseResult(); var productCategories = _productCategoryRepository.Query().Where(pt => pt.ProductId == productId).ToList(); try { if (productCategories != null && productCategories.Any()) { foreach (var productCategory in productCategories) { await _productCategoryRepository.RemoveAsync(productCategory); } } } catch (Exception ex) { result.Result = Result.Failed; result.Message = ex.Message; } return result; === Ladaer.BackEnd\Infrastructures\Services\Cms\ProductService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { /// /// Giao di?n cho d?ch v? qu?n ly d?ch v?. /// public interface IProductService { /// /// Tm ki?m d?ch v? /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m d?ch v?. Task> Search(SmartTableParam param); /// /// L?y thng tin d?ch v? qua Id /// /// Id c?a d?ch v?. /// Thng tin d?ch v?. Task GetById(int productId); Task CreateOrUpdate(ProductModel model); /// /// Xa bi vi?t === Ladaer.BackEnd\Infrastructures\Services\Cms\ProductTagService.cs === namespace Ladaer.BackEnd.Infrastructures.Services.Cms { public class ProductTagService { } } === Ladaer.BackEnd\Infrastructures\Services\Cms\ScriptConfigService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Ladaer.BackEnd.Infrastructures.DTO; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System; using Lada.Framework.Data.Domains; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; using Lada.Framework.Infrastructures.Helpers; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { public interface IScriptConfigService { Task> GetAllAsync(bool onlyActive = false); Task GetByIdAsync(int id); Task CreateOrUpdate(ScriptConfigModel model); Task DeleteAsync(int id); Task> Search(SmartTableParam param); Task Create(ScriptConfigModel model); Task Update(ScriptConfigModel model); } public class ScriptConfigService : IScriptConfigService { private readonly IRepository _repository; public ScriptConfigService(IRepository repository) { _repository = repository; } public async Task> GetAllAsync(bool onlyActive = false) { === Ladaer.BackEnd\Infrastructures\Services\Cms\TagService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { public interface ITagService { Task> TagAutocomplete(string keyword); Task> Search(SmartTableParam param); Task CreateAsync(string name, int createdBy, string createdByUserName); Task> CreateAsync(List tagNames, int createdBy, string createdByUserName); Task RemoveProductTagByProductIdAsync(int productId); Task RemovePostTagByPostIdAsync(int postId); Task RemoveJobPostTagByJobPostIdAsync(int jobPostId); } public class TagService : ITagService { private readonly IRepository _tagRepository; private readonly IRepository _productTagRepository; private readonly IRepository _postTagRepository; private readonly IRepository _jobPostTagRepository; private readonly IUrlRecordService _urlRecordService; public TagService(IRepository tagRepository, IUrlRecordService urlRecordService, IRepository productTagRepository, IRepository postTagRepository, IRepository jobPostTagRepository) { _tagRepository = tagRepository; _urlRecordService = urlRecordService; _productTagRepository = productTagRepository; _postTagRepository = postTagRepository; _jobPostTagRepository = jobPostTagRepository; } === Ladaer.BackEnd\Infrastructures\Services\Cms\TopicService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; using Microsoft.EntityFrameworkCore; using Lada.Framework.Data.Domains; using Ladaer.BackEnd.Infrastructures.AppSettings; using Microsoft.Extensions.Options; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { public interface ITopicService { /// /// Tm ki?m topic /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m d?ch v?. Task> Search(SmartTableParam param); Task CreateOrUpdate(TopicModel model); Task GetById(int topicId); /// /// Xa bi vi?t /// /// Id c?a bi vi?t. /// K?t qu? c?a thao tc. Task DeleteAsync(int topicId); } public class TopicService : ITopicService { private readonly IRepository _topicRepository; private readonly IUrlRecordService _urlRecordService; === Ladaer.BackEnd\Infrastructures\Services\Cms\UrlRecordService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.DTO.SmartTable; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Lada.Framework.Data.Mappings.DbContexts; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Repositories; using Ladaer.BackEnd.Infrastructures.DTO; using Microsoft.EntityFrameworkCore; using Ladaer.BackEnd.Infrastructures.DTO.Items.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Results.Cms; using Lada.Framework.Data.Enums; namespace Ladaer.BackEnd.Infrastructures.Services.Cms { /// /// Giao di?n cho d?ch v? qu?n ly UrlRecord. /// public interface IUrlRecordService { /// /// L?y thng tin bi vi?t qua Id. /// /// Id c?a bi vi?t. /// Thng tin UrlRecord c?a bi vi?t. Task GetByPostId(int postId); /// /// T?o ho?c c?p nh?t UrlRecord. /// /// Thng tin UrlRecord. /// K?t qu? c?a thao tc. Task Update(UrlRecordModel model); /// /// T?o slug cho UrlRecord. /// /// Slug c?n t?o. /// Slug da du?c t?o. === Ladaer.BackEnd\Infrastructures\Services\Crm\CallLogService.cs === using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Results.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Crm { /// /// Interface cho CallLog Service /// public interface ICallLogService { /// /// TAm kim call log /// /// Tham s` tAm kim /// Kt qu tAm kim Task> Search(SmartTableParam param); /// /// Ly call log theo ID /// /// ID ca call log /// ThA'ng tin call log Task GetById(int id); /// /// To/c-p nh-t call log /// /// ThA'ng tin call log /// Kt qu ca thao tAc Task CreateOrUpdate(CallLogModel model); === Ladaer.BackEnd\Infrastructures\Services\Crm\CustomerAddressService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Results.Crm; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Crm { /// /// Giao di?n cho d?ch v? qu?n ly d?a ch? khch hng. /// public interface ICustomerAddressService { /// /// Tm ki?m d?a ch? khch hng. /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m d?a ch? khch hng. Task> Search(SmartTableParam param); /// /// G?i y d?a ch? khch hng. /// /// T? kha tm ki?m. /// Id c?a khch hng. /// Lo?i d?a ch?. /// Danh sch d?a ch? khch hng g?i y. Task> Suggest(string keyword, int customerId, AddressType addressType); /// === Ladaer.BackEnd\Infrastructures\Services\Crm\CustomerBankAccountService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Results.Crm; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Crm { /// /// Giao din cho d public interface ICustomerBankAccountService { /// /// Ly danh sAch tAi khon ngAn hAng ca khAch hAng. /// /// ID khAch hAng. /// Danh sAch tAi khon ngAn hAng. Task> GetByCustomerId(int customerId); /// /// Ly tAi khon ngAn hAng mc ` /// ID khAch hAng. /// TAi khon ngAn hAng mc ` Task GetDefaultByCustomerId(int customerId); /// /// Ly thA'ng tin tAi khon ngAn hAng theo ID. /// /// ID tAi khon. /// ThA'ng tin tAi khon ngAn hAng. === Ladaer.BackEnd\Infrastructures\Services\Crm\CustomerService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Items.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Results.Crm; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Crm { /// /// Giao di?n cho d?ch v? qu?n ly khch hng. /// public interface ICustomerService { /// /// Tm ki?m khch hng. /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m khch hng. Task> Search(SmartTableParam param); Task> Search(SmartTableParam param, int userId); /// /// G?i y danh sch khch hng. /// /// T? kha tm ki?m. /// Danh sch khch hng g?i y. === Ladaer.BackEnd\Infrastructures\Services\Crm\LeadService.cs === using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Results.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Results.Crm; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Crm { public interface ILeadService { /// /// Tm ki?m lead /// /// /// Task> Search(SmartTableParam param); /// /// T?o/c?p nh?t d?i ly /// /// /// Task CreateOrUpdate(LeadModel model); /// /// T?o lead. /// /// Thng tin lead. /// K?t qu? c?a thao tc. === Ladaer.BackEnd\Infrastructures\Services\Crm\VatInfoService.cs === using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Models.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Crm; using Microsoft.EntityFrameworkCore; using static Ladaer.BackEnd.Infrastructures.DTO.Profiles.CrmMappingExtensions; namespace Ladaer.BackEnd.Infrastructures.Services.Crm { /// /// Interface service qun lA thA'ng tin xut hA3a `n VAT ca khAch hAng /// public interface IVatInfoService { /// /// Ly danh sAch thA'ng tin xut hA3a `n VAT theo `i?u kin tAm kim /// /// Model tAm kim /// Danh sAch thA'ng tin xut hA3a `n VAT Task> Search(SmartTableParam param); /// /// Ly thA'ng tin chi tit xut hA3a `n VAT theo ID /// /// ID thA'ng tin xut hA3a `n VAT /// ThA'ng tin chi tit xut hA3a `n VAT Task GetByIdAsync(int id); /// /// Ly thA'ng tin xut hA3a `n VAT mc ` /// ID khAch hAng /// ThA'ng tin xut hA3a `n VAT mc ` Task GetDefaultByCustomerIdAsync(int customerId); === Ladaer.BackEnd\Infrastructures\Services\DriverApp\AppEnums.cs === === Ladaer.BackEnd\Infrastructures\Services\DriverApp\DriverAppOrderService.cs === using System.Data; using Dapper; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Business.Operations; using Ladaer.BackEnd.Infrastructures.DTO.Items.DriverApp; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Items.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.DriverApp; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Updates; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; using Xabe.FFmpeg; namespace Ladaer.BackEnd.Infrastructures.Services.DriverApp { /// /// Interface for Driver App order service. /// public interface IDriverAppOrderService { /// /// Searches for orders based on the provided parameters. /// /// Search parameters. === Ladaer.BackEnd\Infrastructures\Services\DriverApp\DriverAppService.cs === using System.Data; using Dapper; using Lada.Framework.Data.Domains.Hr; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Models.DriverApp; using Ladaer.BackEnd.Infrastructures.Services.Hr; using Ladaer.BackEnd.Infrastructures.Services.Trucks; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.DriverApp { public interface IDriverAppService { Task GetDashboard(int userId); } public class DriverAppService : IDriverAppService { private readonly IDbConnection _dbConnection; private readonly IAttendanceService _attendanceService; private readonly ITruckActivityService _truckActivityService; private readonly IRepository _attendanceRepository; private readonly IRepository _truckActivityRepository; public DriverAppService( IDbConnection dbConnection, IAttendanceService attendanceService, ITruckActivityService truckActivityService, IRepository attendanceRepository, IRepository truckActivityRepository) { _dbConnection = dbConnection; _attendanceService = attendanceService; _truckActivityService = truckActivityService; _attendanceRepository = attendanceRepository; _truckActivityRepository = truckActivityRepository; } === Ladaer.BackEnd\Infrastructures\Services\DriverApp\DriverFinService.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.DriverApp; using Ladaer.BackEnd.Infrastructures.DTO.Models.DriverApp; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.DriverApp { /// /// Interface cho d public interface IDriverFinService { /// /// Ly thA'ng tin tAi chA-nh ca lAi xe /// /// ID ca lAi xe /// ThA'ng tin tAi chA-nh ca lAi xe Task GetDriverFinancialInfo(int userId); /// /// TAm kim danh sAch `n hAng tAi chA-nh ca lAi xe cA3 phAn trang /// /// Tham s` tAm kim vA phAn trang /// ID ca lAi xe /// Kt qu tAm kim cA3 phAn trang Task> Search(SmartTableParam param, int userId); } /// /// D public class DriverFinService : IDriverFinService { private readonly IRepository _orderFinRepository; === Ladaer.BackEnd\Infrastructures\Services\DriverApp\README.md === # DriverApp Services ## Tng quan Th mc `DriverApp` chca cAc service liAn quan `n cng dng lAi xe (Driver App), `c tAch bit kh?i cAc service nghip v kinh doanh (Business Operations) ` `m bo tA-nh rA rAng vA d. bo trA. ## Cu trAc ### 1. DriverAppService - **Mc `A-ch**: X- lA logic dashboard vA thA'ng tin tng quan cho lAi xe - **Chcc nng chA-nh**: - Ly thA'ng tin dashboard - ThA'ng tin chm cA'ng - ThA'ng tin xe `ang ph trAch ### 2. DriverAppOrderService - **Mc `A-ch**: X- lA tt c cAc thao tAc liAn quan `n `n hAng cho lAi xe - **Chcc nng chA-nh**: - TAm kim danh sAch `n hAng - Ly thA'ng tin chi tit `n hAng - C-p nh-t trng thAi ly hAng (Pickup) - C-p nh-t trng thAi giao hAng (Delivery) - X- lA cAc tr?ng hp tht bi (PickupFail, DeliveryFail) ### 3. DriverFinService - **Mc `A-ch**: X- lA cAc vn `? tAi chA-nh liAn quan `n lAi xe - **Chcc nng chA-nh**: - ThA'ng tin tAi chA-nh ca lAi xe - TAm kim `n hAng tAi chA-nh ## LA do tAch bit ### Tr>c `Ay - `OperationService` trong th mc `Business` x- lA c logic nghip v kinh doanh vA logic lAi xe - GAy khA3 khn trong vic bo trA vA mY rTng - KhA'ng rA rAng v? trAch nhim ca tng service === Ladaer.BackEnd\Infrastructures\Services\ErrorReports\ErrorReportService.cs === using Lada.Framework.Data.Domains.ErrorReports; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.ErrorReports; using Ladaer.BackEnd.Infrastructures.DTO.Models.ErrorReports; using Ladaer.BackEnd.Infrastructures.DTO.Results.ErrorReports; using Ladaer.BackEnd.Infrastructures.Extensions; using Microsoft.EntityFrameworkCore; using System.ComponentModel; namespace Ladaer.BackEnd.Infrastructures.Services.ErrorReports { public interface IErrorReportService { /// /// TAm kim bAo l-i /// /// Tham s` tAm kim /// Danh sAch bAo l-i Task> Search(SmartTableParam param); /// /// To m>i bAo l-i /// /// ThA'ng tin bAo l-i /// Kt qu to bAo l-i Task Create(ErrorReportModel model); /// /// Ly chi tit bAo l-i /// /// ID bAo l-i /// Chi tit bAo l-i Task GetById(int id); /// === Ladaer.BackEnd\Infrastructures\Services\Finance\BankSeedService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Microsoft.Extensions.Logging; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Service ` seed d_ liu ngAn hAng /// public class BankSeedService { private readonly IRepository _bankRepository; private readonly ILogger _logger; public BankSeedService( IRepository bankRepository, ILogger logger) { _bankRepository = bankRepository; _logger = logger; } /// /// Seed d_ liu ngAn hAng t danh sAch cung cp /// public async Task SeedBankDataAsync() { try { // Kim tra xem `A cA3 d_ liu cha var existingBanks = _bankRepository.Query(); if (existingBanks.Any()) { _logger.LogInformation("Bank data already exists. Skipping seed."); return true; } var banks = GetBankData(); === Ladaer.BackEnd\Infrastructures\Services\Finance\BankService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { public interface IBankService { Task> Search(SmartTableParam param); Task> GetAll(); Task GetById(int id); Task CreateOrUpdate(BankModel model); Task Create(BankModel model); Task Update(BankModel model); Task Delete(int id); Task> SugBank(string keyword = "", int limit = 20); } /// /// Service qun lA ngAn hAng /// public class BankService : IBankService { private readonly IRepository _bankRepository; public BankService(IRepository bankRepository) { _bankRepository = bankRepository; } /// /// TAm kim ngAn hAng v>i phAn trang /// === Ladaer.BackEnd\Infrastructures\Services\Finance\CustomerReconciliationSlipExcelService.cs === using System.Drawing; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using OfficeOpenXml.Style; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface cho d public interface ICustomerReconciliationSlipExcelService { /// /// Xut Excel danh sAch phiu ``i soAt khAch hAng /// /// Model xut Excel /// Kt qu xut file Task ExportCustomerReconciliationSlipsAsync(CustomerReconciliationSlipExcelExportModel model); /// /// Xut Excel chi tit phiu ``i soAt khAch hAng /// /// ID phiu ``i soAt /// Model xut Excel /// Kt qu xut file Task ExportCustomerReconciliationSlipDetailAsync(int slipId, CustomerReconciliationSlipExcelExportModel model); /// /// Xut Excel danh sAch `n hAng cn ``i soAt ca khAch hAng /// /// ID khAch hAng === Ladaer.BackEnd\Infrastructures\Services\Finance\CustomerReconciliationSlipService.cs === using System.Data; using System.Linq.Dynamic.Core; using Dapper; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Extensions; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.DTO.StoredProcedureResults; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.EntityFrameworkCore; using static Lada.Framework.Data.Enums.OrderFinEnum; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { public class CustomerReconciliationSlipService : ICustomerReconciliationSlipService { private readonly IRepository _slipRepository; private readonly IRepository _slipDetailRepository; private readonly IRepository _logRepository; private readonly IRepository _orderRepository; private readonly IRepository _orderFinRepository; private readonly IRepository _customerRepository; === Ladaer.BackEnd\Infrastructures\Services\Finance\ExpenseCategoryService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Microsoft.EntityFrameworkCore; using static Ladaer.BackEnd.Infrastructures.DTO.Profiles.FinanceMappingExtensions; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface cho service qun lA danh mc chi phA- /// public interface IExpenseCategoryService { /// /// TAm kim danh mc chi phA- v>i phAn trang /// Task> Search(SmartTableParam param); /// /// Ly danh mc chi phA- theo ID /// Task GetByIdAsync(int id); /// /// To hoc c-p nh-t danh mc chi phA- /// Task CreateOrUpdateAsync(ExpenseCategoryModel model, CurrentUser currentUser); /// /// XA3a danh mc chi phA- /// Task DeleteAsync(int id, CurrentUser currentUser); === Ladaer.BackEnd\Infrastructures\Services\Finance\ExportOrderService.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using OfficeOpenXml.Style; using System.Drawing; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface cho d public interface IExportOrderService { /// /// Xut Excel thA'ng tin `n hAng theo danh sAch OrderId hoc OrderCode /// /// ThA'ng tin `u vAo /// Kt qu xut file Task ExportOrdersToExcelAsync(ExportOrderModel model); /// /// Xut Excel thA'ng tin `n hAng theo danh sAch OrderId /// /// Danh sAch ID `n hAng /// ??ng dn file Excel /// Kt qu xut file Task ExportOrdersByIdsAsync(List orderIds, string filePath); /// /// Xut Excel thA'ng tin `n hAng theo danh sAch OrderCode /// /// Danh sAch mA `n hAng /// ??ng dn file Excel === Ladaer.BackEnd\Infrastructures\Services\Finance\ICustomerReconciliationSlipService.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Lada.Framework.Infrastructures; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { public interface ICustomerReconciliationSlipService { /// /// Ly danh sAch khAch hAng cn ``i soAt (cA3 `n hAng cha ``i soAt) /// Sale ch% thy khAch hAng ca mAnh /// Task> GetCustomersOverviewAsync(SmartTableParam param, int userId); /// /// Ly danh sAch `n hAng cA3 th ``i soAt ca mTt khAch hAng /// Task> GetReconciliableOrdersAsync(int customerId, int userId); /// /// To phiu ``i soAt m>i /// Task CreateSlipAsync(CreateCustomerReconciliationSlipModel model, CurrentUser currentUser); /// /// TAm kim phiu ``i soAt /// Task> GetSlipsAsync(SmartTableParam param, int userId); /// /// Ly chi tit phiu ``i soAt /// Task GetSlipByIdAsync(int id, int userId); /// === Ladaer.BackEnd\Infrastructures\Services\Finance\IncomeCategoryService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Microsoft.EntityFrameworkCore; using static Ladaer.BackEnd.Infrastructures.DTO.Profiles.FinanceMappingExtensions; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface cho service qun lA danh mc doanh thu /// public interface IIncomeCategoryService { /// /// TAm kim danh mc doanh thu v>i phAn trang /// Task> Search(SmartTableParam param); /// /// Ly danh mc doanh thu theo ID /// Task GetByIdAsync(int id); /// /// To hoc c-p nh-t danh mc doanh thu /// Task CreateOrUpdateAsync(IncomeCategoryModel model, CurrentUser currentUser); /// /// XA3a danh mc doanh thu /// Task DeleteAsync(int id, CurrentUser currentUser); === Ladaer.BackEnd\Infrastructures\Services\Finance\IUserBankAccountService.cs === using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface service qun lA tAi khon ngAn hAng ng?i dA1ng /// public interface IUserBankAccountService { /// /// TAm kim tAi khon ngAn hAng ng?i dA1ng /// /// Tham s` tAm kim /// Kt qu tAm kim Task> Search(SmartTableParam param); /// /// Ly thA'ng tin chi tit tAi khon ngAn hAng theo ID /// /// ID tAi khon ngAn hAng /// ThA'ng tin chi tit tAi khon ngAn hAng Task GetById(int id); /// /// To m>i hoc c-p nh-t tAi khon ngAn hAng /// /// ThA'ng tin tAi khon ngAn hAng /// Kt qu ca thao tAc Task CreateOrUpdate(UserBankAccountModel model); /// /// XA3a tAi khon ngAn hAng /// /// ThA'ng tin tAi khon ngAn hAng cn xA3a /// Kt qu ca thao tAc Task Delete(UserBankAccountModel model); === Ladaer.BackEnd\Infrastructures\Services\Finance\ReconciliationExcelService.cs === using Lada.Framework.DTO; using Lada.Framework.Data.Repositories; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using OfficeOpenXml.Style; using System.Drawing; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface cho d public interface IReconciliationExcelService { /// /// Xut Excel danh sAch phiu ``i soAt /// /// Model xut Excel /// Kt qu xut file Task ExportReconciliationsAsync(ReconciliationExcelExportModel model); /// /// Xut Excel chi tit phiu ``i soAt /// /// ID phiu ``i soAt /// Model xut Excel /// Kt qu xut file Task ExportReconciliationDetailAsync(int reconciliationId, ReconciliationExcelExportModel model); } /// /// D === Ladaer.BackEnd\Infrastructures\Services\Finance\TaxInvoiceService.cs === using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface d public interface ITaxInvoiceService { Task CreateTaxInvoiceAsync(CreateTaxInvoiceModel model, CurrentUser currentUser); Task UpdateTaxInvoiceStatusAsync(UpdateTaxInvoiceStatusModel model, CurrentUser currentUser); Task GetTaxInvoiceByIdAsync(int id, CurrentUser currentUser); Task GetTaxInvoiceBySlipIdAsync(int slipId, CurrentUser currentUser); Task DeleteTaxInvoiceAsync(int id, CurrentUser currentUser); } /// /// D public class TaxInvoiceService : ITaxInvoiceService { private readonly IRepository _taxInvoiceRepository; private readonly IRepository _slipRepository; private readonly IRepository _vatInfoRepository; === Ladaer.BackEnd\Infrastructures\Services\Finance\TransferPaymentBillExcelService.cs === using Lada.Framework.DTO; using Lada.Framework.Data.Repositories; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Infrastructures.Services; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using OfficeOpenXml.Style; using System.Drawing; using System.IO; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Interface cho d?ch v? xu?t Excel phi?u chuy?n kho?n /// public interface ITransferPaymentBillExcelService { /// /// Xu?t Excel danh sch phi?u chuy?n kho?n /// /// Model xu?t Excel /// K?t qu? xu?t file Task ExportTransferPaymentBillsAsync(TransferPaymentBillExcelExportModel model); /// /// Xu?t Excel chi ti?t phi?u chuy?n kho?n /// /// ID phi?u chuy?n kho?n /// Model xu?t Excel /// K?t qu? xu?t file Task ExportTransferPaymentBillDetailAsync(int transferPaymentBillId, TransferPaymentBillExcelExportModel model); === Ladaer.BackEnd\Infrastructures\Services\Finance\TransferPaymentBillService.cs === using Dapper; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Ladaer.BackEnd.Infrastructures.DTO.StoredProcedureResults; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using System.Data; using static Lada.Framework.Data.Enums.OrderFinEnum; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Domains; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { public interface ITransferPaymentBillService { Task> SearchCustomersForTransferPayment(SmartTableParam param, CurrentUser currentUser); Task GetTransferableOrdersByCustomer(int customerId, CurrentUser currentUser); Task> Search(SmartTableParam param, CurrentUser currentUser); Task GetById(int id, CurrentUser currentUser); Task Create(CreateTransferPaymentBillModel model, CurrentUser currentUser); Task Cancel(CancelTransferPaymentBillModel model); === Ladaer.BackEnd\Infrastructures\Services\Finance\UserBankAccountService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; using static Ladaer.BackEnd.Infrastructures.DTO.Profiles.FinanceMappingExtensions; namespace Ladaer.BackEnd.Infrastructures.Services.Finance { /// /// Service qun lA tAi khon ngAn hAng ng?i dA1ng /// public class UserBankAccountService : IUserBankAccountService { private readonly IRepository _userBankAccountRepository; private readonly IRepository _bankRepository; private readonly IUserRepository _userRepository; private readonly IPermissionService _permissionService; public UserBankAccountService( IRepository userBankAccountRepository, IRepository bankRepository, IUserRepository userRepository, IPermissionService permissionService) { _userBankAccountRepository = userBankAccountRepository; _bankRepository = bankRepository; _userRepository = userRepository; _permissionService = permissionService; } /// /// TAm kim tAi khon ngAn hAng ng?i dA1ng === Ladaer.BackEnd\Infrastructures\Services\Finances\BackFeeService.cs === using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance.Quotations; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Models; using Lada.Framework.DTO.Results; using Lada.Framework.Infrastructures.Services; using Microsoft.EntityFrameworkCore; using Route = Lada.Framework.Data.Domains.Finance.Quotations.Route; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Giao di?n cho d?ch v? tnh ph v?n chuy?n. /// public interface IBackFeeService { /// /// L?y gi theo phu?ng. /// /// Thng tin phu?ng. /// API key c?a Google Maps. /// K?t qu? tnh ph. Task GetFeeByWard(FeeByWardModel model, string apiKey); /// /// L?y gi theo kho?ng cch. /// /// Thng tin kho?ng cch. /// K?t qu? tnh ph. Task GetFee(FeeModel model); } /// /// Tri?n khai d?ch v? tnh ph v?n chuy?n. /// public class BackFeeService : IBackFeeService === Ladaer.BackEnd\Infrastructures\Services\Finances\BankAccountService.cs === using System; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO; using Microsoft.EntityFrameworkCore; using System.Diagnostics; using System.IO; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Interface cho service qun lA tAi khon ngAn hAng /// public interface IBankAccountService { /// /// TAm kim tAi khon ngAn hAng /// Task> Search(SmartTableParam param); /// /// Ly chi tit tAi khon ngAn hAng /// Task GetById(int id); /// /// To hoc c-p nh-t tAi khon ngAn hAng /// Task CreateOrUpdate(BankAccountModel model); /// /// XA3a tAi khon ngAn hAng === Ladaer.BackEnd\Infrastructures\Services\Finances\BankStatementParser.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using System.Globalization; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Interface cho service parse sao kA ngAn hAng /// public interface IBankStatementParser { Task ParseBankStatement(BankStatementImportModel model, string bankCode, int userId = 0, string userName = "System"); } /// /// Service parse sao kA ngAn hAng /// public class BankStatementParser : IBankStatementParser { private readonly IRepository _transactionRepository; public BankStatementParser(IRepository transactionRepository) { _transactionRepository = transactionRepository; } public async Task ParseBankStatement(BankStatementImportModel model, string bankCode, int userId = 0, string userName = "System") { var result = new BankStatementParseResult(); try { using var stream = model.ExcelFile.OpenReadStream(); using var package = new ExcelPackage(stream); if (package.Workbook.Worksheets.Count == 0) === Ladaer.BackEnd\Infrastructures\Services\Finances\CashierService.cs === using Dapper; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Shared; using Newtonsoft.Json; using System.Data; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Repositories; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Domains; using Microsoft.EntityFrameworkCore; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Data.Domains.Orders; using static Lada.Framework.Data.Enums.OrderFinEnum; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { public interface ICashierService { Task> Search(SmartTableParam param, int userId); Task CollectCashier(CollectCashierModel model); } public class CashierService : ICashierService { private readonly IRepository _orderFinRepository; private readonly IRepository _walletRepository; private readonly IRepository _transactionRepository; private readonly IRepository _orderRepository; private readonly IDbConnection _connection; private readonly IUserService _userService; private readonly IOrderTrackService _orderTrackService; private readonly IOrderTimeTrackService _orderTimeTrackService; === Ladaer.BackEnd\Infrastructures\Services\Finances\DriverFinService.cs === === Ladaer.BackEnd\Infrastructures\Services\Finances\ExpenseService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finances; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; using ExpenseStatus = Lada.Framework.Data.Enums.ExpenseStatus; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Interface cho service qun lA chi phA- /// public interface IExpenseService { /// /// TAm kim chi phA- /// /// Tham s` tAm kim /// Ng?i dA1ng hin ti /// Kt qu tAm kim Task> Search(SmartTableParam param, CurrentUser currentUser); /// /// Ly thA'ng tin chi tit ca chi phA- /// /// ID chi phA- /// Ng?i dA1ng hin ti /// ThA'ng tin chi tit chi phA- === Ladaer.BackEnd\Infrastructures\Services\Finances\IncomeService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finances; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; using IncomeStatus = Lada.Framework.Data.Enums.IncomeStatus; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Interface cho service qun lA doanh thu /// public interface IIncomeService { /// /// TAm kim doanh thu /// /// Tham s` tAm kim /// Ng?i dA1ng hin ti /// Kt qu tAm kim Task> Search(SmartTableParam param, CurrentUser currentUser); /// /// Ly thA'ng tin chi tit ca doanh thu /// /// ID doanh thu /// Ng?i dA1ng hin ti /// ThA'ng tin chi tit doanh thu === Ladaer.BackEnd\Infrastructures\Services\Finances\IVatInvoiceService.cs === using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Service qun lA hA3a `n VAT nTi bT (CRUD) /// public interface IVatInvoiceService { /// /// TAm kim hA3a `n VAT /// Task> Search(SmartTableParam param); } } === Ladaer.BackEnd\Infrastructures\Services\Finances\IVatInvoiceSyncService.cs === using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Service `"ng bT hA3a `n VAT t API Tng cc Thu /// public interface IVatInvoiceSyncService { /// /// ?"ng bT hA3a `n t API Tng cc Thu cho mTt khong th?i gian /// /// NgAy b_t `u /// NgAy kt thAc /// Loi `"ng bT: Manual hoc Auto /// User ID nu lA manual sync /// Chi?u hA3a `n: 1=BAn ra, 2=Mua vAo /// Task SyncInvoicesFromAPI(DateTimeOffset fromDate, DateTimeOffset toDate, string syncType = "Manual", int? userId = null, int invoiceDirection = 1); /// /// ?"ng bT hA3a `n bAn ra ca ngAy hA'm qua (dA1ng cho Hangfire job) /// Task SyncYesterdayInvoices(); /// /// ?"ng bT hA3a `n mua vAo ca ngAy hA'm qua (dA1ng cho Hangfire job) /// Task SyncYesterdayPurchaseInvoices(); /// /// Ly thA'ng tin `"ng bT gn nht /// Task GetLastSyncInfo(); } } === Ladaer.BackEnd\Infrastructures\Services\Finances\OrderTimeTrackService.cs === using Dapper; using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using System.Data; using static Lada.Framework.Data.Enums.OrderFinEnum; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Interface cho service qun lA th?i gian nh-n ti?n trong OrderTimeTrack /// public interface IOrderTimeTrackService { /// /// C-p nh-t th?i gian nh-n ti?n trong OrderTimeTrack /// /// ID `n hAng /// Stage ca SourceFee (3=Branch, 9=Head) /// Stage ca DestFee (3=Branch, 9=Head) /// Stage ca TransferFee (3=Branch, 9=Head) /// Stage ca COD (3=Branch, 9=Head) /// Stage ca DeductCodFee (3=Branch, 9=Head) - ch% khi PayFeeType = COD /// ID ng?i c-p nh-t /// TAn ng?i c-p nh-t /// Th?i gian hin ti (null = SYSDATETIMEOFFSET()) /// Kt qu c-p nh-t Task UpdateFinancialTimesAsync( int orderId, OrderFeeStage? sourceFeeStage = null, OrderFeeStage? destFeeStage = null, OrderFeeStage? transferFeeStage = null, OrderCodStage? codStage = null, OrderFeeStage? deductCodFeeStage = null, int? updatedBy = null, string? updatedByUserName = null, DateTimeOffset? currentTime = null); /// /// C-p nh-t th?i gian nh-n ti?n cho nhi?u `n hAng /// === Ladaer.BackEnd\Infrastructures\Services\Finances\PriceService.cs === using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance.Quotations; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Results.Export; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using OfficeOpenXml; using OfficeOpenXml.Style; using System.Drawing; using Route = Lada.Framework.Data.Domains.Finance.Quotations.Route; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Giao di?n cho d?ch v? qu?n ly gi. /// public interface IPriceService { /// /// L?y danh sch gi m?c d?nh theo lo?i gi. /// /// Lo?i gi. /// Danh sch gi m?c d?nh. Task GetDefaultPriceList(PriceType priceType); /// /// C?p nh?t danh sch gi m?c d?nh. /// /// Thng tin danh sch gi. /// K?t qu? c?a thao tc. Task UpdateDefaultPriceList(PriceListModel model); /// /// Xu?t danh sch gi m?c d?nh ra file. === Ladaer.BackEnd\Infrastructures\Services\Finances\README_OrderTimeTrackService.md === # OrderTimeTrackService - Service Qun LA Th?i Gian Nh-n Ti?n ## Tng Quan `OrderTimeTrackService` lA mTt service chuyAn dng ` qun lA vic c-p nh-t th?i gian nh-n ti?n trong bng `OrderTimeTrack`. Service nAy `c thit k ` cA3 th tAi s- dng Y nhi?u ni khAc nhau trong h th`ng. ## Mc ?A-ch - **TAi s- dng**: CA3 th s- dng trong nhi?u service khAc nhau (CashierService, ReconciliationService, TransferPaymentBillService, etc.) - **T-p trung hA3a**: Tt c logic c-p nh-t th?i gian nh-n ti?n `c t-p trung vAo mTt service - **D. bo trA**: Thay `i logic ch% cn s-a Y mTt ni - **Batch processing**: H- tr c-p nh-t nhi?u `n hAng cA1ng lAc ## CAc Tr?ng Th?i Gian ?c Qun LA | Tr?ng | MA' T | ?i?u Kin C-p Nh-t | |--------|-------|-------------------| | `HeadSourceFeeTime` | Th?i gian nh-n ti?n c>c ngu"n | Khi `SourceFeeStage = Head (9)` | | `HeadDestFeeTime` | Th?i gian nh-n ti?n c>c `A-ch | Khi `DestFeeStage = Head (9)` | | `HeadTransferFeeTime` | Th?i gian nh-n ti?n c>c chuyn khon | Khi `TransferFeeStage = Head (9)` | | `HeadDeductCodFeeTime` | Th?i gian nh-n ti?n c>c cn tr COD | Khi `DeductCodFeeStage = Head (9)` vA `PayFeeType = COD` | ## Interface ### IOrderTimeTrackService ```csharp public interface IOrderTimeTrackService { /// /// C-p nh-t th?i gian nh-n ti?n cho mTt `n hAng /// Task UpdateFinancialTimesAsync( int orderId, OrderFeeStage? sourceFeeStage = null, OrderFeeStage? destFeeStage = null, OrderFeeStage? transferFeeStage = null, OrderCodStage? codStage = null, OrderFeeStage? deductCodFeeStage = null, int? updatedBy = null, === Ladaer.BackEnd\Infrastructures\Services\Finances\ReconciliationService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Crm; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finances; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Microsoft.EntityFrameworkCore; using static Lada.Framework.Data.Enums.OrderFinEnum; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Giao din cho d public interface IReconciliationService { /// /// TAm kim khAch hAng cn ``i soAt v>i phAn trang. /// /// Tham s` tAm kim. /// ID ng?i dA1ng hin ti. /// Kt qu tAm kim khAch hAng cn ``i soAt. Task> SearchCustomersForReconciliation(SmartTableParam param, int userId); /// === Ladaer.BackEnd\Infrastructures\Services\Finances\RouteService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finances; using Microsoft.EntityFrameworkCore; using Route = Lada.Framework.Data.Domains.Finance.Quotations.Route; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Giao di?n cho d?ch v? qu?n ly tuy?n v?n t?i. /// public interface IRouteService { /// /// Tm ki?m tuy?n v?n t?i. /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m tuy?n v?n t?i. Task> Search(SmartTableParam param); /// /// T?o m?i ho?c c?p nh?t thng tin tuy?n v?n t?i. /// /// Thng tin tuy?n v?n t?i. /// K?t qu? c?a thao tc. Task CreateOrUpdate(RouteModel model); /// /// L?y thng tin tuy?n v?n t?i theo ID. /// /// ID c?a tuy?n v?n t?i. /// Thng tin tuy?n v?n t?i. Task GetById(int routeId); === Ladaer.BackEnd\Infrastructures\Services\Finances\TransactionService.cs === using System; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finances; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { public interface ITransactionService { Task SearchWalletTransactions(SmartTableParam param, int userId); Task GetTransactionDetail(Guid transactionId); Task GetTransactionStatistics(int walletId, DateTimeOffset? startDate = null, DateTimeOffset? endDate = null); Task GetWalletBalanceHistory(int walletId, DateTimeOffset? startDate = null, DateTimeOffset? endDate = null); } public class TransactionService : ITransactionService { private readonly IRepository _transactionRepository; private readonly IRepository _walletRepository; private readonly IRepository _transactionOrderRepository; private readonly IUserService _userService; public TransactionService( IRepository transactionRepository, IRepository walletRepository, IRepository transactionOrderRepository, IUserService userService) { _transactionRepository = transactionRepository; _walletRepository = walletRepository; _transactionOrderRepository = transactionOrderRepository; === Ladaer.BackEnd\Infrastructures\Services\Finances\VatInvoiceService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Service qun lA hA3a `n VAT nTi bT (CRUD) /// public class VatInvoiceService : IVatInvoiceService { private readonly IRepository _repository; public VatInvoiceService(IRepository repository) { _repository = repository; } /// /// TAm kim hA3a `n VAT /// public async Task> Search(SmartTableParam param) { var query = _repository.Query(); // A?p dng filter t param if (param.Search.PredicateObject != null) { dynamic search = param.Search.PredicateObject; // TAm kim theo keyword if (search.Keyword != null) { string keyword = search.Keyword.ToString().Trim().ToLower(); query = query.Where(x => x.InvoiceNumber.ToLower().Contains(keyword) || x.SellerName.ToLower().Contains(keyword) || === Ladaer.BackEnd\Infrastructures\Services\Finances\VatInvoiceSyncService.cs === using System.Globalization; using System.Net; using System.Text; using System.Text.Json; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Service `"ng bT hA3a `n VAT t API Tng cc Thu /// public class VatInvoiceSyncService : IVatInvoiceSyncService { private readonly IRepository _repository; private readonly IRepository _syncHistoryRepository; private readonly IRepository _appConfigRepository; private readonly IHttpClientFactory _httpClientFactory; private readonly ILogger _logger; public VatInvoiceSyncService( IRepository repository, IRepository syncHistoryRepository, IRepository appConfigRepository, IHttpClientFactory httpClientFactory, ILogger logger) { _repository = repository; _syncHistoryRepository = syncHistoryRepository; _appConfigRepository = appConfigRepository; _httpClientFactory = httpClientFactory; _logger = logger; } === Ladaer.BackEnd\Infrastructures\Services\Finances\WalletService.cs === using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finances; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { public interface IWalletService { /// /// Tm ki?m v /// /// /// Task> Search(SmartTableParam param); Task GetById(int id, int currentUserId); Task GetWalletByUserId(int userId, int currentUserId); Task> SearchTransactions(SmartTableParam param); /// /// Di?u ch?nh s? du v (cn v) /// Task BalanceAdjustment(int walletId, BalanceAdjustmentModel model); /// /// L?y danh sch v cho suggestion (select control) /// /// T? kha tm ki?m === Ladaer.BackEnd\Infrastructures\Services\Finances\WalletTransferService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Finance.Wallets; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finances; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Finances { /// /// Interface cho service chuyn ti?n gi_a cAc vA- /// public interface IWalletTransferService { /// /// Chuyn ti?n t vA- ngu"n sang vA- `A-ch /// /// ID vA- ngu"n (vA- ca ng?i dA1ng `ang `ng nh-p) /// ThA'ng tin chuyn ti?n /// Kt qu chuyn ti?n Task Transfer(int sourceWalletId, TransferWalletModel model); } /// /// Service x- lA chuyn ti?n gi_a cAc vA- v>i `m bo toAn v1n giao d public class WalletTransferService : IWalletTransferService { private readonly IRepository _walletRepository; private readonly IRepository _transactionRepository; private readonly IRepository _mediaRepository; private readonly IUnifiedMediaService _unifiedMediaService; private const int MaxRetryAttempts = 3; private const int RetryDelayMs = 100; === Ladaer.BackEnd\Infrastructures\Services\FuelCards\FuelCardService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Ladaer.BackEnd.Infrastructures.DTO.Items.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Models.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Results.FuelCards; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.FuelCards; /// /// Interface cho service qun lA th xng du (th tA-n dng) /// public interface IFuelCardService { /// /// TAm kim th xng du v>i phAn trang /// Task> Search(SmartTableParam param); /// /// Ly th xng du theo ID /// Task GetByIdAsync(int id); /// /// To hoc c-p nh-t th xng du /// Task CreateOrUpdateAsync(FuelCardModel model, CurrentUser currentUser); /// /// XA3a th xng du /// Task DeleteAsync(int id, CurrentUser currentUser); /// /// Ly danh sAch th `ang hot `Tng === Ladaer.BackEnd\Infrastructures\Services\FuelCards\FuelCardTransactionService.cs === using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Items.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Models.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.FuelCards; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using System.Globalization; namespace Ladaer.BackEnd.Infrastructures.Services.FuelCards; /// /// Interface cho service qun lA giao d public interface IFuelCardTransactionService { /// /// Import sao kA th tA-n dng t Excel /// Task ImportStatementAsync(FuelCardTransactionImportModel model, CurrentUser currentUser); /// /// TAm kim giao d Task> Search(SmartTableParam param, int? fuelCardId = null); /// /// Ly chi tit giao d Task GetByIdAsync(Guid id); /// /// ?`i soAt giao di ln ` du === Ladaer.BackEnd\Infrastructures\Services\FuelCards\FuelRefillExcelService.cs === using System.Drawing; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Results.FuelCards; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using OfficeOpenXml.Style; namespace Ladaer.BackEnd.Infrastructures.Services.FuelCards { /// /// Interface cho d public interface IFuelRefillExcelService { /// /// Xut Excel l /// Tham s` tAm kim vA s_p xp /// Kt qu xut file Task ExportFuelRefillsAsync(SmartTableParam param); } /// /// D public class FuelRefillExcelService : IFuelRefillExcelService { private readonly IRepository _fuelRefillRepository; private readonly IExcelFileService _excelFileService; public FuelRefillExcelService( IRepository fuelRefillRepository, IExcelFileService excelFileService) { _fuelRefillRepository = fuelRefillRepository; === Ladaer.BackEnd\Infrastructures\Services\FuelCards\FuelRefillService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Finance; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Models.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Models.Trucks; using Ladaer.BackEnd.Infrastructures.Services.Trucks; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.FuelCards; /// /// Interface cho service qun lA vic ` du /// public interface IFuelRefillService { /// /// To hoc c-p nh-t thA'ng tin ` du /// Task CreateOrUpdate(FuelRefillModel model, CurrentUser currentUser); /// /// LAi xe ` du - Upload nh vA t `Tng tA-nh chAnh lch ` [Obsolete("S- dng CreateOrUpdate thay th")] Task RefillFuelAsync(FuelRefillModel model, CurrentUser currentUser); /// /// TAm kim l Task> Search(SmartTableParam param); === Ladaer.BackEnd\Infrastructures\Services\Hr\AttendanceService.cs === using System.Data; using Dapper; using Lada.Framework.Data.Domains.Hr; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Models.Media; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Results.Export; using Ladaer.BackEnd.Infrastructures.DTO.Results.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Results.Media; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using OfficeOpenXml.Style; namespace Ladaer.BackEnd.Infrastructures.Services.Hr { /// /// Giao di?n cho d?ch v? ch?m cng. /// public interface IAttendanceService { /// /// X? ly ch?m cng (Check-in ho?c Check-out) d?a trn tr?ng thi hi?n t?i. /// /// M hnh CheckInOutModel ch?a thng tin ch?m cng. /// K?t qu? ch?m cng v?i thng tin chi ti?t. Task PunchAsync(CheckInOutModel model); /// /// L?y thng tin ch?m cng hi?n t?i c?a ngu?i dng (chua check-out ho?c hm nay) /// /// ID ngu?i dng === Ladaer.BackEnd\Infrastructures\Services\Hr\CandidateService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Hr; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Hr { /// /// Giao di?n cho d?ch v? qu?n ly ?ng vin. /// public interface ICandidateService { /// /// Tm ki?m ?ng vin. /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m ?ng vin. Task> Search(SmartTableParam param); /// /// Xa ?ng vin theo ID. /// /// ID c?a ?ng vin. /// K?t qu? c?a thao tc. Task Delete(int id); /// /// L?y thng tin dnh gi ?ng vin theo ID. /// /// ID c?a ?ng vin. /// Thng tin dnh gi ?ng vin. Task GetReviewModelById(int id); === Ladaer.BackEnd\Infrastructures\Services\Hr\CvUploadService.cs === using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Results.Hr; using Microsoft.Extensions.Options; using ImageMagick; using System.Diagnostics; namespace Ladaer.BackEnd.Infrastructures.Services.Hr { } === Ladaer.BackEnd\Infrastructures\Services\Hr\JobPostService.cs === using Hangfire.Common; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Domains.Hr; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Items.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Models.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Models.Cms; using Ladaer.BackEnd.Infrastructures.DTO.Models.Hr; using Ladaer.BackEnd.Infrastructures.DTO.Results.Hr; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Hosting; namespace Ladaer.BackEnd.Infrastructures.Services.Hr { /// /// Giao di?n cho d?ch v? qu?n ly bi dang tuy?n d?ng. /// public interface IJobPostService { /// /// Tm ki?m cng vi?c. /// /// Thng s? tm ki?m. /// K?t qu? tm ki?m cng vi?c. Task> Search(SmartTableParam param); /// /// T?o ho?c c?p nh?t cng vi?c. /// /// Thng tin cng vi?c. /// K?t qu? c?a thao tc. === Ladaer.BackEnd\Infrastructures\Services\Identity\IPermissionService.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Models.Itentity; using Ladaer.BackEnd.Infrastructures.DTO.Results.Identity; namespace Ladaer.BackEnd.Infrastructures.Services.Identity { /// /// Service interface for managing Permission Groups and Role assignments /// public interface IPermissionService { /// /// To Permission Group m>i /// /// TAn Permission Group /// MA' t /// Danh sAch Role ID /// Permission `A to Task CreatePermissionAsync(string name, string? description, List roleIds); /// /// C-p nh-t Permission Group /// /// ID ca Permission /// TAn m>i /// MA' t m>i /// Danh sAch Role ID m>i /// Permission `A c-p nh-t Task UpdatePermissionAsync(int permissionId, string name, string? description, List roleIds); /// /// XA3a Permission Group /// /// ID ca Permission /// True nu xA3a thAnh cA'ng Task DeletePermissionAsync(int permissionId); /// === Ladaer.BackEnd\Infrastructures\Services\Identity\IRoleMigrationService.cs === using Lada.Framework.Data.Domains.Identity; namespace Ladaer.BackEnd.Infrastructures.Services.Identity { /// /// Service for migrating from old role naming convention to new Controller.Action pattern /// public interface IRoleMigrationService { /// /// To tt c Role m>i theo pattern Controller.Action /// /// Danh sAch Role `A to Task> CreateNewRolesAsync(); /// /// To Permission Groups mc `i cAc vai trA cc /// /// Danh sAch Permission `A to Task> CreateDefaultPermissionGroupsAsync(); /// /// Migration Users t old roles sang Permission Groups /// /// S` lng User `A migration Task MigrateUsersToPermissionGroupsAsync(); /// /// Ly danh sAch Role m>i cn to /// /// Dictionary v>i key lA role name, value lA description Dictionary GetNewRolesToCreate(); /// /// Ly mapping t old roles sang Permission Groups /// /// Dictionary v>i key lA old role, value lA Permission Group name Dictionary GetOldRoleToPermissionMapping(); /// === Ladaer.BackEnd\Infrastructures\Services\Identity\PermissionService.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Models.Itentity; using Ladaer.BackEnd.Infrastructures.DTO.Results.Identity; using Ladaer.BackEnd.Infrastructures.Extensions; using Lada.Framework.Data.Domains; using Lada.Framework.DTO; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Identity { /// /// Service for managing Permission Groups and Role assignments /// public class PermissionService : IPermissionService { private readonly IRepository _permissionRepository; private readonly IRepository _permissionRoleRepository; private readonly UserManager _userManager; private readonly RoleManager _roleManager; private readonly IUserService _userService; public PermissionService( IRepository permissionRepository, IRepository permissionRoleRepository, UserManager userManager, RoleManager roleManager, IUserService userService) { _permissionRepository = permissionRepository; _permissionRoleRepository = permissionRoleRepository; _userManager = userManager; _roleManager = roleManager; _userService = userService; } public async Task CreatePermissionAsync(string name, string? description, List roleIds) { === Ladaer.BackEnd\Infrastructures\Services\Identity\RoleMigrationService.cs === using Lada.Framework.Data.Domains.Identity; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Identity { /// /// Service for migrating from old role naming convention to new Controller.Action pattern /// public class RoleMigrationService : IRoleMigrationService { private readonly RoleManager _roleManager; private readonly UserManager _userManager; private readonly IPermissionService _permissionService; public RoleMigrationService( RoleManager roleManager, UserManager userManager, IPermissionService permissionService) { _roleManager = roleManager; _userManager = userManager; _permissionService = permissionService; } public Dictionary GetNewRolesToCreate() { return new Dictionary { // System Roles { "System.Permission.Manage", "Qun lA Permission Groups" }, { "System.Role.Manage", "Qun lA Roles" }, { "System.User.Manage", "Qun lA Users" }, // Agency Roles { "Agency.View", "Xem thA'ng tin `i lA" }, { "Agency.Create", "To `i lA m>i" }, { "Agency.Update", "C-p nh-t thA'ng tin `i lA" }, { "Agency.Delete", "XA3a `i lA" }, === Ladaer.BackEnd\Infrastructures\Services\Identity\RoleService.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Models.Itentity; using Ladaer.BackEnd.Infrastructures.DTO.Models.Users; using Ladaer.BackEnd.Infrastructures.DTO.Results.Users; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Identity { public interface IRoleService { Task> SearchAsync(SmartTableParam param); Task> GetRolesAsync(int currentUserId); Task GetByIdAsync(int roleId); Task CreateOrUpdateAsync(RoleModel model); Task DeleteAsync(int roleId); Task SetRoleAsync(SetRoleModel model); } public class RoleService : IRoleService { private readonly RoleManager _roleManager; private readonly UserManager _userManager; public RoleService(RoleManager roleManager, UserManager userManager) { _roleManager = roleManager; _userManager = userManager; } public async Task GetByIdAsync(int roleId) { === Ladaer.BackEnd\Infrastructures\Services\Identity\UserService.cs === using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Categories; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Models.Accounts; using Ladaer.BackEnd.Infrastructures.DTO.Models.Users; using Ladaer.BackEnd.Infrastructures.DTO.Results.Accounts; using Ladaer.BackEnd.Infrastructures.DTO.Results.Users; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; using System.Data; using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Security.Cryptography; using System.Text; namespace Ladaer.BackEnd.Infrastructures.Services.Identity { /// /// Giao di?n cho d?ch v? qu?n ly ngu?i dng. /// public interface IUserService { /// /// G?i y ngu?i dng d?a trn t? kha v lo?i ngu?i dng. /// /// T? kha tm ki?m. /// Lo?i ngu?i dng. /// Tn vai tr (ty ch?n). /// Danh sch ngu?i dng g?i y. === Ladaer.BackEnd\Infrastructures\Services\Monitor\OrderRiskService.cs === using System.Data; using Dapper; using Ladaer.BackEnd.Infrastructures.DTO.Models.Monitor; namespace Ladaer.BackEnd.Infrastructures.Services.Monitor { public interface IOrderRiskService { Task GetOrdersWithoutSourceCashierAsync(OrderRiskSearchParam param); Task GetOrderRiskOverviewAsync(DateTime? fromDate = null, DateTime? toDate = null); Task GetOrdersWithoutDestCashierAsync(OrderRiskSearchParam param); Task GetOrderRiskOverviewForDestCashierAsync(DateTime? fromDate = null, DateTime? toDate = null); Task GetOrdersBothPayWithoutCashierAsync(OrderRiskSearchParam param); Task GetOrderRiskOverviewForBothPayAsync(DateTime? fromDate = null, DateTime? toDate = null); } public class OrderRiskService : IOrderRiskService { private readonly IDbConnection _connection; public OrderRiskService(IDbConnection connection) { _connection = connection; } public async Task GetOrdersWithoutSourceCashierAsync(OrderRiskSearchParam param) { var parameters = new DynamicParameters(); if (param.FromDate.HasValue) { parameters.Add("@FromDate", param.FromDate.Value); } if (param.ToDate.HasValue) { parameters.Add("@ToDate", param.ToDate.Value); } parameters.Add("@PageNumber", param.PageNumber > 0 ? param.PageNumber : 1); === Ladaer.BackEnd\Infrastructures\Services\OrderBusiness\OrderFailReasonService.cs === using Lada.Framework.Data.Domains.OrderBusiness; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.OrderBusiness; using Ladaer.BackEnd.Infrastructures.DTO.Models.OrderBusiness; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.OrderBusiness { /// /// Interface qun lA lA do tht bi ly/giao hAng /// public interface IOrderFailReasonService { /// /// TAm kim lA do tht bi /// Task> Search(SmartTableParam param); /// /// To hoc c-p nh-t lA do tht bi /// Task CreateOrUpdate(OrderFailReasonModel model); /// /// Ly thA'ng tin lA do tht bi theo ID /// Task GetById(int id); /// /// XA3a lA do tht bi (soft delete) /// Task Delete(OrderFailReasonModel model); /// /// Ly danh sAch lA do tht bi theo loi (cho Driver App) === Ladaer.BackEnd\Infrastructures\Services\Orders\OrderAddressService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Shared; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; namespace Ladaer.BackEnd.Infrastructures.Services.Orders { /// /// Giao di?n cho d?ch v? qu?n ly d?a ch? don hng. /// public interface IOrderAddressService { /// /// L?y thng tin d?a ch? don hng theo ID. /// /// ID c?a d?a ch? don hng. /// Thng tin d?a ch? don hng. Task GetById(int id); /// /// C?p nh?t thng tin d?a ch? don hng. /// /// Thng tin d?a ch? don hng. /// K?t qu? c?a thao tc. Task Update(UpdateOrderAddressModel model); } /// /// Tri?n khai d?ch v? qu?n ly d?a ch? don hng. /// public class OrderAddressService : IOrderAddressService { === Ladaer.BackEnd\Infrastructures\Services\Orders\OrderFinService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Models; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models.Business.Operations; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Shared; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.Extensions.Options; using Newtonsoft.Json; using static Lada.Framework.Data.Enums.OrderFinEnum; namespace Ladaer.BackEnd.Infrastructures.Services.Orders { /// /// Interface d? d?nh nghia cc phuong th?c x? ly ti chnh don hng. /// public interface IOrderFinService { /// /// C?p nh?t ti chnh don hng khng d?ng b?. /// /// ID c?a don hng. /// ID c?a ngu?i c?p nh?t. /// Tn ngu?i c?p nh?t. /// K?t qu? c?a ho?t d?ng c?p nh?t. Task UpdateOrderFinAsync(int orderId, int updatedBy, string updatedByUserName); /// === Ladaer.BackEnd\Infrastructures\Services\Orders\OrderPackageService.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Enums; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Shared; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; namespace Ladaer.BackEnd.Infrastructures.Services.Orders { /// /// Giao di?n cho d?ch v? qu?n ly ki?n hng trong don hng. /// public interface IOrderPackageService { /// /// L?y thng tin ki?n hng theo ID don hng. /// /// ID c?a don hng. /// Thng tin ki?n hng. Task GetByOrderId(int orderId); /// /// L?y thng tin ki?n hng theo ID don hng v?i thng tin don v? do. /// /// ID c?a don hng. /// Thng tin ki?n hng v?i don v? do. Task GetByOrderIdWithUnits(int orderId); /// /// C?p nh?t thng tin ki?n hng. /// /// Model ch?a thng tin ki?n hng. /// K?t qu? c?a thao tc. === Ladaer.BackEnd\Infrastructures\Services\Orders\OrderService.cs === using Dapper; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using static Lada.Framework.Data.Enums.OrderFinEnum; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.Enums; using Lada.Framework.DTO.Models; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Lada.Framework.Infrastructures.Extensions; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Identity; using Ladaer.BackEnd.Infrastructures.DTO.Items.Medias; using Ladaer.BackEnd.Infrastructures.DTO.Items.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Detail; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders.Updates; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Filters.Orders; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; using System.Collections.Generic; using System.Data; using Lada.Framework.Infrastructures; using Lada.Framework.Infrastructures.Services; using OfficeOpenXml; using OfficeOpenXml.Style; using System.Drawing; using System.ComponentModel; using System.Reflection; namespace Ladaer.BackEnd.Infrastructures.Services.Orders { === Ladaer.BackEnd\Infrastructures\Services\Orders\OrderTrackService.cs === using Hangfire.Storage.Monitoring; using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Hr; using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; namespace Ladaer.BackEnd.Infrastructures.Services.Orders { /// /// Giao di?n cho d?ch v? qu?n ly hnh trnh don hng. /// public interface IOrderTrackService { /// /// T?o m?i hnh trnh don hng. /// /// Thng tin hnh trnh don hng. /// K?t qu? c?a thao tc. Task CreateAsync(OrderTrackModel model); /// /// T?o m?i danh sch hnh trnh don hng. /// /// Danh sch thng tin hnh trnh don hng. /// K?t qu? c?a thao tc. Task CreateAsync(List models); } /// /// Tri?n khai d?ch v? qu?n ly hnh trnh don hng. /// public class OrderTrackService : IOrderTrackService { private readonly IRepository _orderTrackRepository; /// /// Kh?i t?o m?t th? hi?n c?a . === Ladaer.BackEnd\Infrastructures\Services\Orders\Exports\IOrderExportTemplate.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.DTO; using OfficeOpenXml; namespace Ladaer.BackEnd.Infrastructures.Services.Orders.Exports { /// /// Interface cho template xut Excel `n hAng /// /// Loi DTO export public interface IOrderExportTemplate where TExportItem : class { /// /// TAn template /// string TemplateName { get; } /// /// MA' t template /// string Description { get; } /// /// TAn worksheet mc ` string DefaultWorksheetName { get; } /// /// Chuyn `i danh sAch Order thAnh danh sAch DTO export /// /// Danh sAch `n hAng /// Danh sAch DTO export Task> ConvertOrdersToExportItemsAsync(List orders); /// /// Thit l-p header cho Excel /// /// Worksheet void SetupHeaders(ExcelWorksheet worksheet); === Ladaer.BackEnd\Infrastructures\Services\Orders\Exports\OrderExportService.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Items.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Models.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Results.Orders; using Ladaer.BackEnd.Infrastructures.Services.Orders.Exports.Templates; using Microsoft.EntityFrameworkCore; using OfficeOpenXml; using System.Diagnostics; namespace Ladaer.BackEnd.Infrastructures.Services.Orders.Exports { /// /// Interface cho d public interface IOrderExportService { /// /// Xut Excel `n hAng v>i template `c ch% ` /// Model xut Excel /// Kt qu xut file Task ExportOrdersAsync(OrderExportModel model); /// /// Xut Excel `n hAng v>i filter nAng cao /// /// Model xut Excel v>i filter /// Kt qu xut file Task ExportOrdersWithFilterAsync(OrderExportWithFilterModel model); /// /// Ly danh sAch template cA3 sn /// /// Danh sAch template List GetAvailableTemplates(); /// === Ladaer.BackEnd\Infrastructures\Services\Orders\Exports\Templates\BasicOrderExportTemplate.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Orders; using Ladaer.BackEnd.Infrastructures.Services.Identity; using OfficeOpenXml; namespace Ladaer.BackEnd.Infrastructures.Services.Orders.Exports.Templates { /// /// Template xut Excel c bn cho `n hAng /// public class BasicOrderExportTemplate : BaseOrderExportTemplate { private readonly IUserService _userService; public BasicOrderExportTemplate(IUserService userService) { _userService = userService; } public override string TemplateName => "Basic"; public override string Description => "Template xut Excel c bn cho `n hAng"; public override string DefaultWorksheetName => "Danh sAch `n hAng"; public override async Task> ConvertOrdersToExportItemsAsync(List orders) { var exportItems = new List(); // Ly thA'ng tin Sale var saleIds = orders.Where(x => x.SaleId > 0).Select(x => x.SaleId).Distinct().ToList(); var saleUsers = new Dictionary(); if (saleIds.Any()) { var saleItems = await _userService.GetByListIdAsync(saleIds); saleUsers = saleItems.ToDictionary(s => s.Id, s => s.FullName ?? s.UserName); } === Ladaer.BackEnd\Infrastructures\Services\Orders\Exports\Templates\FinanceOrderExportTemplate.cs === using Lada.Framework.Data.Domains.Orders; using Lada.Framework.Data.Enums; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Finance; using Ladaer.BackEnd.Infrastructures.Services.Identity; using OfficeOpenXml; using System.Drawing; namespace Ladaer.BackEnd.Infrastructures.Services.Orders.Exports.Templates { /// /// Template xut Excel cho mc `A-ch tAi chA-nh (TransferPaymentBill) /// public class FinanceOrderExportTemplate : BaseOrderExportTemplate { private readonly IUserService _userService; public FinanceOrderExportTemplate(IUserService userService) { _userService = userService; } public override string TemplateName => "Finance"; public override string Description => "Template xut Excel cho mc `A-ch tAi chA-nh - TransferPaymentBill"; public override string DefaultWorksheetName => "Danh sAch `n hAng - TAi chA-nh"; public override async Task> ConvertOrdersToExportItemsAsync(List orders) { var exportItems = new List(); // Ly thA'ng tin Sale var saleIds = orders.Where(x => x.SaleId > 0).Select(x => x.SaleId).Distinct().ToList(); var saleUsers = new Dictionary(); if (saleIds.Any()) { var saleItems = await _userService.GetByListIdAsync(saleIds); saleUsers = saleItems.ToDictionary(s => s.Id, s => s.FullName ?? s.UserName); } === Ladaer.BackEnd\Infrastructures\Services\Premises\PremiseScoringService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Premises; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.Premises; using Ladaer.BackEnd.Infrastructures.DTO.Models.Premises; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Premises { public interface IPremiseScoringService { Task> SearchCriteria(SmartTableParam param); Task GetCriteriaById(int id); Task CreateOrUpdateCriteria(PremiseScoringCriteriaModel model); Task DeleteCriteria(int id); Task> GetAllActiveCriteria(); } public class PremiseScoringService : IPremiseScoringService { private readonly IRepository _criteriaRepository; private readonly IRepository _optionRepository; public PremiseScoringService( IRepository criteriaRepository, IRepository optionRepository) { _criteriaRepository = criteriaRepository; _optionRepository = optionRepository; } public async Task> SearchCriteria(SmartTableParam param) { var query = _criteriaRepository.Query() .Include(x => x.Options) .Where(x => !x.IsDeleted); === Ladaer.BackEnd\Infrastructures\Services\Premises\PremiseService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Premises; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Items.Premises; using Ladaer.BackEnd.Infrastructures.DTO.Models.Premises; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Results.Premises; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Premises { public interface IPremiseService { Task> Search(SmartTableParam param); Task CreateOrUpdate(PremiseModel model); Task GetById(int id); Task Delete(int id); Task ChangeStatus(PremiseStatusModel model); Task UpdateFinancial(PremiseFinancialModel model); Task DeleteMedia(int premiseMediaId); } public class PremiseService : IPremiseService { private readonly IRepository _repository; private readonly IRepository _contactRepository; private readonly IRepository _scoreRepository; private readonly IRepository _financialRepository; private readonly IRepository _scoringOptionRepository; private readonly IRepository _premiseMediaRepository; private readonly IRepository _mediaRepository; private readonly IUnifiedMediaService _unifiedMediaService; public PremiseService( === Ladaer.BackEnd\Infrastructures\Services\Report\Finance\IncomeExpenseReportService.cs === using Dapper; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models.Finance; using Ladaer.BackEnd.Infrastructures.DTO.Results.Finance; using System.Data; namespace Ladaer.BackEnd.Infrastructures.Services.Report.Finance { /// /// Interface cho service bAo cAo thu chi /// public interface IIncomeExpenseReportService { /// /// Ly bAo cAo thu chi theo khong th?i gian /// /// ThA'ng tin khong th?i gian /// ID ng?i dA1ng /// BAo cAo thu chi Task GetIncomeExpenseReportAsync( IncomeExpenseReportRequest request, int userId); } /// /// Service bAo cAo thu chi /// public class IncomeExpenseReportService : IIncomeExpenseReportService { private readonly IDbConnection _dbConnection; /// /// KhYi to mTt th hin ca . /// /// Kt n`i c sY d_ liu. public IncomeExpenseReportService(IDbConnection dbConnection) { _dbConnection = dbConnection; } === Ladaer.BackEnd\Infrastructures\Services\Report\FuelCards\FuelRefillReportExcelService.cs === using System.Drawing; using Dapper; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Items.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Results.FuelCards; using OfficeOpenXml; using OfficeOpenXml.Style; using System.Data; namespace Ladaer.BackEnd.Infrastructures.Services.Report.FuelCards { /// /// Interface cho d public interface IFuelRefillReportExcelService { /// /// Xut Excel bAo cAo ` du theo lAi xe (nhA3m theo ngAy) /// /// Tham s` tAm kim vA s_p xp /// Kt qu xut file Task ExportByDriverAsync(SmartTableParam param); } /// /// D public class FuelRefillReportExcelService : IFuelRefillReportExcelService { private readonly IDbConnection _dbConnection; private readonly IExcelFileService _excelFileService; public FuelRefillReportExcelService( IDbConnection dbConnection, IExcelFileService excelFileService) { _dbConnection = dbConnection; === Ladaer.BackEnd\Infrastructures\Services\Report\FuelCards\FuelRefillReportService.cs === using Dapper; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Items.FuelCards; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Results; using System.Data; namespace Ladaer.BackEnd.Infrastructures.Services.Report.FuelCards { /// /// Interface cho d public interface IFuelRefillReportService { /// /// Ly bAo cAo ` du theo lAi xe t stored procedure /// /// Tham s` bng thA'ng minh /// Danh sAch bAo cAo ` du theo lAi xe Task GetFuelRefillReportByDriverAsync(SmartTableParam param); } /// /// D public class FuelRefillReportService : IFuelRefillReportService { private readonly IDbConnection _dbConnection; public FuelRefillReportService(IDbConnection dbConnection) { _dbConnection = dbConnection; } /// /// Ly bAo cAo ` du theo lAi xe t stored procedure /// /// Tham s` bng thA'ng minh /// Danh sAch bAo cAo ` du theo lAi xe public async Task GetFuelRefillReportByDriverAsync(SmartTableParam param) === Ladaer.BackEnd\Infrastructures\Services\Report\OperationReports\BranchReportService.cs === === Ladaer.BackEnd\Infrastructures\Services\Report\OperationReports\DriverReportService.cs === using Dapper; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Items.Operations; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Results; using Ladaer.BackEnd.Infrastructures.Services.Identity; using System.Data; namespace Ladaer.BackEnd.Infrastructures.Services.Report.OperationReports { /// /// Interface cho d public interface IDriverReportService { /// /// Ly bAo cAo nng sut lAi xe theo tng ngAy /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng /// Kt qu bAo cAo nng sut lAi xe theo ngAy Task GetDriverProductivityReportByDateAsync( SmartTableParam param, int userId); } /// /// D public class DriverReportService : IDriverReportService { private readonly IDbConnection _dbConnection; private readonly IUserService _userService; /// /// KhYi to mTt th hin ca . /// /// Kt n`i c sY d_ liu. /// Service qun lA ng?i dA1ng. public DriverReportService(IDbConnection dbConnection, IUserService userService) { === Ladaer.BackEnd\Infrastructures\Services\Report\Orders\OrderFinReportService.cs === using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.StoredProcedureResults; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using System.Data; namespace Ladaer.BackEnd.Infrastructures.Services.Report.Orders { /// /// Giao din cho d public interface IOrderFinReportService { /// /// Ly th`ng kA chuyn khon ngAn hAng theo sale /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng hin ti /// Danh sAch th`ng kA chuyn khon theo sale Task> GetBankTransferSummaryBySaleAsync( SmartTableParam param, int userId); } /// /// D public class OrderFinReportService : IOrderFinReportService { private readonly IDbConnection _dbConnection; private readonly IUserService _userService; /// /// KhYi to mTt th hin ca . /// /// Kt n`i c sY d_ liu. === Ladaer.BackEnd\Infrastructures\Services\Report\Orders\OrderReportService.cs === using Dapper; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Items.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Results; using Ladaer.BackEnd.Infrastructures.Services.Identity; using System.Data; using System.Linq; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace Ladaer.BackEnd.Infrastructures.Services.Report.Orders { public interface IOrderReportService { /// /// Ly th`ng kA `n hAng theo ngAy t stored procedure /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng /// Danh sAch th`ng kA `n hAng theo ngAy Task GetOrderProductionAsync(SmartTableParam param, int userId); // ?A chuyn sang ISaleReportService /// /// Ly bAo cAo cA'ng n theo sale t stored procedure /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng /// Danh sAch bAo cAo cA'ng n theo sale Task GetSaleDebtReportAsync(SmartTableParam param, int userId); /// /// Ly bAo cAo s` lng `n vA doanh s` theo tuyn /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng /// Danh sAch bAo cAo theo tuyn vA trng thAi Task GetOrderReportByRouteAsync(SmartTableParam param, int userId); === Ladaer.BackEnd\Infrastructures\Services\Report\SaleReports\SaleReportService.cs === using System.Data; using Dapper; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Items.Orders; using Ladaer.BackEnd.Infrastructures.DTO.Reports.Results; using Ladaer.BackEnd.Infrastructures.Services.Identity; namespace Ladaer.BackEnd.Infrastructures.Services.Report.SaleReports { /// /// Interface d public interface ISaleReportService { /// /// Ly th`ng kA doanh thu theo sale t stored procedure /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng /// Kt qu th`ng kA doanh thu Task GetSaleRevenueStatisticsAsync(SmartTableParam param, int userId); /// /// Ly th`ng kA `n hAng vA doanh thu theo ngAy t stored procedure /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng /// Danh sAch th`ng kA `n hAng vA doanh thu theo ngAy Task GetOrderRevenueStatisticsByDateAsync(SmartTableParam param, int userId); /// /// Ly th`ng kA doanh thu theo ngAy nh-n ti?n t stored procedure /// /// Tham s` bng thA'ng minh /// ID ng?i dA1ng /// Danh sAch th`ng kA doanh thu theo ngAy nh-n ti?n Task GetOrderRevenueByCollectionDateAsync(SmartTableParam param, int userId); /// === Ladaer.BackEnd\Infrastructures\Services\Rewards\AutoPenaltyConfigService.cs === using Lada.Framework.Data.Domains.Rewards; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Items.Rewards; using Microsoft.EntityFrameworkCore; using System.Text.Json; namespace Ladaer.BackEnd.Infrastructures.Services.Rewards { public interface IAutoPenaltyConfigService { /// /// Ly cu hAnh `ang hiu lc /// Task GetCurrentConfig(); /// /// C-p nh-t cu hAnh (to version m>i) /// Task UpdateConfig(AutoPenaltyConfigModel model, CurrentUser currentUser); /// /// Tm dng / MY li /// Task TogglePause(bool isPaused, string? pauseReason, CurrentUser currentUser); /// /// TAm kim danh sAch cu hAnh /// Task> Search(SmartTableParam param); /// /// Ly chi tit cu hAnh theo ID /// Task GetById(int id); === Ladaer.BackEnd\Infrastructures\Services\Rewards\RewardPenaltyService.cs === using Lada.Framework.Data.Domains.Rewards; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Ladaer.BackEnd.Infrastructures.DTO.Items.Rewards; using Ladaer.BackEnd.Infrastructures.DTO.Models.Rewards; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Rewards { public interface IRewardPenaltyService { Task> Search(SmartTableParam param); /// /// To phiu thYng/pht th cA'ng /// Task CreateManual(RewardPenaltyTicketModel model, CurrentUser currentUser); /// /// Duyt phiu /// Task Approve(int id, CurrentUser currentUser); /// /// T ch`i phiu /// Task Reject(int id, CurrentUser currentUser); /// /// G/hy phiu (cA3 gi>i hn amnesty nu lA Auto) /// Task Cancel(int id, string reason, CurrentUser currentUser); /// === Ladaer.BackEnd\Infrastructures\Services\Settings\CallPathService.cs === using Lada.Framework.Data.Domains.Settings; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Settings; using Ladaer.BackEnd.Infrastructures.DTO.Models.Settings; using Ladaer.BackEnd.Infrastructures.DTO; using Microsoft.EntityFrameworkCore; using Lada.Framework.Data.Domains; using Newtonsoft.Json.Linq; using Lada.Framework.Infrastructures.Helpers; namespace Ladaer.BackEnd.Infrastructures.Services.Settings { public interface ICallPathService { /// /// Ly thA'ng tin CallPath theo Id. /// /// Id ca CallPath. /// ThA'ng tin CallPath. Task GetByIdAsync(int id); /// /// To m>i CallPath. /// /// ThA'ng tin CallPath cn to. /// Kt qu ca thao tAc. Task CreateOrUpdateAsync(CallPathModel callPath); /// /// XA3a CallPath. /// /// Id ca CallPath cn xA3a. /// Kt qu ca thao tAc. Task DeleteAsync(int id); /// /// TAm kim CallPath theo `i?u kin l?c vA phAn trang. /// === Ladaer.BackEnd\Infrastructures\Services\Settings\CallPathVersionService.cs === using Lada.Framework.Data.Domains.Settings; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Ladaer.BackEnd.Infrastructures.DTO.Items.Settings; using Ladaer.BackEnd.Infrastructures.DTO.Models.Settings; using Ladaer.BackEnd.Infrastructures.DTO.Profiles; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; using Lada.Framework.Data.Domains; namespace Ladaer.BackEnd.Infrastructures.Services.Settings { public interface ICallPathVersionService { /// /// Ly thA'ng tin CallPathVersion theo Id. /// Task GetByIdAsync(int id); /// /// To m>i hoc c-p nh-t CallPathVersion. /// Task CreateOrUpdateAsync(CallPathVersionModel model); /// /// XA3a CallPathVersion. /// Task DeleteAsync(int id); /// /// TAm kim CallPathVersion theo `i?u kin l?c vA phAn trang. /// Task> SearchAsync(SmartTableParam param); /// /// Ly tt c CallPathVersion (dA1ng cho dropdown). /// Task> GetAllAsync(); } === Ladaer.BackEnd\Infrastructures\Services\Trucks\TruckActivityService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Trucks; using Ladaer.BackEnd.Infrastructures.DTO.Models; using Ladaer.BackEnd.Infrastructures.DTO.Models.Trucks; using Ladaer.BackEnd.Infrastructures.DTO.Results.Trucks; using Ladaer.BackEnd.Infrastructures.DTO.Results.Media; using Lada.Framework.Infrastructures.Services; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Trucks { /// /// Giao di?n cho d?ch v? qu?n ly ho?t d?ng xe t?i. /// public interface ITruckActivityService { /// /// L?y thng tin ho?t d?ng xe t?i theo danh sch ID. /// /// Danh sch ID c?a ho?t d?ng xe t?i. /// K?t qu? ch?a thng tin ho?t d?ng xe t?i. Task GetByIds(KeyModels param); /// /// T?o m?i ho?c c?p nh?t thng tin ho?t d?ng xe t?i. /// /// Thng tin ho?t d?ng xe t?i. /// K?t qu? c?a thao tc. Task CreateOrUpdate(TruckActivityModel param); /// === Ladaer.BackEnd\Infrastructures\Services\Trucks\TruckAssetService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Models; using Ladaer.BackEnd.Infrastructures.DTO.Models.Trucks; using Ladaer.BackEnd.Infrastructures.DTO.Results.Trucks; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Trucks { /// /// Giao di?n cho d?ch v? qu?n ly ti s?n xe t?i. /// public interface ITruckAssetService { /// /// L?y thng tin ti s?n xe t?i theo danh sch ID. /// /// Danh sch ID c?a ti s?n xe t?i. /// K?t qu? ch?a thng tin ti s?n xe t?i. Task GetByIds(KeyModels param); /// /// T?o m?i ho?c c?p nh?t thng tin ti s?n xe t?i. /// /// Thng tin ti s?n xe t?i. /// K?t qu? c?a thao tc. Task CreateOrUpdate(TruckAssetModel param); /// /// Xa thng tin ti s?n xe t?i. /// /// Thng tin ti s?n xe t?i. /// K?t qu? c?a thao tc. Task Delete(TruckModel param); } /// /// Tri?n khai d?ch v? qu?n ly ti s?n xe t?i. === Ladaer.BackEnd\Infrastructures\Services\Trucks\TruckService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Categories; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Domains.Medias; using Lada.Framework.Data.Domains.Trucks; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.DTO.Items.Trucks; using Ladaer.BackEnd.Infrastructures.DTO.Models; using Ladaer.BackEnd.Infrastructures.DTO.Models.Trucks; using Ladaer.BackEnd.Infrastructures.DTO.Results.Trucks; using Microsoft.EntityFrameworkCore; namespace Ladaer.BackEnd.Infrastructures.Services.Trucks { /// /// Giao di?n cho d?ch v? qu?n ly xe t?i. /// public interface ITruckService { #region Truck Management /// /// T?o m?i ho?c c?p nh?t thng tin xe t?i. /// /// Thng tin xe t?i. /// K?t qu? c?a thao tc. Task CreateOrUpdate(TruckModel param); /// /// L?y danh sch media (?nh dang ky, dang ki?m) c?a xe t?i. /// /// ID xe t?i. /// Danh sch media items. Task> GetTruckMediaAsync(int truckId); === Ladaer.BackEnd\Infrastructures\Startup\DependencyRegister.cs === using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.AppSettings; using Lada.Framework.Infrastructures.Extensions; using Lada.Framework.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.Extensions; using Ladaer.BackEnd.Infrastructures.Services; using Ladaer.BackEnd.Infrastructures.Services.Business; using Ladaer.BackEnd.Infrastructures.Services.Categories; using Ladaer.BackEnd.Infrastructures.Services.Cms; using Ladaer.BackEnd.Infrastructures.Services.Crm; using Ladaer.BackEnd.Infrastructures.Services.DriverApp; using Ladaer.BackEnd.Infrastructures.Services.ErrorReports; using Ladaer.BackEnd.Infrastructures.Services.Finance; using Ladaer.BackEnd.Infrastructures.Services.Finances; using Ladaer.BackEnd.Infrastructures.Services.Hr; using Ladaer.BackEnd.Infrastructures.Services.Identity; using Ladaer.BackEnd.Infrastructures.Services.Monitor; using Ladaer.BackEnd.Infrastructures.Services.Orders; using Ladaer.BackEnd.Infrastructures.Services.Orders.Exports; using Ladaer.BackEnd.Infrastructures.Services.Report.Finance; using Ladaer.BackEnd.Infrastructures.Services.Report.OperationReports; using Ladaer.BackEnd.Infrastructures.Services.Report.Orders; using Ladaer.BackEnd.Infrastructures.Services.Report.SaleReports; using Ladaer.BackEnd.Infrastructures.Services.Settings; using Ladaer.BackEnd.Infrastructures.Services.Trucks; using Ladaer.BackEnd.Infrastructures.Services.Premises; using Ladaer.BackEnd.Infrastructures.Services.OrderBusiness; namespace Ladaer.BackEnd.Infrastructures.Startup { /// /// L>p tcnh ` `ng kA cAc ph thuTc cho cng dng. /// public static partial class DependencyRegister { /// /// ?ng kA cAc ph thuTc cho cng dng. /// /// BT su t-p d === Ladaer.BackEnd\Infrastructures\Startup\GeneralRegister.cs === using AutoMapper; using Hangfire; using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Mappings.DbContexts; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.DTO; using Ladaer.BackEnd.Infrastructures.Services; using Microsoft.AspNetCore.Identity; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using System.Data; namespace Ladaer.BackEnd.Infrastructures.Startup { /// /// L>p mY rTng ` `ng kA cAc d public static class GeneralRegister { private static readonly string policyName = "default"; /// /// ?ng kA cAc d /// ?`i tng IServiceCollection. /// ?`i tng IConfiguration. public static void RegisterGeneralServices(this IServiceCollection services, IConfiguration Configuration) { services.AddControllers() .AddNewtonsoftJson(x => { x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; x.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); string connectionString = Configuration.GetConnectionString("LadaConnection"); services.AddDbContext(options => === Ladaer.BackEnd\Infrastructures\Startup\SecurityRegister.cs === using Lada.Framework.Data.Domains.Identity; using Lada.Framework.Data.Mappings.DbContexts; using Lada.Framework.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.AppSettings; using Ladaer.BackEnd.Infrastructures.Authorization; using Ladaer.BackEnd.Infrastructures.IdentityConfigs; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.IdentityModel.Tokens; using System.Security.Claims; using System.Text; namespace Ladaer.BackEnd.Infrastructures.Startup { /// /// L?p m? r?ng d? dang ky cc d?ch v? b?o m?t. /// public static class SecurityRegister { /// /// Dang ky cc d?ch v? b?o m?t. /// /// D?i tu?ng IServiceCollection. /// D?i tu?ng IConfiguration. public static void RegisterSecurityServices(this IServiceCollection services, IConfiguration configuration) { var autConfig = configuration.GetSection("AutConfig").Get(); var jwtSettings = configuration.GetSection("JwtSettings").Get(); var key = Encoding.UTF8.GetBytes(jwtSettings.Secret); services.AddIdentity( options => { #region Password settings // Password settings options.Password.RequireDigit = false; === Ladaer.BackEnd\Infrastructures\Startup\StartupHostedService.cs === using Ladaer.BackEnd.Infrastructures.Services; namespace Ladaer.BackEnd.Infrastructures.Startup { /// /// D?ch v? kh?i d?ng du?c luu tr?. /// public class StartupHostedService : IHostedService { private readonly IServiceProvider _serviceProvider; /// /// Kh?i t?o m?t th? hi?n c?a . /// /// D?i tu?ng IServiceProvider. public StartupHostedService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; } /// /// Phuong th?c du?c g?i khi d?ch v? kh?i d?ng. /// /// D?i tu?ng CancellationToken. /// Nhi?m v? khng d?ng b?. public async Task StartAsync(CancellationToken cancellationToken) { using (var scope = _serviceProvider.CreateScope()) { var appConfigService = scope.ServiceProvider.GetRequiredService(); await appConfigService.LoadConfigsToCacheAsync(); } } /// /// Phuong th?c du?c g?i khi d?ch v? d?ng. /// /// D?i tu?ng CancellationToken. /// Nhi?m v? hon thnh. public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; === Ladaer.BackEnd\Infrastructures\Startup\SwaggerRegister.cs === using Lada.Framework.Swaggers; using Microsoft.OpenApi.Models; using System.Reflection; namespace Ladaer.BackEnd.Infrastructures.Startup { /// /// L?p m? r?ng d? dang ky cc d?ch v? v middleware c?a Swagger. /// public static class SwaggerRegister { /// /// Dang ky cc d?ch v? c?a Swagger. /// /// D?i tu?ng IServiceCollection. public static void RegisterSwaggerServices(this IServiceCollection services) { var jwtScheme = new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, Scheme = "bearer", BearerFormat = "JWT", In = ParameterLocation.Header, Name = "Authorization", Description = "Ch? dn token (khng c?n 'Bearer ').", Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } }; services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "LADAER API", Version = "v1" }); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); c.AddSecurityDefinition("Bearer", jwtScheme); c.AddSecurityRequirement(new OpenApiSecurityRequirement { === ladaexpress.vn\appsettings.Development.json === { "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } } } === ladaexpress.vn\appsettings.json === { "ConnectionStrings": { "LadaConnection": "Server=THANGTQ1009\\SQL19;Database=Ladaer2;User Id=ladadbm;Password=0gcHVHvCyuZTbKw;MultipleActiveResultSets=true;TrustServerCertificate=true" }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "SeoSettings": { "BaseUrl": "https://ladaexpress.vn", "SiteName": "LADA Express", "DefaultImage": "/images/logo.svg", "DefaultTitle": "LADA Express - D(); var app = builder.Build(); app.ConfigAndRunApp(); === ladaexpress.vn\Controllers\CandidateController.cs === using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO.Models.Hr; using ladaexpress.vn.Infrastructures.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; using System.Linq; namespace ladaexpress.vn.Controllers { [Route("api/[controller]")] [ApiController] public class CandidateController : ControllerBase { private readonly ICandidateService _candidateService; public CandidateController(ICandidateService candidateService) { _candidateService = candidateService; } [HttpPost("Apply")] public async Task Apply([FromForm] ApplyModel applyModel) { var result = new BaseResult(); if (!ModelState.IsValid) { //IEnumerable allErrors = ModelState.Values.SelectMany(v => v.Errors); var allErrors = ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage)).ToList(); result.Result = Result.Failed; result.Message = string.Join("\n", allErrors); return Ok(result); } result = await _candidateService.Apply(applyModel); return Ok(result); } === ladaexpress.vn\Controllers\CategoryController.cs === using ladaexpress.vn.Infrastructures.Services; using ladaexpress.vn.Infrastructures.Services.Seo; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class CategoryController : Controller { private readonly ICategoryService _categoryService; private readonly ISeoService _seoService; private readonly IStructuredDataService _structuredDataService; public CategoryController( ICategoryService categoryService, ISeoService seoService, IStructuredDataService structuredDataService) { _categoryService = categoryService; _seoService = seoService; _structuredDataService = structuredDataService; } public async Task Detail(int id) { var model = await _categoryService.PrepareCategoryDetail(id); if (model.Id > 0) { // Generate SEO data for category page var seoData = await _seoService.GetCategorySeoAsync( categoryId: model.Id, name: model.Name, description: model.Description, url: $"/danh-muc/{id}" // Can be improved with slug if available ); // Generate structured data for collection page var structuredData = await _structuredDataService.GetCollectionPageStructuredDataAsync( categoryId: model.Id, name: model.Name, description: model.Description, === ladaexpress.vn\Controllers\CompanyController.cs === using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class CompanyController : Controller { public IActionResult AboutUs() { return View(); } } } === ladaexpress.vn\Controllers\HomeController.cs === using ladaexpress.vn.Infrastructures.Services; using ladaexpress.vn.Infrastructures.Services.Seo; using ladaexpress.vn.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; namespace ladaexpress.vn.Controllers { public class HomeController : Controller { private readonly IHomeService _homeService; private readonly ISeoService _seoService; private readonly IStructuredDataService _structuredDataService; public HomeController(IHomeService homeService, ISeoService seoService, IStructuredDataService structuredDataService) { _homeService = homeService; _seoService = seoService; _structuredDataService = structuredDataService; } public async Task Index() { var model = await _homeService.PrepareHomeModel(); // Set up SEO data for home page var seoData = await _seoService.GetHomePageSeoAsync(); ViewData["SeoData"] = seoData; // Set up structured data var organizationSchema = _structuredDataService.GenerateOrganizationSchema(); var websiteSchema = _structuredDataService.GenerateWebsiteSchema(); var breadcrumbSchema = _structuredDataService.GenerateBreadcrumbSchema(seoData.Breadcrumbs); var combinedSchema = _structuredDataService.CombineSchemas(organizationSchema, websiteSchema, breadcrumbSchema); ViewData["StructuredData"] = combinedSchema; return View(model); } === ladaexpress.vn\Controllers\JobPostController.cs === using ladaexpress.vn.Infrastructures.Services; using ladaexpress.vn.Infrastructures.Services.Seo; using ladaexpress.vn.Infrastructures.DTO.Models.Seo; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class JobPostController : Controller { private readonly IJobService _jobPostService; private readonly ISeoService _seoService; private readonly IStructuredDataService _structuredDataService; private readonly IBreadcrumbService _breadcrumbService; private readonly IContentOptimizationService _contentOptimizationService; public JobPostController( IJobService jobPostService, ISeoService seoService, IStructuredDataService structuredDataService, IBreadcrumbService breadcrumbService, IContentOptimizationService contentOptimizationService) { _jobPostService = jobPostService; _seoService = seoService; _structuredDataService = structuredDataService; _breadcrumbService = breadcrumbService; _contentOptimizationService = contentOptimizationService; } public async Task Index() { var model = await _jobPostService.PrepareJobListModel(); // Generate SEO data for job listing page var seoData = await _seoService.GetJobPostIndexSeoAsync(); // Generate structured data for job listing page var structuredData = await _structuredDataService.GetCollectionPageStructuredDataAsync( === ladaexpress.vn\Controllers\LeadController.cs === using Lada.Framework.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Service; using ladaexpress.vn.Infrastructures.DTO.Results.Crm; using ladaexpress.vn.Infrastructures.Services; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; namespace ladaexpress.vn.Controllers { public class LeadController : Controller { private readonly ILeadService _leadService; public LeadController(ILeadService leadService) { _leadService = leadService; } public IActionResult Index() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public async Task SendAsync(LeadModel model, string returnUrl = null) { var result = new LeadResult(); if (!ModelState.IsValid) { var errors = ModelState .Where(x => x.Value.Errors.Count > 0) .ToDictionary( kvp => kvp.Key, kvp => kvp.Value.Errors[0].ErrorMessage ); return Json(new { success = false, errors }); } === ladaexpress.vn\Controllers\PostController.cs === using ladaexpress.vn.Infrastructures.Services; using ladaexpress.vn.Infrastructures.Services.Seo; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class PostController : Controller { private readonly IPostService _postService; private readonly ISeoService _seoService; private readonly IStructuredDataService _structuredDataService; private readonly IContentOptimizationService _contentOptimizationService; public PostController( IPostService postService, ISeoService seoService, IStructuredDataService structuredDataService, IContentOptimizationService contentOptimizationService) { _postService = postService; _seoService = seoService; _structuredDataService = structuredDataService; _contentOptimizationService = contentOptimizationService; } public async Task Index() { var model = await _postService.PreparePostIndex(); // Generate SEO data for news listing page var seoData = await _seoService.GetCategorySeoAsync( categoryId: 0, // News listing page doesn't have specific category name: "Tin t?c", description: "C?p nh?t tin t?c m?i nh?t v? d?ch v? v?n chuy?n, logistics v xu hu?ng ngnh t? LADA Express.", url: "/tin-tuc" ); // Generate structured data for news collection page var structuredData = await _structuredDataService.GetCollectionPageStructuredDataAsync( categoryId: 0, === ladaexpress.vn\Controllers\PrivacyController.cs === using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class PrivacyController : Controller { public IActionResult ConditionOfUse() { return View(); } public IActionResult SecurityPrivacy() { return View(); } } } === ladaexpress.vn\Controllers\ProductController.cs === using Lada.Framework.Data.Enums; using ladaexpress.vn.Infrastructures.Services; using ladaexpress.vn.Infrastructures.Services.Seo; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class ProductController : Controller { private readonly IProductService _productService; private readonly ISeoService _seoService; private readonly IStructuredDataService _structuredDataService; private readonly IContentOptimizationService _contentOptimizationService; public ProductController( IProductService productService, ISeoService seoService, IStructuredDataService structuredDataService, IContentOptimizationService contentOptimizationService) { _productService = productService; _seoService = seoService; _structuredDataService = structuredDataService; _contentOptimizationService = contentOptimizationService; } public async Task Index() { var model = await _productService.PrepareProductIndex(); // Generate SEO data for products listing page var seoData = await _seoService.GetProductIndexSeoAsync(); // Generate structured data for collection page var structuredData = await _structuredDataService.GetCollectionPageStructuredDataAsync( categoryId: 0, name: "D?ch v? LADA Express", description: "Danh sch cc d?ch v? v?n chuy?n c?a LADA Express", url: "/dich-vu", === ladaexpress.vn\Controllers\ServiceController.cs === using ladaexpress.vn.Infrastructures.Services; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class ServiceController : Controller { private readonly IServiceService _serviceService; public ServiceController(IServiceService serviceService) { _serviceService = serviceService; } public async Task Index() { var model = await _serviceService.PrepareServiceModel(); return View(model); } } } === ladaexpress.vn\Controllers\SharedController.cs === using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class SharedController : Controller { public IActionResult Index() { return View(); } } } === ladaexpress.vn\Controllers\StatusController.cs === using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class StatusController : Controller { public IActionResult NotFound() { return View(); } [Route("/Status/HandleError/{code:int}")] public IActionResult HandleError(int code) { switch (code) { case 404: return RedirectToAction("NotFound"); default: break; } ViewData["ErrorMessage"] = $"Error occurred. The ErrorCode is: {code}"; return View(); } } } === ladaexpress.vn\Controllers\TagController.cs === using ladaexpress.vn.Infrastructures.Services; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class TagController : Controller { private readonly ITagService _tagService; public TagController(ITagService tagService) { _tagService = tagService; } public async Task Index() { return View(); //var model = await _tagService.PrepareTagDetail(); //if (model.Id > 0) //{ // return View(model); //} //else //{ // return NotFound(); //} } public async Task Detail(int id) { var model = await _tagService.PrepareTagDetail(id); if (model.Id > 0) { return View(model); } else { return NotFound(); === ladaexpress.vn\Controllers\TopicController.cs === using ladaexpress.vn.Infrastructures.Services; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class TopicController : Controller { private readonly ITopicService _topicService; public TopicController(ITopicService topicService) { _topicService = topicService; } public async Task Detail(int id) { var model = await _topicService.PrepareTopicDetail(id); if (model.Id > 0) { return View(model); } else { return NotFound(); } } } } === ladaexpress.vn\Controllers\UrlRecordController.cs === using ladaexpress.vn.Infrastructures.Services; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace ladaexpress.vn.Controllers { public class UrlRecordController : Controller { private readonly IUrlRecordService _urlRecordService; private readonly ISitemapService _sitemapService; public UrlRecordController(IUrlRecordService urlRecordService, ISitemapService sitemapService) { _urlRecordService = urlRecordService; _sitemapService = sitemapService; } [HttpGet("SiteMapXml")] public async Task SiteMapXml() { // Use the new SitemapService with image support var siteMap = await _sitemapService.GenerateSitemapXmlAsync(); // Set proper headers to prevent script injection Response.Headers["Cache-Control"] = "public, max-age=3600"; Response.Headers["X-Content-Type-Options"] = "nosniff"; return Content(siteMap, "application/xml; charset=utf-8"); } [HttpGet("Robot")] public async Task Robot() { var robots = await _urlRecordService.GenerateRobots(); return Content(robots, "text/plain"); } } } === ladaexpress.vn\docs\SitemapService_Test_Results.md === # SitemapService Refactoring Test Results ## NgAy thc hin: 2025-08-16 ## Mc tiAu Refactor SitemapService ` ly d_ liu t bng UrlRecord thay vA t cAc bng thc th (Post, Product, Category, Tag). ## Thay `i `A thc hin ### 1. Thay `i Dependencies - **Tr>c:** Inject 4 repositories: `IRepository`, `IRepository`, `IRepository`, `IRepository` - **Sau:** Ch% inject 1 repository: `IRepository` ### 2. ThAm Helper Method ```csharp private string ConvertFrequencyToString(SitemapFrequency frequency) { return frequency switch { SitemapFrequency.Never => "never", SitemapFrequency.Yearly => "yearly", SitemapFrequency.Monthly => "monthly", SitemapFrequency.Weekly => "weekly", SitemapFrequency.Daily => "daily", SitemapFrequency.Hourly => "hourly", SitemapFrequency.Always => "always", _ => "monthly" }; } ``` ### 3. S-a `i cAc phng thcc ly d_ liu #### GetStaticPagesSitemapAsync() - **Tr>c:** Hardcode danh sAch static pages - **Sau:** Query t UrlRecord v>i `i?u kin tt c foreign keys = null === ladaexpress.vn\Infrastructures\DTO\Models\Service\LeadModel.cs === using Microsoft.AspNetCore.Mvc.ModelBinding; using System.ComponentModel.DataAnnotations; namespace ladaexpress.vn.Infrastructures.DTO.Models.Service { [Serializable] public class LeadModel { [Required(ErrorMessage = "Vui lng nh?p h? tn")] [Display(Name = "H? v tn")] [StringLength(100, MinimumLength = 2, ErrorMessage = "H? tn ph?i c t? 2 d?n 100 ky t?")] public string FullName { get; set; } [Required(ErrorMessage = "Vui lng nh?p s? di?n tho?i")] [Display(Name = "S? di?n tho?i")] [RegularExpression(@"^(0[0-9]{9,10})$", ErrorMessage = "S? di?n tho?i khng h?p l? (ph?i b?t d?u b?ng s? 0 v c 10-11 s?)")] public string PhoneNumber { get; set; } [Required(ErrorMessage = "Vui lng nh?p n?i dung yu c?u")] [Display(Name = "N?i dung yu c?u")] [StringLength(1000, MinimumLength = 10, ErrorMessage = "N?i dung yu c?u ph?i c t? 10 d?n 1000 ky t?")] [DataType(DataType.MultilineText)] public string Message { get; set; } public string SourcePath { get; set; } = string.Empty; } } === ladaexpress.vn\Infrastructures\DTO\Models\Service\ServiceModel.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index.Childs; namespace ladaexpress.vn.Infrastructures.DTO.Models.Service { public class ServiceModel { public ServiceModel() { LatestPosts = new List(); } /// /// Cc bi vi?t m?i nh?t /// public List LatestPosts { get; set; } } } === ladaexpress.vn\Infrastructures\Extensions\ServiceCollectionExtensions.cs === using ladaexpress.vn.Infrastructures.Startup; namespace Microsoft.Extensions.DependencyInjection { public static class ServiceCollectionExtensions { public static IServiceCollection AddStartupTasks(this IServiceCollection services) { services.AddTransient(); services.AddTransient(); return services; } } } === ladaexpress.vn\Infrastructures\Services\AppConfigService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Repositories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; namespace ladaexpress.vn.Infrastructures.Services { /// /// Implementation ca AppConfigService cho ladaexpress.vn /// public class AppConfigService : IAppConfigService { private readonly IRepository _appConfigRepository; private readonly IMemoryCache _memoryCache; private readonly string _cacheKeyPrefix = "WebAppConfig_"; private readonly ILogger _logger; public AppConfigService( IRepository appConfigRepository, IMemoryCache memoryCache, ILogger logger) { _appConfigRepository = appConfigRepository; _memoryCache = memoryCache; _logger = logger; } public async Task GetConfigValueAsync(string key) { try { var cacheKey = $"{_cacheKeyPrefix}{key}"; if (!_memoryCache.TryGetValue(cacheKey, out string? value)) { var config = await _appConfigRepository.Query() .FirstOrDefaultAsync(c => c.Key == key); if (config != null) { === ladaexpress.vn\Infrastructures\Services\BreadcrumbService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; namespace ladaexpress.vn.Infrastructures.Services { /// /// Implementation ca IBreadcrumbService v>i cache support /// public class BreadcrumbService : IBreadcrumbService { private readonly IAppConfigService _appConfigService; private readonly IMemoryCache _memoryCache; private readonly IConfiguration _configuration; private readonly ILogger _logger; private readonly string _baseUrl; private readonly string _cacheKeyPrefix = "Breadcrumb_"; public BreadcrumbService( IAppConfigService appConfigService, IMemoryCache memoryCache, IConfiguration configuration, ILogger logger) { _appConfigService = appConfigService; _memoryCache = memoryCache; _configuration = configuration; _logger = logger; _baseUrl = _configuration["SeoSettings:BaseUrl"] ?? "https://ladaexpress.vn"; } public async Task> GetHomeBreadcrumbsAsync() { var cacheKey = $"{_cacheKeyPrefix}Home"; if (_memoryCache.TryGetValue(cacheKey, out List? cached) && cached != null) { return cached; } === ladaexpress.vn\Infrastructures\Services\CandidateService.cs === using Lada.Framework.Data.Domains; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Domains.Hr; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using Lada.Framework.Infrastructures.Services; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Hr; using ladaexpress.vn.Infrastructures.DTO.Results.Hr; using Microsoft.EntityFrameworkCore; using System; using System.Threading.Tasks; namespace ladaexpress.vn.Infrastructures.Services { public interface ICandidateService { Task Apply(ApplyModel mode); } public class CandidateService : ICandidateService { private readonly IRepository _candidateRepository; private readonly ICvUploadService _cvUploadService; public CandidateService(IRepository candidateRepository, ICvUploadService cvUploadService) { _candidateRepository = candidateRepository; _cvUploadService = cvUploadService; } public async Task Apply(ApplyModel model) { var result = new ApplyResult(); try { // Ki?m tra ?ng tuy?n trng l?p (cng JobId v PhoneNumber) var existingApplication = await _candidateRepository.Query() .Include(c => c.Job) .FirstOrDefaultAsync(c => c.JobId == model.JobPostId && c.PhoneNumber == model.PhoneNumber); === ladaexpress.vn\Infrastructures\Services\CategoryService.cs === using Dapper; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Categories; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index.Childs; using ladaexpress.vn.Infrastructures.DTO.Models.Product.Index.Childs; using Microsoft.EntityFrameworkCore; using System.Data; using System.Data.Common; namespace ladaexpress.vn.Infrastructures.Services { public interface ICategoryService { Task PrepareCategoryDetail(int id); } public class CategoryService : ICategoryService { private readonly IRepository _categoryRepository; private readonly IDbConnection _dbConnection; public CategoryService(IRepository categoryRepository, IDbConnection dbConnection) { _categoryRepository = categoryRepository; _dbConnection = dbConnection; } public async Task PrepareCategoryDetail(int id) { var model = new CategoryDetailModel(); var currentTime = DateTimeHelper.CurrentTime(); var category = await _categoryRepository.Query().FirstOrDefaultAsync(c => c.Id == id); if (category != null && category.Id > 0) { model.ContentType = category.ContentType; === ladaexpress.vn\Infrastructures\Services\ContentOptimizationService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using System.Text.RegularExpressions; using System.Text; using System.Globalization; namespace ladaexpress.vn.Infrastructures.Services { /// /// Implementation ca IContentOptimizationService /// public class ContentOptimizationService : IContentOptimizationService { private readonly IAppConfigService _appConfigService; private readonly IMemoryCache _memoryCache; private readonly IConfiguration _configuration; private readonly ILogger _logger; private readonly string _cacheKeyPrefix = "ContentOpt_"; // Common Vietnamese stop words private readonly HashSet _vietnameseStopWords = new HashSet { "vA", "ca", "cA3", "lA", "`c", "cAc", "cho", "trong", "v>i", "v?", "t", "`", "khi", "khA'ng", "nAy", "`A", "s", "ccng", "nh", "mTt", "nh_ng", "nhi?u", "hay", "hoc", "nhng", "mA", "nu", "thA", "vA", "do", "nAn", "r"i", "`Ay", "`A3", "ti", "theo", "sau", "tr>c", "gi_a", "d>i", "trAn", "ngoAi", "trong", "bAn", "cnh" }; public ContentOptimizationService( IAppConfigService appConfigService, IMemoryCache memoryCache, IConfiguration configuration, ILogger logger) { _appConfigService = appConfigService; _memoryCache = memoryCache; _configuration = configuration; _logger = logger; } public async Task GenerateOptimizedTitleAsync(string baseTitle, string contentType, string? keywords = null) === ladaexpress.vn\Infrastructures\Services\HomeService.cs === using Dapper; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using ladaexpress.vn.Infrastructures.DTO.Models.Home; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index.Childs; using System.Data; namespace ladaexpress.vn.Infrastructures.Services { public interface IHomeService { /// /// Home Model /// /// /// Task PrepareHomeModel(); } public class HomeService : IHomeService { private readonly IRepository _postRepository; private readonly IDbConnection _dbConnection; public HomeService(IRepository postRepository, IRepository urlRecordRepository, IRepository categoryRepository, IDbConnection dbConnection) { _postRepository = postRepository; _dbConnection = dbConnection; } public async Task PrepareHomeModel() { var model = new HomeModel(); try { model.LatestPosts = (await _dbConnection.QueryAsync("Home_GetLatestPosts", commandType: CommandType.StoredProcedure)).ToList(); === ladaexpress.vn\Infrastructures\Services\IAppConfigService.cs === using Lada.Framework.Data.Domains; namespace ladaexpress.vn.Infrastructures.Services { /// /// Interface cho service qun lA cu hAnh cng dng ladaexpress.vn /// public interface IAppConfigService { /// /// Ly giA tr< cu hAnh theo key /// /// Key cu hAnh /// GiA tr< cu hAnh Task GetConfigValueAsync(string key); /// /// Ly giA tr< cu hAnh theo key v>i giA tr< mc ` /// Key cu hAnh /// GiA tr< mc ` /// GiA tr< cu hAnh hoc giA tr< mc ` Task GetConfigValueAsync(string key, string defaultValue); /// /// Load tt c configs vAo cache /// /// Task LoadConfigsToCacheAsync(); /// /// Reload config cache /// /// Task ReloadConfigCacheAsync(); /// /// Invalidate cache cho mTt key c th /// /// Key cn xA3a cache === ladaexpress.vn\Infrastructures\Services\IBreadcrumbService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; namespace ladaexpress.vn.Infrastructures.Services { /// /// Service chuyAn dng cho qun lA breadcrumb /// public interface IBreadcrumbService { /// /// To breadcrumbs cho trang ch /// /// Task> GetHomeBreadcrumbsAsync(); Task> GetProductIndexBreadcrumbsAsync(); Task> GetJobPostIndexBreadcrumbsAsync(); /// /// To breadcrumbs cho trang sn phcm /// /// ID sn phcm /// TAn sn phcm /// URL sn phcm /// TAn danh mc (optional) /// URL danh mc (optional) /// Task> GetProductBreadcrumbsAsync(int productId, string productName, string productUrl, string? categoryName = null, string? categoryUrl = null); /// /// To breadcrumbs cho trang tin tcc /// /// ID bAi vit /// TiAu `? bAi vit /// URL bAi vit /// TAn danh mc (optional) /// URL danh mc (optional) /// Task> GetPostBreadcrumbsAsync(int postId, string postTitle, string postUrl, string? categoryName = null, string? categoryUrl = null); === ladaexpress.vn\Infrastructures\Services\IContentOptimizationService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; namespace ladaexpress.vn.Infrastructures.Services { /// /// Service ` t`i u nTi dung vA meta data /// public interface IContentOptimizationService { /// /// To meta title `c t`i u cho SEO /// /// TiAu `? g`c /// Loi nTi dung (product, post, category, etc.) /// T khA3a chA-nh (optional) /// Meta title `A t`i u Task GenerateOptimizedTitleAsync(string baseTitle, string contentType, string? keywords = null); /// /// To meta description `c t`i u /// /// NTi dung g`c /// Loi nTi dung /// ?T dAi mc tiAu (default: 155) /// Meta description `A t`i u Task GenerateOptimizedDescriptionAsync(string content, string contentType, int targetLength = 155); /// /// To keywords t nTi dung /// /// TiAu `? /// NTi dung /// S` lng keywords t`i `a /// Danh sAch keywords Task> ExtractKeywordsAsync(string title, string content, int maxKeywords = 10); /// /// T`i u nTi dung cho SEO /// /// NTi dung HTML === ladaexpress.vn\Infrastructures\Services\IRobotsService.cs === namespace ladaexpress.vn.Infrastructures.Services { /// /// Service ` to vA qun lA robots.txt /// public interface IRobotsService { /// /// To nTi dung robots.txt /// /// NTi dung robots.txt Task GenerateRobotsTxtAsync(); /// /// To robots.txt cho development environment /// /// NTi dung robots.txt cho dev Task GenerateDevRobotsTxtAsync(); /// /// To robots.txt cho production environment /// /// NTi dung robots.txt cho production Task GenerateProdRobotsTxtAsync(); /// /// Validate robots.txt syntax /// /// NTi dung robots.txt /// Danh sAch l-i List ValidateRobotsTxt(string robotsTxt); /// /// Lu robots.txt vAo file /// /// NTi dung /// ??ng dn file Task SaveRobotsTxtAsync(string robotsTxt); /// === ladaexpress.vn\Infrastructures\Services\ISitemapService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; namespace ladaexpress.vn.Infrastructures.Services { /// /// Service ` to vA qun lA sitemap.xml /// public interface ISitemapService { /// /// To sitemap.xml hoAn ch%nh /// /// XML content ca sitemap Task GenerateSitemapXmlAsync(); /// /// To sitemap index cho cAc sitemap con /// /// XML content ca sitemap index Task GenerateSitemapIndexXmlAsync(); /// /// To sitemap cho static pages /// /// Danh sAch SitemapItem cho static pages Task> GetStaticPagesSitemapAsync(); /// /// To sitemap cho products/services /// /// Danh sAch SitemapItem cho products Task> GetProductsSitemapAsync(); /// /// To sitemap cho posts/news /// /// Danh sAch SitemapItem cho posts Task> GetPostsSitemapAsync(); /// === ladaexpress.vn\Infrastructures\Services\JobService.cs === using Dapper; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Domains.Hr; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Hr; using Microsoft.EntityFrameworkCore; using System.Data; namespace ladaexpress.vn.Infrastructures.Services { public interface IJobService { public Task PrepareJobListModel(); Task PrepareJobDetailModel(int id); } public class JobService : IJobService { private readonly IRepository _jobPostRepository; private readonly IDbConnection _dbConnection; private readonly IRepository _urlRecordRepository; public JobService(IRepository jobPostRepository, IDbConnection dbConnection, IRepository urlRecordRepository) { _jobPostRepository = jobPostRepository; _dbConnection = dbConnection; _urlRecordRepository = urlRecordRepository; } public async Task PrepareJobListModel() { var model = new JobListModel(); var currentTime = DateTimeHelper.CurrentTime(); var newTime = currentTime.AddDays(-3);//Nh?ng bi vi?t c ngy xu?t b?n 3 ngy tr? v? dy du?c coi l bi vi?t m?i model.JobPosts = await PrepareJobPosts(); model.TotalJob = await PrepareTotalJobs(); === ladaexpress.vn\Infrastructures\Services\LeadService.cs === using Lada.Framework.Data.Domains.Crm; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Service; using ladaexpress.vn.Infrastructures.DTO.Results.Crm; namespace ladaexpress.vn.Infrastructures.Services { public interface ILeadService { /// /// T?o lead. /// /// Thng tin lead. /// K?t qu? c?a thao tc. Task Create(LeadModel model); } public class LeadService : ILeadService { private readonly IRepository _leadRepository; public LeadService(IRepository leadRepository) { _leadRepository = leadRepository; } public async Task Create(LeadModel model) { var result = new LeadResult(); var currentTime = DateTimeHelper.CurrentTime(); var lead = model.ToEntity(); lead.CreatedTime = currentTime; lead.UpdatedTime = currentTime; try { === ladaexpress.vn\Infrastructures\Services\PostService.cs === using Dapper; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.DTO.SmartTable; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Detail; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index.Childs; using Microsoft.EntityFrameworkCore; using System.Data; using System.Text.RegularExpressions; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace ladaexpress.vn.Infrastructures.Services { public interface IPostService { /// /// Tm ki?m bi vi?t /// /// /// Task PreparePostIndex(); Task PreparePostDetail(int id); /// /// T?o / c?p nh?t bi vi?t /// /// /// /// /// //Task CreateOrUpdate(PostModel model); /// /// L?y thng tin bi vi?t qua Id /// === ladaexpress.vn\Infrastructures\Services\ProductService.cs === using Dapper; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Detail; using ladaexpress.vn.Infrastructures.DTO.Models.Product.Index; using ladaexpress.vn.Infrastructures.DTO.Models.Product.Index.Childs; using ladaexpress.vn.Infrastructures.DTO.Models.Products.Detail; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Hosting; using System.Data; using System.Text.RegularExpressions; namespace ladaexpress.vn.Infrastructures.Services { public interface IProductService { /// /// Tm ki?m bi vi?t /// /// /// Task PrepareProductIndex(); Task PrepareProductDetail(int id); /// /// T?o / c?p nh?t bi vi?t /// /// /// /// /// //Task CreateOrUpdate(ProductModel model); /// /// L?y thng tin bi vi?t qua Id /// /// === ladaexpress.vn\Infrastructures\Services\RobotsService.cs === using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System.Text; namespace ladaexpress.vn.Infrastructures.Services { /// /// Implementation ca IRobotsService /// public class RobotsService : IRobotsService { private readonly IAppConfigService _appConfigService; private readonly IConfiguration _configuration; private readonly IHostEnvironment _hostEnvironment; private readonly ILogger _logger; private readonly string _baseUrl; public RobotsService( IAppConfigService appConfigService, IConfiguration configuration, IHostEnvironment hostEnvironment, ILogger logger) { _appConfigService = appConfigService; _configuration = configuration; _hostEnvironment = hostEnvironment; _logger = logger; _baseUrl = _configuration["SeoSettings:BaseUrl"] ?? "https://ladaexpress.vn"; } public async Task GenerateRobotsTxtAsync() { try { if (_hostEnvironment.IsDevelopment()) { return await GenerateDevRobotsTxtAsync(); } else === ladaexpress.vn\Infrastructures\Services\ScriptConfigService.cs === using System.Collections.Generic; using System.Threading.Tasks; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Microsoft.EntityFrameworkCore; using ladaexpress.vn.Infrastructures.Stores; namespace ladaexpress.vn.Infrastructures.Services { public interface IScriptConfigService { Task> GetScriptsByPosition(ScriptPosition position); } public class ScriptConfigService : IScriptConfigService { public Task> GetScriptsByPosition(ScriptPosition position) { var scripts = ScriptConfigStore.AllScripts .Where(x => x.IsActive && x.Position == position) .Select(x => x.ScriptContent) .ToList(); return Task.FromResult(scripts); } } } === ladaexpress.vn\Infrastructures\Services\ServiceService.cs === using Dapper; using ladaexpress.vn.Infrastructures.DTO.Models.Home; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index.Childs; using ladaexpress.vn.Infrastructures.DTO.Models.Service; using System.Data; namespace ladaexpress.vn.Infrastructures.Services { public interface IServiceService { /// /// Home Model /// /// /// Task PrepareServiceModel(); } public class ServiceService : IServiceService { private readonly IDbConnection _dbConnection; public ServiceService(IDbConnection dbConnection) { _dbConnection = dbConnection; } public async Task PrepareServiceModel() { var model = new ServiceModel(); try { model.LatestPosts = (await _dbConnection.QueryAsync("Home_GetLatestPosts", commandType: CommandType.StoredProcedure)).ToList(); } catch (Exception) { } === ladaexpress.vn\Infrastructures\Services\SitemapService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using System.Text; using System.Xml; using System.Xml.Linq; using Lada.Framework.Data.Repositories; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Domains.Hr; using Microsoft.EntityFrameworkCore; using Lada.Framework.Data.Enums; using Lada.Framework.Infrastructures.Services; namespace ladaexpress.vn.Infrastructures.Services { /// /// Implementation ca ISitemapService /// public class SitemapService : ISitemapService { private readonly IAppConfigService _appConfigService; private readonly IMemoryCache _memoryCache; private readonly IConfiguration _configuration; private readonly ILogger _logger; private readonly IRepository _urlRecordRepository; private readonly IImageService _imageService; private readonly string _baseUrl; private readonly string _cacheKeyPrefix = "Sitemap_"; public SitemapService( IAppConfigService appConfigService, IMemoryCache memoryCache, IConfiguration configuration, ILogger logger, IRepository urlRecordRepository, IImageService imageService) { _appConfigService = appConfigService; _memoryCache = memoryCache; === ladaexpress.vn\Infrastructures\Services\TagService.cs === using Dapper; using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Categories; using ladaexpress.vn.Infrastructures.DTO.Models.Hr; using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index.Childs; using ladaexpress.vn.Infrastructures.DTO.Models.Product.Index.Childs; using ladaexpress.vn.Infrastructures.DTO.Models.Tags; using Microsoft.EntityFrameworkCore; using System.Data; namespace ladaexpress.vn.Infrastructures.Services { public interface ITagService { Task PrepareTagDetail(int id); } public class TagService : ITagService { private readonly IRepository _tagRepository; private readonly IDbConnection _dbConnection; public TagService(IDbConnection dbConnection, IRepository tagRepository) { _dbConnection = dbConnection; _tagRepository = tagRepository; } public async Task PrepareTagDetail(int id) { var model = new TagDetailModel(); var currentTime = DateTimeHelper.CurrentTime(); var tag = await _tagRepository.Query().FirstOrDefaultAsync(c => c.Id == id); if (tag != null && tag.Id > 0) { model = tag.ToDetailModel(); model.Posts = await PreparePosts(id, "TagDetail_Posts"); === ladaexpress.vn\Infrastructures\Services\TopicService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.DTO.Models.Topic; using Microsoft.EntityFrameworkCore; using System.Data; using System.Text.RegularExpressions; namespace ladaexpress.vn.Infrastructures.Services { public interface ITopicService { Task PrepareTopicDetail(int id); Task PrepareTopicDetailBySystemName(string systemName); } public class TopicService : ITopicService { private readonly IRepository _topicRepository; private readonly IRepository _categoryRepository; private readonly IRepository _urlRecordRepository; private readonly IDbConnection _dbConnection; public TopicService(IRepository topicRepository, IRepository urlRecordRepository, IRepository categoryRepository, IDbConnection dbConnection) { _topicRepository = topicRepository; _urlRecordRepository = urlRecordRepository; _categoryRepository = categoryRepository; _dbConnection = dbConnection; } public async Task PrepareTopicDetail(int id) { var model = new TopicDetailModel(); var currentTime = DateTimeHelper.CurrentTime(); === ladaexpress.vn\Infrastructures\Services\UrlRecordService.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Enums; using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Helpers; using Microsoft.EntityFrameworkCore; using System.Globalization; using System.Xml.Linq; namespace ladaexpress.vn.Infrastructures.Services { public interface IUrlRecordService { /// /// T?o lead /// /// /// Task GenerateSiteMapXml(); /// /// Sinh n?i dung robots /// /// Task GenerateRobots(); } public class UrlRecordService : IUrlRecordService { private readonly IRepository _urlRecordRepository; public UrlRecordService(IRepository urlRecordRepository) { _urlRecordRepository = urlRecordRepository; } public async Task GenerateRobots() { var rs = string.Empty; rs = "User-agent: *"; rs += "\n" + "Disallow:"; rs += "\n\n" + "Sitemap: https://ladaexpress.vn/sitemap.xml"; === ladaexpress.vn\Infrastructures\Services\Seo\ISeoService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; namespace ladaexpress.vn.Infrastructures.Services.Seo { /// /// Interface cho SEO Service /// public interface ISeoService { /// /// To SEO model mc ` /// Task GetHomePageSeoAsync(); Task GetProductIndexSeoAsync(); Task GetJobPostIndexSeoAsync(); /// /// To SEO model cho trang bAi vit /// /// ID bAi vit /// TiAu `? bAi vit /// MA' t ng_n /// HAnh nh /// URL bAi vit /// TAc gi /// NgAy xut bn /// NgAy ch%nh s-a /// T khA3a /// Task GetArticleSeoAsync(int postId, string title, string description, string image, string url, string author, DateTime publishedDate, DateTime? modifiedDate = null, List? keywords = null); /// /// To SEO model cho trang sn phcm/d /// ID sn phcm /// TAn sn phcm /// MA' t sn phcm === ladaexpress.vn\Infrastructures\Services\Seo\IStructuredDataService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; namespace ladaexpress.vn.Infrastructures.Services.Seo { /// /// Interface cho Structured Data Service - To JSON-LD markup /// public interface IStructuredDataService { /// /// To Organization schema cho trang ch /// /// string GenerateOrganizationSchema(); /// /// To Website schema v>i search action /// /// string GenerateWebsiteSchema(); /// /// To Article schema cho bAi vit /// /// Article schema model /// string GenerateArticleSchema(ArticleSchema article); /// /// To Product schema cho sn phcm/d /// Product schema model /// string GenerateProductSchema(ProductSchema product); /// /// To BreadcrumbList schema /// /// Danh sAch breadcrumb items /// === ladaexpress.vn\Infrastructures\Services\Seo\SeoService.cs === using ladaexpress.vn.Infrastructures.DTO.Models.Seo; using ladaexpress.vn.Infrastructures.Services; using Microsoft.Extensions.Configuration; using System.Text.RegularExpressions; namespace ladaexpress.vn.Infrastructures.Services.Seo { /// /// Implementation ca SEO Service /// public class SeoService : ISeoService { private readonly IConfiguration _configuration; private readonly IAppConfigService _appConfigService; private readonly IBreadcrumbService _breadcrumbService; // Added private readonly string _baseUrl; private readonly string _defaultImage; private readonly string _siteName; public SeoService(IConfiguration configuration, IAppConfigService appConfigService, IBreadcrumbService breadcrumbService) // Modified { _configuration = configuration; _appConfigService = appConfigService; _breadcrumbService = breadcrumbService; // Injected // Fallback to appsettings if AppConfig not available _baseUrl = _configuration["SeoSettings:BaseUrl"] ?? "https://ladaexpress.vn"; _defaultImage = _configuration["SeoSettings:DefaultImage"] ?? "/images/logo.svg"; _siteName = _configuration["SeoSettings:SiteName"] ?? "LADA Express"; } public async Task GetHomePageSeoAsync() { // Get SEO configs from AppConfig var title = await GetConfigValueAsync("SEO.HomePage.Title", "LADA Express - D /// Implementation ca Structured Data Service /// public class StructuredDataService : IStructuredDataService { private readonly IConfiguration _configuration; private readonly IAppConfigService _appConfigService; private readonly string _baseUrl; private readonly string _siteName; public StructuredDataService(IConfiguration configuration, IAppConfigService appConfigService) { _configuration = configuration; _appConfigService = appConfigService; _baseUrl = _configuration["SeoSettings:BaseUrl"] ?? "https://ladaexpress.vn"; _siteName = _configuration["SeoSettings:SiteName"] ?? "LADA Express"; } /// /// To JsonSerializerOptions chucn cho structured data /// private static JsonSerializerOptions GetJsonSerializerOptions() { return new JsonSerializerOptions { PropertyNamingPolicy = null, // KhA'ng s- dng camelCase ` gi_ nguyAn @context, @type WriteIndented = false, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; } public string GenerateOrganizationSchema() { === ladaexpress.vn\Infrastructures\Startup\IStartupTask.cs === using System.Threading; using System.Threading.Tasks; namespace ladaexpress.vn.Infrastructures.Startup { public interface IStartupTask { Task ExecuteAsync(CancellationToken cancellationToken = default); } } === ladaexpress.vn\Infrastructures\Startup\ScriptConfigStartupTask.cs === using Lada.Framework.Data.Domains.Cms; using Lada.Framework.Data.Repositories; using ladaexpress.vn.Infrastructures.Stores; using Microsoft.EntityFrameworkCore; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace ladaexpress.vn.Infrastructures.Startup { public class ScriptConfigStartupTask : IStartupTask { private readonly IRepository _scriptConfigRepository; public ScriptConfigStartupTask(IRepository scriptConfigRepository) { _scriptConfigRepository = scriptConfigRepository; } public async Task ExecuteAsync(CancellationToken cancellationToken = default) { ScriptConfigStore.AllScripts = await _scriptConfigRepository .Query() .Where(x => x.IsActive) .ToListAsync(cancellationToken); } } } === ladaexpress.vn\Infrastructures\Startup\StartupHostedService.cs === using ladaexpress.vn.Infrastructures.Services; namespace ladaexpress.vn.Infrastructures.Startup { /// /// D?ch v? kh?i d?ng d? load AppConfig vo cache /// public class StartupHostedService : IHostedService { private readonly IServiceProvider _serviceProvider; private readonly ILogger _logger; public StartupHostedService(IServiceProvider serviceProvider, ILogger logger) { _serviceProvider = serviceProvider; _logger = logger; } /// /// Kh?i t?o services khi ?ng d?ng start /// /// /// public async Task StartAsync(CancellationToken cancellationToken) { try { _logger.LogInformation("Starting application initialization..."); using (var scope = _serviceProvider.CreateScope()) { // Load AppConfig into cache var appConfigService = scope.ServiceProvider.GetRequiredService(); await appConfigService.LoadConfigsToCacheAsync(); // Load ScriptConfig into cache if needed var scriptConfigService = scope.ServiceProvider.GetService(); if (scriptConfigService != null) { // ScriptConfig c th? c method tuong t? n?u c?n === ladaexpress.vn\Infrastructures\StartupRegisters\DependencyRegister.cs === using Lada.Framework.Data.Repositories; using Lada.Framework.Infrastructures.Services; using Lada.Framework.Infrastructures.AppSettings; using Microsoft.Extensions.Options; using ladaexpress.vn.Infrastructures.Routes; using ladaexpress.vn.Infrastructures.Services; using ladaexpress.vn.Infrastructures.Services.Seo; namespace ladaexpress.vn.Infrastructures.StartupRegisters { public static class DependencyRegister { public static void RegisterDependency(this IServiceCollection services, IConfiguration configuration) { #region AppSettings services.Configure(options => configuration.GetSection("Media").Bind(options)); #endregion #region Repositories services.AddTransient(typeof(IRepository<>), typeof(Repository<>)); #endregion services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); #region Services services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); === ladaexpress.vn\Infrastructures\StartupRegisters\GeneralRegister.cs === using Lada.Framework.Data.Mappings.DbContexts; using ladaexpress.vn.Infrastructures.DTO; using ladaexpress.vn.Infrastructures.Routes; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using System.Data; using WebMarkupMin.AspNetCoreLatest; using WebMarkupMin.Core; using WebMarkupMin.NUglify; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Mvc; using ladaexpress.vn.Infrastructures.Startup; namespace ladaexpress.vn.Infrastructures.StartupRegisters { public static class GeneralRegister { public static void RegisterGeneralServices(this IServiceCollection services, IConfiguration Configuration) { if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { services.AddControllersWithViews() .AddRazorRuntimeCompilation(); } else { services.AddControllersWithViews(); } // ?ng kA d(options => options.UseSqlServer(connectionString, b => b.MigrationsAssembly("Ladaer.BackEnd")), ServiceLifetime.Transient); // Khai bAo Dapper services.AddTransient((sp) => new SqlConnection(connectionString)); services.AddWebMarkupMin(options =>