Last works on Tag Service ...
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using xCommons.Extensions;
|
||||
using xTagService.Models.Dtos;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
namespace xTagService.Extensions
|
||||
{
|
||||
public static class xTagServiceExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Map Global Properties From XFile to XFile Dto ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XTagDto ToDto(this XTag source)
|
||||
{
|
||||
//
|
||||
XTagDto result = null;
|
||||
|
||||
//
|
||||
if (!source.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
result = new XTagDto();
|
||||
result = result.UpdateData(
|
||||
updateWith: source,
|
||||
propertyBlackList: new List<string>
|
||||
{
|
||||
nameof(XTag.Deleted),
|
||||
nameof(XTag.References),
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing List ...
|
||||
if (!source.References.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
result.References = source.References
|
||||
.ParseListString<string>()
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Dto to Entity Representation ...
|
||||
/// Ignore ID Property ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XTag FromDto(this XTagDto source)
|
||||
{
|
||||
//
|
||||
var result = new XTag();
|
||||
|
||||
//
|
||||
if (!source.IsNull())
|
||||
{
|
||||
//
|
||||
result = result.UpdateData(
|
||||
updateWith: source,
|
||||
propertyBlackList: new List<string>
|
||||
{
|
||||
nameof(XTag.Deleted),
|
||||
nameof(XTag.References),
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
if (!source.References.IsNull() && source.References.HasChild()) {
|
||||
result.References = source.References.ToListString();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user