This commit is contained in:
2026-06-02 09:42:25 +03:30
parent ad152fdf7f
commit 6abefdd4be
+108 -2
View File
@@ -1,9 +1,16 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using xCategoryService.Interfaces;
using xCategoryService.Interfaces.Dtos;
using xCategoryService.Models.Dtos;
using xCategoryService.Models.Entities;
using xCategoryService.Providers.Dtos;
using xCommons.Configurations;
using xCommons.Extensions;
using xExceptions.Constants;
using xIdentityModels.Models;
using xPushService.Providers;
@@ -11,13 +18,27 @@ namespace xCategoryService.Providers
{
public class XCategoryProvider : XBaseProvided<XCategory, XCategoryDto, int, XCategoryDtoHub>, IXCategoryProvider
{
private readonly IXCategoryServiceProvider provider;
private readonly XAppConfiguration appConfiguration;
private readonly IXCategoryTitleResourceProvider titleResourceProvider;
private readonly IXCategoryDescriptionResourceProvider descriptionResourceProvider;
public XCategoryProvider(
IXCategoryServiceProvider provider
XAppConfiguration appConfiguration,
IXCategoryServiceProvider provider,
IXCategoryTitleResourceProvider titleResourceProvider,
IXCategoryDescriptionResourceProvider descriptionResourceProvider
) : base(
provider,
permittedRoles: new string[] { }
)
{ }
{
//
this.provider = provider;
this.appConfiguration = appConfiguration;
this.titleResourceProvider = titleResourceProvider;
this.descriptionResourceProvider = descriptionResourceProvider;
}
public override bool IsOwned(
XCategoryDto item,
@@ -34,5 +55,90 @@ namespace xCategoryService.Providers
{
return !item.IsNullOrDefault();
}
// public async Task<(string, string)> LoadResources(
// int id,
// string language = null
// )
// {
// //
// // Normalize Language ...
// language =
// !language.IsNullOrEmpty()
// ? language
// : appConfiguration.DefaultLanguage;
// //
// // Validate Args ...
// var isValid =
// id.IsValidIntId() &&
// !language.IsNullOrEmpty();
// if (!isValid)
// {
// XException.InvalidArgs.Throw();
// }
// //
// // Reading Resources ...
// // var title = await titleResourceProvider.GetResourceLocales()
// XException.InvalidArgs.Throw();
// }
public async Task<bool> Add(
XCategoryDto item,
string langauge = null,
string connectionId = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
)
{
//
// Normalize ...
langauge =
!langauge.IsNullOrEmpty()
? langauge
: appConfiguration.DefaultLanguage;
//
// Validate ...
var isValid = !item.IsNullOrDefault();
if (!isValid)
{
XException.InvalidArgs.Throw();
}
//
try
{
//
var title = item.Title;
var description = item.Description;
//
// Add Item Pure for ID Generating ...
item = await base.Add(
item: item,
userInfo: userInfo,
connectionId: connectionId,
cancellationToken: cancellationToken
);
isValid = !item.IsNullOrDefault();
if (!isValid)
{
XException.ActionFailed.Throw();
}
//
var id = item.Id;
var titleResource = titleResourceProvider.A
}
catch
{
XException.InvalidArgs.Throw();
}
//
throw new NotImplementedException();
}
}
}