Initial Commit ...
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace xModels.Interfaces {
|
||||
/// <summary>
|
||||
/// Some times we need to wrap Entities by some logs or audits ...
|
||||
/// this class provide Audit fields for an Auditable Entity ...
|
||||
/// </summary>
|
||||
public interface IXAuditable {
|
||||
string UserAgent { get; }
|
||||
string UserIp { get; }
|
||||
DateTime TransactionTime { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using xModels.Base;
|
||||
|
||||
namespace xModels.Interfaces {
|
||||
public interface IXBaseStore<T, TKey> where T : XBaseStorableDto<TKey> {
|
||||
//
|
||||
#region Retrieve ...
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Items ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<T>> GetAll ();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve specific Item by key ...
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> Get (TKey key);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve items based on specific condition ...
|
||||
/// </summary>
|
||||
/// <param name="condition"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<T>> FindMany (Expression<Func<T, bool>> condition);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve item based on specific condition ...
|
||||
/// </summary>
|
||||
/// <param name="condition"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> FindOne (Expression<Func<T, bool>> condition);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
/// <summary>
|
||||
/// add specific item to Store ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Add (T item);
|
||||
|
||||
/// <summary>
|
||||
/// Add a Collection of Items on Store ...
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddMany (XBaseRangeRequest<T> items);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
/// <summary>
|
||||
/// Remove an item from store ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Remove (T item);
|
||||
|
||||
/// <summary>
|
||||
/// remove an item by it's Key ...
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> RemoveByKey (TKey key);
|
||||
|
||||
/// <summary>
|
||||
/// remove a collection of items at once ...
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> RemoveMany(XBaseRangeRequest<T> items);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
/// <summary>
|
||||
/// Update Exists Item in store ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="propertyWhiteList"></param>
|
||||
/// <param name="propertyBlackList"></param>
|
||||
/// <param name="propertyValueProviders"></param>
|
||||
/// <param name="updateWithNullOrEmptyValues"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> Update (
|
||||
T item,
|
||||
ICollection<string> propertyWhiteList = null,
|
||||
ICollection<string> propertyBlackList = null,
|
||||
ICollection<KeyValuePair<string, Func<T, object>>> propertyValueProviders = null,
|
||||
bool updateWithNullOrEmptyValues = false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update a Collection of Exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="propertyWhiteList"></param>
|
||||
/// <param name="propertyBlackList"></param>
|
||||
/// <param name="propertyValueProviders"></param>
|
||||
/// <param name="updateWithNullOrEmptyValues"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateMany (
|
||||
XBaseRangeRequest<T> items,
|
||||
ICollection<string> propertyWhiteList = null,
|
||||
ICollection<string> propertyBlackList = null,
|
||||
ICollection<KeyValuePair<string, Func<T, object>>> propertyValueProviders = null,
|
||||
bool updateWithNullOrEmptyValues = false
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
/// <summary>
|
||||
/// retrieve item(s) exists based on specific condition ...
|
||||
/// </summary>
|
||||
/// <param name="condition"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExists (Expression<Func<T, bool>> condition);
|
||||
|
||||
/// <summary>
|
||||
/// is exists an item by providing it's key ...
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExistsByKey (TKey key);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Count ...
|
||||
/// <summary>
|
||||
/// Count Exists items ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> Count ();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
|
||||
namespace xModels.Interfaces {
|
||||
public interface IXEntityControllerActions<TEntity, TKey>
|
||||
where TEntity : XBaseEntity<TKey> {
|
||||
//
|
||||
#region Retrieve ...
|
||||
Task<ActionResult<TEntity>> Get (
|
||||
[FromRoute] TKey id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
);
|
||||
|
||||
Task<ActionResult<IEnumerable<TEntity>>> GetAll (
|
||||
[FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
);
|
||||
|
||||
Task<ActionResult<TEntity>> FindOne (
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
);
|
||||
|
||||
Task<ActionResult<IEnumerable<TEntity>>> FindMany (
|
||||
[FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
);
|
||||
|
||||
Task<ActionResult<XQueryResult<TEntity>>> Query (
|
||||
[FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true
|
||||
);
|
||||
|
||||
//
|
||||
// TODO: Fix this ...
|
||||
// Task<ActionResult<XPageResponse<TEntity>>> RequestPage (
|
||||
// [FromQuery] XPageRequest request, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool containsDetail = false
|
||||
// );
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add ...
|
||||
Task<ActionResult<TEntity>> Add (TEntity item);
|
||||
|
||||
Task<ActionResult<TEntity>> AddOrUpdate (TEntity item);
|
||||
|
||||
Task<ActionResult> AddMany (XBaseRangeRequest<TEntity> request);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
Task<ActionResult<TEntity>> Update (
|
||||
[FromRoute] TKey id, [FromBody] TEntity item
|
||||
);
|
||||
|
||||
Task<ActionResult<bool>> UpdateMany (
|
||||
XBaseRangeRequest<TEntity> request
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
Task<ActionResult<bool>> IsExists (
|
||||
[FromRoute] TKey id,
|
||||
bool ignoreSoftDeletedss = true
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
Task<ActionResult<TEntity>> Remove (
|
||||
[FromRoute] TKey id,
|
||||
bool softDelete = true
|
||||
);
|
||||
|
||||
Task<ActionResult> RemoveMany (
|
||||
XBaseRangeRequest<TEntity> request,
|
||||
bool softDelete = true
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user