docs: #302 API for manually modfiying duplicates data
This commit is contained in:
parent
e6ffd70d6b
commit
c734ce9f5d
@ -2673,6 +2673,42 @@ namespace RMuseum.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// manually add a duplicate for a poems
|
||||
/// </summary>
|
||||
/// <param name="srcCatId"></param>
|
||||
/// <param name="srcPoemId"></param>
|
||||
/// <param name="destPoemId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("duplicates/manual/{srcCatId}/{srcPoemId}/{destPoemId}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> AdDuplicateAsync(int srcCatId, int srcPoemId, int destPoemId)
|
||||
{
|
||||
var res = await _ganjoorService.AdDuplicateAsync(srcCatId, srcPoemId, destPoemId);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// delete a duplicate
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("duplicates/{id}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> DeleteDuplicateAsync(int id)
|
||||
{
|
||||
var res = await _ganjoorService.DeleteDuplicateAsync(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list of category saved duplicated poems
|
||||
/// </summary>
|
||||
|
||||
@ -1648,6 +1648,22 @@
|
||||
<param name="destCatId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.AdDuplicateAsync(System.Int32,System.Int32,System.Int32)">
|
||||
<summary>
|
||||
manually add a duplicate for a poems
|
||||
</summary>
|
||||
<param name="srcCatId"></param>
|
||||
<param name="srcPoemId"></param>
|
||||
<param name="destPoemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.DeleteDuplicateAsync(System.Int32)">
|
||||
<summary>
|
||||
delete a duplicate
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetCategoryDuplicates(System.Int32)">
|
||||
<summary>
|
||||
list of category saved duplicated poems
|
||||
@ -11433,6 +11449,22 @@
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.AdDuplicateAsync(System.Int32,System.Int32,System.Int32)">
|
||||
<summary>
|
||||
manually add a duplicate for a poems
|
||||
</summary>
|
||||
<param name="srcCatId"></param>
|
||||
<param name="srcPoemId"></param>
|
||||
<param name="destPoemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.DeleteDuplicateAsync(System.Int32)">
|
||||
<summary>
|
||||
delete duplicate
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.StartRemovingCategoryDuplicates(System.Int32,System.Int32)">
|
||||
<summary>
|
||||
start removing category duplicates
|
||||
@ -13718,6 +13750,22 @@
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.AdDuplicateAsync(System.Int32,System.Int32,System.Int32)">
|
||||
<summary>
|
||||
manually add a duplicate for a poems
|
||||
</summary>
|
||||
<param name="srcCatId"></param>
|
||||
<param name="srcPoemId"></param>
|
||||
<param name="destPoemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.DeleteDuplicateAsync(System.Int32)">
|
||||
<summary>
|
||||
delete duplicate
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Services.Implementation.GanjoorService.AggressiveCacheEnabled">
|
||||
<summary>
|
||||
aggressive cache
|
||||
|
||||
@ -877,6 +877,22 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorDuplicateViewModel[]>> GetCategoryDuplicates(int catId);
|
||||
|
||||
/// <summary>
|
||||
/// manually add a duplicate for a poems
|
||||
/// </summary>
|
||||
/// <param name="srcCatId"></param>
|
||||
/// <param name="srcPoemId"></param>
|
||||
/// <param name="destPoemId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> AdDuplicateAsync(int srcCatId, int srcPoemId, int destPoemId);
|
||||
|
||||
/// <summary>
|
||||
/// delete duplicate
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> DeleteDuplicateAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// start removing category duplicates
|
||||
/// </summary>
|
||||
|
||||
@ -3294,6 +3294,58 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// manually add a duplicate for a poems
|
||||
/// </summary>
|
||||
/// <param name="srcCatId"></param>
|
||||
/// <param name="srcPoemId"></param>
|
||||
/// <param name="destPoemId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> AdDuplicateAsync(int srcCatId, int srcPoemId, int destPoemId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var alreadyDup = await _context.GanjoorDuplicates.AsNoTracking().Where(p => p.SrcPoemId == srcPoemId).FirstOrDefaultAsync();
|
||||
if(alreadyDup != null)
|
||||
{
|
||||
return new RServiceResult<bool>(false, $"already dupped : {alreadyDup.DestPoemId}");
|
||||
}
|
||||
var dup = new GanjoorDuplicate()
|
||||
{
|
||||
SrcCatId = srcCatId,
|
||||
SrcPoemId = srcPoemId,
|
||||
DestPoemId = destPoemId
|
||||
};
|
||||
_context.GanjoorDuplicates.Add(dup);
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// delete duplicate
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> DeleteDuplicateAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dup = await _context.GanjoorDuplicates.Where(d => d.Id == id).SingleAsync();
|
||||
_context.Remove(dup);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// aggressive cache
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user