Refactoring XReference Mechanism ...
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using xCommons.Extensions;
|
||||
using xDataService.Extensions;
|
||||
using xTagService.Models.Dtos;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace xTagService.Extensions
|
||||
{
|
||||
//
|
||||
result.References = source.References
|
||||
.ParseListString<string>()
|
||||
.ParseXReferenceList<string>()
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -73,7 +74,7 @@ namespace xTagService.Extensions
|
||||
|
||||
//
|
||||
if (!source.References.IsNull() && source.References.HasChild()) {
|
||||
result.References = source.References.ToListString();
|
||||
result.References = source.References.ToXReferenceString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+34
-211
@@ -1,258 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using xModels.Dtos;
|
||||
using xDataService.Interfaces;
|
||||
using xDataService.Models;
|
||||
using xTagService.Models.Dtos;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
namespace xTagService.Interfaces
|
||||
{
|
||||
public interface IXBaseTagProvider<TKey>
|
||||
/// <summary>
|
||||
/// Implementing XBaseTagProvider ...
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey"></typeparam>
|
||||
public interface IXBaseTagProvider<TKey> : IXBaseReferencedProvider<XTagDto, TKey>
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
/// <summary>
|
||||
/// Specified Provider ...
|
||||
/// Provider Identifier ...
|
||||
/// </summary>
|
||||
string ProvideFor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specified Provider Repositroy ...
|
||||
/// </summary>
|
||||
IXTagProvider Provider { get; }
|
||||
IXTagProvider TagProvider { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Helper ...
|
||||
#region Tools ...
|
||||
/// <summary>
|
||||
/// Get Specified Identifier ...
|
||||
/// </summary>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
string GetIdentifier(TKey forProvidedId);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Implementation ...
|
||||
/// <summary>
|
||||
/// Attach Specified Label to Specified Provided Model ...
|
||||
/// Add Reference a Tag to Specific Provided ID ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="forIndex"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Attach(
|
||||
Task<bool> AddReference(
|
||||
string tag,
|
||||
TKey forProvidedId,
|
||||
TKey providedForId,
|
||||
int forIndex = 0,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Detach Specified Label From Specified Provided Model ...
|
||||
/// Add Reference a Tag to Specific XRefence<TKey> ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <param name="reference"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Detach(
|
||||
Task<bool> AddReference(
|
||||
string tag,
|
||||
TKey forProvidedId,
|
||||
XReference<TKey> reference,
|
||||
string connectionId = null
|
||||
);
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Tag ...
|
||||
/// Remove Reference a Tag for Specific Provided ID ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="forIndex">if null, removes all</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Add(
|
||||
XTagDto model,
|
||||
TKey forProvidedId,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Item as Dto ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Get(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag by it's Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> GetTag(string tag);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag by it's Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> GetTagFor(
|
||||
Task<bool> RemoveReference(
|
||||
string tag,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve All Items as Dto ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XTagDto>> GetAll();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve All Items as Dto ...
|
||||
/// </summary>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XTagDto>> GetTags(TKey forProvidedId);
|
||||
|
||||
/// <summary>
|
||||
/// Find Specified Item by Condition ...
|
||||
/// </summary>
|
||||
/// <param name="whereClause"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> FindOne(Expression<Func<XTag, bool>> whereClause);
|
||||
|
||||
/// <summary>
|
||||
/// Find Many Items based on Conditions ...
|
||||
/// </summary>
|
||||
/// <param name="whereClause"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XTagDto>> FindMany(Expression<Func<XTag, bool>> whereClause);
|
||||
|
||||
/// <summary>
|
||||
/// Find Many Items based on Conditions ...
|
||||
/// </summary>
|
||||
/// <param name="whereClause"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XTagDto>> FindManyFor(
|
||||
Expression<Func<XTag, bool>> whereClause,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Query Model retrieving Dtos ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XTagDto>> Query(XQuery query);
|
||||
|
||||
/// <summary>
|
||||
/// Query Model retrieving Dtos ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XTagDto>> QueryTagsFor(
|
||||
XQuery query,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Query Conditional Retrieving Dtos ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="whereClause"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XTagDto>> ConditionalQuery(
|
||||
XQuery query,
|
||||
Expression<Func<XTag, bool>> whereClause
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Query Conditional Retrieving Dtos ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="whereClause"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XTagDto>> ConditionalQueryTagsFor(
|
||||
XQuery query,
|
||||
Expression<Func<XTag, bool>> whereClause,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Dto ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Remove(
|
||||
int id,
|
||||
TKey providedForId,
|
||||
int? forIndex = null,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove All Specified Tags ...
|
||||
/// </summary>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> RemoveTagsFor(
|
||||
TKey forProvidedId,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Dto ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Update(
|
||||
int id,
|
||||
XTagDto model,
|
||||
TKey forProvidedId,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Count Exists Entities ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> Count();
|
||||
|
||||
/// <summary>
|
||||
/// Check Entity Exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExists(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by Label ...
|
||||
/// Remove Reference a Tag for Specific XRefence<TKey> ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsTagExists(string tag);
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsTagExistsFor(
|
||||
Task<bool> RemoveReference(
|
||||
string tag,
|
||||
TKey forProvidedId
|
||||
XReference<TKey> reference,
|
||||
string connectionId = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Model has Tag or not ...
|
||||
/// </summary>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExistsFor(TKey forProvidedId);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using xDataService.Models;
|
||||
using xModels.Base;
|
||||
|
||||
namespace xTagService.Models.Dtos
|
||||
@@ -7,6 +8,6 @@ namespace xTagService.Models.Dtos
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Tag { get; set; }
|
||||
public IList<string> References = new List<string>();
|
||||
public IList<XReference<string>> References = new List<XReference<string>>();
|
||||
}
|
||||
}
|
||||
+744
-932
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user