From 0912ffd3738c7472967fad0e08bfc7a4463c5721 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 21 Oct 2021 17:10:55 +0330 Subject: [PATCH] #224 a method for computing relation between poets and halfcenturies entities (starting to code) --- RMuseum/RMuseum.xml | 9 + .../GanjoorService-Centuries.cs | 239 ++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Centuries.cs diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 988a058c..6d9586e8 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -10287,6 +10287,9 @@ IGanjoorService implementation + + IGanjoorService implementation + @@ -10348,6 +10351,12 @@ + + + regenerate half centuries + + + find category poem rhymes diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Centuries.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Centuries.cs new file mode 100644 index 00000000..1bd30bae --- /dev/null +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Centuries.cs @@ -0,0 +1,239 @@ +using Microsoft.EntityFrameworkCore; +using RMuseum.Models.Ganjoor; +using RSecurityBackend.Models.Generic; +using System; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using RSecurityBackend.Services.Implementation; +using RMuseum.Models.Ganjoor.ViewModels; +using System.Collections.Generic; + +namespace RMuseum.Services.Implementation +{ + /// + /// IGanjoorService implementation + /// + public partial class GanjoorService : IGanjoorService + { + /// + /// regenerate half centuries + /// + /// + public async Task> RegenerateHalfCenturiesAsync() + { + try + { + var oldOnes = await _context.GanjoorHalfCenturies.ToArrayAsync(); + _context.RemoveRange(oldOnes); + await _context.SaveChangesAsync(); + + var periods = new List + { + new GanjoorHalfCentury() + { + HalfCenturyOrder = 1, + Name = "قرن سوم", + StartYear = 0, + EndYear = 300, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 2, + Name = "سوم و چهارم", + StartYear = 250, + EndYear = 350, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 3, + Name = "قرن چهارم", + StartYear = 300, + EndYear = 400, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 4, + Name = "چهارم و پنجم", + StartYear = 350, + EndYear = 450, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 5, + Name = "قرن پنجم", + StartYear = 400, + EndYear = 500, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 6, + Name = "پنجم و ششم", + StartYear = 450, + EndYear = 550, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 7, + Name = "قرن ششم", + StartYear = 500, + EndYear = 600, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 8, + Name = "ششم و هفتم", + StartYear = 550, + EndYear = 650, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 9, + Name = "قرن هفتم", + StartYear = 600, + EndYear = 700, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 10, + Name = "هفتم و هشتم", + StartYear = 650, + EndYear = 750, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 11, + Name = "قرن هشتم", + StartYear = 700, + EndYear = 800, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 12, + Name = "هشتم و نهم", + StartYear = 750, + EndYear = 850, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 13, + Name = "قرن نهم", + StartYear = 800, + EndYear = 900, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 14, + Name = "نهم و دهم", + StartYear = 850, + EndYear = 950, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 15, + Name = "قرن دهم", + StartYear = 900, + EndYear = 1000, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 16, + Name = "دهم و یازدهم", + StartYear = 950, + EndYear = 1050, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 17, + Name = "قرن یازدهم", + StartYear = 1000, + EndYear = 1100, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 18, + Name = "یازذهم و دوازدهم", + StartYear = 1050, + EndYear = 1150, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 19, + Name = "قرن دوازدهم", + StartYear = 1100, + EndYear = 1200, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 20, + Name = "دوازدهم و سیزدهم", + StartYear = 1150, + EndYear = 1250, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 21, + Name = "قرن سیزدهم", + StartYear = 1200, + EndYear = 1300, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 22, + Name = "سیزدهم و چهاردهم", + StartYear = 1250, + EndYear = 1350, + ShowInTimeLine = false, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 23, + Name = "قرن چهاردهم", + StartYear = 1300, + EndYear = 1400, + ShowInTimeLine = true, + }, + new GanjoorHalfCentury() + { + HalfCenturyOrder = 24, + Name = "چهاردهم و پانزدهم", + StartYear = 1350, + EndYear = 1450, + ShowInTimeLine = false, + }, + + }; + + var poets = await _context.GanjoorPoets.AsNoTracking().Where(p => p.BirthYearInLHijri != 0).OrderBy(p => new { p.BirthYearInLHijri, p.DeathYearInLHijri }).ToArrayAsync(); + + + return new RServiceResult(true); + } + catch (Exception exp) + { + return new RServiceResult(false, exp.ToString()); + } + } + } +}