last ...
This commit is contained in:
@@ -1,10 +1,41 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using xCategoryService.Models.Dtos;
|
using xCategoryService.Models.Dtos;
|
||||||
using xCategoryService.Models.Entities;
|
using xCategoryService.Models.Entities;
|
||||||
using xCategoryService.Providers.Dtos;
|
using xCategoryService.Providers.Dtos;
|
||||||
|
using xIdentityModels.Models;
|
||||||
using xPushService.Interfaces;
|
using xPushService.Interfaces;
|
||||||
|
|
||||||
namespace xCategoryService.Interfaces
|
namespace xCategoryService.Interfaces
|
||||||
{
|
{
|
||||||
public interface IXCategoryProvider : IXBaseProvided<XCategory, XCategoryDto, int, XCategoryDtoHub>
|
public interface IXCategoryProvider : IXBaseProvided<XCategory, XCategoryDto, int, XCategoryDtoHub>
|
||||||
{ }
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Load an Item by all of it's Related Translations ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XCategoryResourceDto> GetResource(
|
||||||
|
int id,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Category Item for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="langauge"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XCategoryResourceDto> Add(
|
||||||
|
XCategoryDto item,
|
||||||
|
string langauge = null,
|
||||||
|
string connectionId = null,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using xCategoryService.Models.Dtos;
|
||||||
|
using xModels.Base;
|
||||||
|
using xModels.Dtos;
|
||||||
|
|
||||||
|
namespace xCategoryService.Providers.Dtos
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represent a Category by all of it's Resources ...
|
||||||
|
/// </summary>
|
||||||
|
public class XCategoryResourceDto : XBaseDto
|
||||||
|
{
|
||||||
|
public XCategoryDto Item { get; set; }
|
||||||
|
public XResourceDto Titles { get; set; }
|
||||||
|
public XResourceDto Descriptions { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using xCategoryService.Interfaces;
|
using xCategoryService.Interfaces;
|
||||||
@@ -56,35 +53,54 @@ namespace xCategoryService.Providers
|
|||||||
return !item.IsNullOrDefault();
|
return !item.IsNullOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public async Task<(string, string)> LoadResources(
|
/// <summary>
|
||||||
// int id,
|
/// Load an Item by all of it's Related Translations ...
|
||||||
// string language = null
|
/// </summary>
|
||||||
// )
|
/// <param name="id"></param>
|
||||||
// {
|
/// <param name="cancellationToken"></param>
|
||||||
// //
|
/// <returns></returns>
|
||||||
// // Normalize Language ...
|
public async Task<XCategoryResourceDto> GetResource(
|
||||||
// language =
|
int id,
|
||||||
// !language.IsNullOrEmpty()
|
CancellationToken cancellationToken = default
|
||||||
// ? language
|
)
|
||||||
// : appConfiguration.DefaultLanguage;
|
{
|
||||||
|
//
|
||||||
|
var category = await Get(
|
||||||
|
id: id,
|
||||||
|
includeBuilder: null,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
var titleResource = await titleResourceProvider.GetResource(
|
||||||
|
identifier: id,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
var descriptionResource = await titleResourceProvider.GetResource(
|
||||||
|
identifier: id,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
// //
|
//
|
||||||
// // Validate Args ...
|
var result = new XCategoryResourceDto
|
||||||
// var isValid =
|
{
|
||||||
// id.IsValidIntId() &&
|
Item = category,
|
||||||
// !language.IsNullOrEmpty();
|
Titles = titleResource,
|
||||||
// if (!isValid)
|
Descriptions = descriptionResource
|
||||||
// {
|
};
|
||||||
// XException.InvalidArgs.Throw();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
//
|
||||||
// // Reading Resources ...
|
return result;
|
||||||
// // var title = await titleResourceProvider.GetResourceLocales()
|
}
|
||||||
// XException.InvalidArgs.Throw();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public async Task<bool> Add(
|
/// <summary>
|
||||||
|
/// Add Category Item for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="langauge"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XCategoryResourceDto> Add(
|
||||||
XCategoryDto item,
|
XCategoryDto item,
|
||||||
string langauge = null,
|
string langauge = null,
|
||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
@@ -108,6 +124,7 @@ namespace xCategoryService.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
var id = -1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -129,7 +146,7 @@ namespace xCategoryService.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
var id = item.Id;
|
id = item.Id;
|
||||||
var titleResourceTitle = await titleResourceProvider.AddOrUpdateItemResourcer(
|
var titleResourceTitle = await titleResourceProvider.AddOrUpdateItemResourcer(
|
||||||
identifier: id,
|
identifier: id,
|
||||||
language: langauge,
|
language: langauge,
|
||||||
@@ -158,10 +175,7 @@ namespace xCategoryService.Providers
|
|||||||
connectionId: connectionId,
|
connectionId: connectionId,
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
);
|
);
|
||||||
var result = XCategoryTitleResourceProvider;
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -169,7 +183,51 @@ namespace xCategoryService.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
throw new NotImplementedException();
|
// Validate Id ...
|
||||||
|
isValid = id.IsValidIntId();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.ActionFailed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Category Resourv=ce ...
|
||||||
|
var result = await GetResource(
|
||||||
|
id: id,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> RemoveResaource(
|
||||||
|
int id,
|
||||||
|
CancellationToken cancellationToken
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = id.IsValidIntId();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Resource ...
|
||||||
|
var resource = await GetResource(
|
||||||
|
id: id,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
isValid = !resource.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotFound.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
await titleResourceProvider.RemoveResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user