docs: #352 CRUD for PoemGetDateTags

This commit is contained in:
Hamid Reza Mohammadi 2022-07-31 21:25:20 +04:30
parent f08eecebf9
commit 5fba71d503
3 changed files with 149 additions and 0 deletions

View File

@ -496,5 +496,10 @@ namespace RMuseum.DbContext
/// </summary>
public DbSet<UpdatingRelSectsLog> UpdatingRelSectsLogs{ get; set; }
/// <summary>
/// PoemGeoDateTags
/// </summary>
public DbSet<PoemGeoDateTag> PoemGeoDateTags { get; set; }
}
}

View File

@ -3030,6 +3030,11 @@
Updating related sections logs
</summary>
</member>
<member name="P:RMuseum.DbContext.RMuseumDbContext.PoemGeoDateTags">
<summary>
PoemGeoDateTags
</summary>
</member>
<member name="T:RMuseum.Models.Accounting.DonationExpenditure">
<summary>
donation expenditures
@ -14305,6 +14310,9 @@
<summary>
IGanjoorService implementation
</summary>
<summary>
IGanjoorService implementation
</summary>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.SwitchCoupletBookmark(System.Guid,System.Int32,System.Int32)">
<summary>
@ -14617,6 +14625,34 @@
<param name="rejectionCause"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.AddPoemGeoDateTagAsync(RMuseum.Models.Ganjoor.PoemGeoDateTag)">
<summary>
add poem geo tag
</summary>
<param name="tag"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.UpdatePoemGeoDateTagAsync(RMuseum.Models.Ganjoor.PoemGeoDateTag)">
<summary>
update poem tag
</summary>
<param name="tag"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.DeletePoemGeoDateTagAsync(System.Int32)">
<summary>
delete poem tag
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemGeoDateTagsAsync(System.Int32)">
<summary>
get poem tags ordered by LunarDateTotalNumber then by Id
</summary>
<param name="poemId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartFillingPoemSectionsCoupletIndex">
<summary>
sectionizing poems

View File

@ -0,0 +1,108 @@
using Microsoft.EntityFrameworkCore;
using RMuseum.Models.Ganjoor;
using RSecurityBackend.Models.Generic;
using System;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace RMuseum.Services.Implementation
{
/// <summary>
/// IGanjoorService implementation
/// </summary>
public partial class GanjoorService : IGanjoorService
{
/// <summary>
/// add poem geo tag
/// </summary>
/// <param name="tag"></param>
/// <returns></returns>
public async Task<RServiceResult<PoemGeoDateTag>> AddPoemGeoDateTagAsync(PoemGeoDateTag tag)
{
try
{
_context.PoemGeoDateTags.Add(tag);
await _context.SaveChangesAsync();
return new RServiceResult<PoemGeoDateTag>(tag);
}
catch (Exception exp)
{
return new RServiceResult<PoemGeoDateTag>(null, exp.ToString());
}
}
/// <summary>
/// update poem tag
/// </summary>
/// <param name="tag"></param>
/// <returns></returns>
public async Task<RServiceResult<bool>> UpdatePoemGeoDateTagAsync(PoemGeoDateTag tag)
{
try
{
var dbTag = await _context.PoemGeoDateTags.Where(t => t.Id == tag.Id).SingleAsync();
dbTag.PoemId = tag.PoemId;
dbTag.CoupletIndex = tag.CoupletIndex;
dbTag.LocationId = tag.LocationId;
dbTag.LunarYear = tag.LunarYear;
dbTag.LunarMonth = tag.LunarMonth;
dbTag.LunarDay = tag.LunarDay;
dbTag.PoemId = tag.PoemId;
dbTag.LunarDateTotalNumber = tag.LunarDateTotalNumber;
_context.Update(dbTag);
await _context.SaveChangesAsync();
return new RServiceResult<bool>(true);
}
catch (Exception exp)
{
return new RServiceResult<bool>(false, exp.ToString());
}
}
/// <summary>
/// delete poem tag
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<bool>> DeletePoemGeoDateTagAsync(int id)
{
try
{
var dbTag = await _context.PoemGeoDateTags.Where(t => t.Id == id).SingleAsync();
_context.Remove(dbTag);
await _context.SaveChangesAsync();
return new RServiceResult<bool>(true);
}
catch (Exception exp)
{
return new RServiceResult<bool>(false, exp.ToString());
}
}
/// <summary>
/// get poem tags ordered by LunarDateTotalNumber then by Id
/// </summary>
/// <param name="poemId"></param>
/// <returns></returns>
public async Task<RServiceResult<PoemGeoDateTag[]>> GetPoemGeoDateTagsAsync(int poemId)
{
try
{
return new RServiceResult<PoemGeoDateTag[]>(
await _context.PoemGeoDateTags.AsNoTracking().Where(t => t.PoemId == poemId)
.OrderBy(t => t.LunarDateTotalNumber)
.ThenBy(t => t.Id)
.ToArrayAsync()
);
}
catch (Exception exp)
{
return new RServiceResult<PoemGeoDateTag[]>(null, exp.ToString());
}
}
}
}