changing GanjoorPoemCompleteViewModel

This commit is contained in:
Hamid Reza Mohammadi 2020-12-24 17:34:17 +03:30
parent 35d3cb9f26
commit 8084b6f6de
3 changed files with 83 additions and 6 deletions

View File

@ -9,9 +9,44 @@ namespace RMuseum.Models.Ganjoor.ViewModels
public class GanjoorPoemCompleteViewModel
{
/// <summary>
/// basic poem info
/// Id
/// </summary>
public GanjoorPoem Poem { get; set; }
public int Id { get; set; }
/// <summary>
/// title
/// </summary>
public string Title { get; set; }
/// <summary>
/// cat + parent cats title + title
/// </summary>
public string FullTitle { get; set; }
/// <summary>
/// url => slug
/// </summary>
public string UrlSlug { get; set; }
/// <summary>
/// sample: /hafez/ghazal/sh1
/// </summary>
public string FullUrl { get; set; }
/// <summary>
/// verses text
/// </summary>
public string PlainText { get; set; }
/// <summary>
/// verses text as html (ganjoor.net format)
/// </summary>
public string HtmlText { get; set; }
/// <summary>
/// category
/// </summary>
public GanjoorPoetCompleteViewModel Category { get; set; }
/// <summary>
/// Recitations

View File

@ -3470,9 +3470,44 @@
a more complete GanjoorPoem View Model
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Poem">
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Id">
<summary>
basic poem info
Id
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Title">
<summary>
title
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.FullTitle">
<summary>
cat + parent cats title + title
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.UrlSlug">
<summary>
url => slug
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.FullUrl">
<summary>
sample: /hafez/ghazal/sh1
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.PlainText">
<summary>
verses text
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.HtmlText">
<summary>
verses text as html (ganjoor.net format)
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Category">
<summary>
category
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Recitations">

View File

@ -301,7 +301,7 @@ namespace RMuseum.Services.Implementation
try
{
int poemId = _GetRandomPoemId();
var poem = (await GetPoemById(poemId)).Result;
var poem = await _context.GanjoorPoems.Where(p => p.Id == poemId).SingleOrDefaultAsync();
PublicRecitationViewModel[] recitations = poem == null ? new PublicRecitationViewModel[] { } : (await GetPoemRecitations(poemId)).Result;
int loopPreventer = 0;
while (poem == null || recitations.Length == 0)
@ -317,7 +317,14 @@ namespace RMuseum.Services.Implementation
(
new GanjoorPoemCompleteViewModel()
{
Poem = poem,
Id = poem.Id,
Title = poem.Title,
FullTitle = poem.FullTitle,
FullUrl = poem.FullUrl,
UrlSlug = poem.UrlSlug,
HtmlText = poem.HtmlText,
PlainText = poem.PlainText,
Category = null,//no usage for now, so do not waste resources
Recitations = recitations,
Images = null //no usage for now, so do not waste resources
}