From 5fba71d503503544d83021047ce8087afc12ab94 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sun, 31 Jul 2022 21:25:20 +0430 Subject: [PATCH] docs: #352 CRUD for PoemGetDateTags --- RMuseum/DbContext/RMuseumDbContext.cs | 5 + RMuseum/RMuseum.xml | 36 ++++++ .../GanjoorService-PoemGeoDateTag.cs | 108 ++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemGeoDateTag.cs diff --git a/RMuseum/DbContext/RMuseumDbContext.cs b/RMuseum/DbContext/RMuseumDbContext.cs index 051a210c..9202abbe 100644 --- a/RMuseum/DbContext/RMuseumDbContext.cs +++ b/RMuseum/DbContext/RMuseumDbContext.cs @@ -496,5 +496,10 @@ namespace RMuseum.DbContext /// public DbSet UpdatingRelSectsLogs{ get; set; } + /// + /// PoemGeoDateTags + /// + public DbSet PoemGeoDateTags { get; set; } + } } diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 4db82900..be40dc3e 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -3030,6 +3030,11 @@ Updating related sections logs + + + PoemGeoDateTags + + donation expenditures @@ -14305,6 +14310,9 @@ IGanjoorService implementation + + IGanjoorService implementation + @@ -14617,6 +14625,34 @@ + + + add poem geo tag + + + + + + + update poem tag + + + + + + + delete poem tag + + + + + + + get poem tags ordered by LunarDateTotalNumber then by Id + + + + sectionizing poems diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemGeoDateTag.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemGeoDateTag.cs new file mode 100644 index 00000000..5e2d1dbb --- /dev/null +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemGeoDateTag.cs @@ -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 +{ + /// + /// IGanjoorService implementation + /// + public partial class GanjoorService : IGanjoorService + { + /// + /// add poem geo tag + /// + /// + /// + public async Task> AddPoemGeoDateTagAsync(PoemGeoDateTag tag) + { + try + { + _context.PoemGeoDateTags.Add(tag); + await _context.SaveChangesAsync(); + return new RServiceResult(tag); + } + catch (Exception exp) + { + return new RServiceResult(null, exp.ToString()); + } + } + + /// + /// update poem tag + /// + /// + /// + public async Task> 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(true); + } + catch (Exception exp) + { + return new RServiceResult(false, exp.ToString()); + } + } + + /// + /// delete poem tag + /// + /// + /// + public async Task> DeletePoemGeoDateTagAsync(int id) + { + try + { + var dbTag = await _context.PoemGeoDateTags.Where(t => t.Id == id).SingleAsync(); + _context.Remove(dbTag); + await _context.SaveChangesAsync(); + return new RServiceResult(true); + } + catch (Exception exp) + { + return new RServiceResult(false, exp.ToString()); + } + } + + /// + /// get poem tags ordered by LunarDateTotalNumber then by Id + /// + /// + /// + public async Task> GetPoemGeoDateTagsAsync(int poemId) + { + try + { + return new RServiceResult( + await _context.PoemGeoDateTags.AsNoTracking().Where(t => t.PoemId == poemId) + .OrderBy(t => t.LunarDateTotalNumber) + .ThenBy(t => t.Id) + .ToArrayAsync() + ); + } + catch (Exception exp) + { + return new RServiceResult(null, exp.ToString()); + } + } + + + + } +}