Last works on Tag Service ...
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using xModels.Dtos;
|
||||
using xTagService.Models.Dtos;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
namespace xTagService.Interfaces
|
||||
{
|
||||
public interface IXBaseTagProvider<TKey>
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
/// <summary>
|
||||
/// Specified Provider ...
|
||||
/// </summary>
|
||||
string ProvideFor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specified Provider Repositroy ...
|
||||
/// </summary>
|
||||
IXTagProvider Provider { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Helper ...
|
||||
/// <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 ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Attach(
|
||||
string tag,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Detach Specified Label From Specified Provided Model ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Detach(
|
||||
string tag,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Tag ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Add(
|
||||
XTagDto model,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <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(
|
||||
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>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Remove(
|
||||
int id
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Dto ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Update(
|
||||
int id,
|
||||
XTagDto model,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <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 ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></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(
|
||||
string tag,
|
||||
TKey forProvidedId
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Model has Tag or not ...
|
||||
/// </summary>
|
||||
/// <param name="forProvidedId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExistsFor(TKey forProvidedId);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using xDataService.Configuration;
|
||||
using xIdentityModels.Models;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xTagService.Hubs;
|
||||
using xTagService.Interfaces.Entities;
|
||||
using xTagService.Models.Dtos;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
namespace xTagService.Interfaces
|
||||
{
|
||||
public interface IXTagProvider
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
IXTagRepository Repository { get; }
|
||||
IHubContext<XTagEntityHub> Hub { get; }
|
||||
IXIdentityProvider IdentityProvider { get; }
|
||||
XDataServiceConfiguration DataConfiguration { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Helpers ...
|
||||
/// <summary>
|
||||
/// Converts an Entity to Dto ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
XTagDto ToXTagDto(XTag model);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a List of Entitiies to List of Dto's ...
|
||||
/// </summary>
|
||||
/// <param name="models"></param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<XTagDto> ToXTagDtoList(IEnumerable<XTag> models);
|
||||
|
||||
/// <summary>
|
||||
/// Converts Query Result of Entities to Dto ...
|
||||
/// </summary>
|
||||
/// <param name="queryResult"></param>
|
||||
/// <returns></returns>
|
||||
XQueryResult<XTagDto> ToXTagDtoQueryResult(XQueryResult<XTag> queryResult);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Tools ...
|
||||
/// <summary>
|
||||
/// Add Specified Tag ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Add(XTagDto model);
|
||||
|
||||
/// <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 All Items as Dto ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XTagDto>> GetAll();
|
||||
|
||||
/// <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>
|
||||
/// Query Model retrieving Dtos ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XTagDto>> Query(XQuery query);
|
||||
|
||||
/// <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>
|
||||
/// Remove Specified Dto ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Remove(
|
||||
int id
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Dto ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
Task<XTagDto> Update(
|
||||
int id,
|
||||
XTagDto model
|
||||
);
|
||||
|
||||
/// <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 ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsTagExists(string tag);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user