docs: #319 section editor + some needed API
This commit is contained in:
parent
be63f176bf
commit
7b8ab40b9d
@ -106,27 +106,5 @@ else
|
||||
<a role="button" onclick="newRhythm()" class="pagebutton">پیشنهاد وزن جدید</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
شکستن به اشعار مجزا
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@foreach (var verse in Model.Verses)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<p id="original-@($"{verse.VOrder}")">@verse.Text</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<a role="button" id="breakpoem-@verse.VOrder" style="cursor:pointer;width:100%;color:white;background-color:red;display:block" onclick="#">از اینجا به بعد شعر جداگانهایست</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
}
|
||||
</table>
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
/// <summary>
|
||||
/// my last edit
|
||||
/// </summary>
|
||||
public GanjoorPoemCorrectionViewModel MyLastEdit { get; set; }
|
||||
public GanjoorPoemSectionCorrectionViewModel MyLastEdit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// verses
|
||||
@ -128,6 +128,14 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
|
||||
PoemSection = PageInformation.Poem.Sections.Where(s => s.Index == int.Parse(Request.Query["index"])).Single();
|
||||
|
||||
var editResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/section/correction/last/{PoemSection.Id}");
|
||||
if (!editResponse.IsSuccessStatusCode)
|
||||
{
|
||||
FatalError = JsonConvert.DeserializeObject<string>(await editResponse.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
MyLastEdit = JsonConvert.DeserializeObject<GanjoorPoemSectionCorrectionViewModel>(await editResponse.Content.ReadAsStringAsync());
|
||||
|
||||
Verses = _FilterSectionVerses(PoemSection, PageInformation.Poem.Verses);
|
||||
}
|
||||
else
|
||||
|
||||
@ -2812,6 +2812,29 @@ namespace RMuseum.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns last unreviewed correction from the user for a section
|
||||
/// </summary>
|
||||
/// <param name="id">section id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("section/correction/last/{id}")]
|
||||
[Authorize]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemSectionCorrectionViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetLastUnreviewedUserCorrectionForSection(int id)
|
||||
{
|
||||
Guid userId =
|
||||
new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
|
||||
RServiceResult<GanjoorPoemSectionCorrectionViewModel> res =
|
||||
await _ganjoorService.GetLastUnreviewedUserCorrectionForSection(userId, id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);//might be null
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// readonly mode
|
||||
|
||||
@ -482,5 +482,10 @@ namespace RMuseum.DbContext
|
||||
/// </summary>
|
||||
public DbSet<GanjoorCachedRelatedSection> GanjoorCachedRelatedSections { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// section correctons
|
||||
/// </summary>
|
||||
public DbSet<GanjoorPoemSectionCorrection> GanjoorPoemSectionCorrections { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1713,6 +1713,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetLastUnreviewedUserCorrectionForSection(System.Int32)">
|
||||
<summary>
|
||||
returns last unreviewed correction from the user for a section
|
||||
</summary>
|
||||
<param name="id">section id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Controllers.GanjoorController.ReadOnlyMode">
|
||||
<summary>
|
||||
readonly mode
|
||||
@ -2894,6 +2901,11 @@
|
||||
related sections to each section (having same rhyme letters and prosody metre)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.DbContext.RMuseumDbContext.GanjoorPoemSectionCorrections">
|
||||
<summary>
|
||||
section correctons
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Accounting.DonationExpenditure">
|
||||
<summary>
|
||||
donation expenditures
|
||||
@ -12327,6 +12339,14 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetLastUnreviewedUserCorrectionForSection(System.Guid,System.Int32)">
|
||||
<summary>
|
||||
last unreviewed user correction for a section
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="sectionId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IGanjoorTranslationService">
|
||||
<summary>
|
||||
translation service implementation
|
||||
@ -13706,6 +13726,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>
|
||||
@ -13880,6 +13903,14 @@
|
||||
<param name="moderation"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetLastUnreviewedUserCorrectionForSection(System.Guid,System.Int32)">
|
||||
<summary>
|
||||
last unreviewed user correction for a section
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="sectionId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartUpdatingMundexPage(System.Guid)">
|
||||
<summary>
|
||||
start updating stats page
|
||||
|
||||
@ -941,5 +941,13 @@ namespace RMuseum.Services
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemSection[]>> GetPoemSectionsAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// last unreviewed user correction for a section
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="sectionId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemSectionCorrectionViewModel>> GetLastUnreviewedUserCorrectionForSection(Guid userId, int sectionId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using RMuseum.DbContext;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using RSecurityBackend.Services.Implementation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RMuseum.Services.Implementation
|
||||
{
|
||||
/// <summary>
|
||||
/// IGanjoorService implementation
|
||||
/// </summary>
|
||||
public partial class GanjoorService : IGanjoorService
|
||||
{
|
||||
/// <summary>
|
||||
/// last unreviewed user correction for a section
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="sectionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoemSectionCorrectionViewModel>> GetLastUnreviewedUserCorrectionForSection(Guid userId, int sectionId)
|
||||
{
|
||||
var dbCorrection = await _context.GanjoorPoemSectionCorrections.AsNoTracking().Include(c => c.User)
|
||||
.Where(c => c.UserId == userId && c.SectionId == sectionId && c.Reviewed == false)
|
||||
.OrderByDescending(c => c.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (dbCorrection == null)
|
||||
return new RServiceResult<GanjoorPoemSectionCorrectionViewModel>(null);
|
||||
|
||||
return new RServiceResult<GanjoorPoemSectionCorrectionViewModel>
|
||||
(
|
||||
new GanjoorPoemSectionCorrectionViewModel()
|
||||
{
|
||||
Id = dbCorrection.Id,
|
||||
SectionId = dbCorrection.SectionId,
|
||||
UserId = dbCorrection.UserId,
|
||||
Rhythm = dbCorrection.Rhythm,
|
||||
OriginalRhythm = dbCorrection.OriginalRhythm,
|
||||
RhythmResult = dbCorrection.RhythmResult,
|
||||
Rhythm2 = dbCorrection.Rhythm2,
|
||||
OriginalRhythm2 = dbCorrection.OriginalRhythm2,
|
||||
RhythmResult2 = dbCorrection.RhythmResult2,
|
||||
BreakFromVerse1VOrder = dbCorrection.BreakFromVerse1VOrder,
|
||||
BreakFromVerse1VOrderResult = dbCorrection.BreakFromVerse1VOrderResult,
|
||||
BreakFromVerse2VOrder = dbCorrection.BreakFromVerse2VOrder,
|
||||
BreakFromVerse2VOrderResult = dbCorrection.BreakFromVerse2VOrderResult,
|
||||
BreakFromVerse3VOrder = dbCorrection.BreakFromVerse3VOrder,
|
||||
BreakFromVerse3VOrderResult = dbCorrection.BreakFromVerse3VOrderResult,
|
||||
BreakFromVerse4VOrder = dbCorrection.BreakFromVerse4VOrder,
|
||||
BreakFromVerse4VOrderResult = dbCorrection.BreakFromVerse4VOrderResult,
|
||||
Note = dbCorrection.Note,
|
||||
Date = dbCorrection.Date,
|
||||
Reviewed = dbCorrection.Reviewed,
|
||||
ReviewNote = dbCorrection.ReviewNote,
|
||||
ReviewDate = dbCorrection.ReviewDate,
|
||||
UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user