people tags #387

This commit is contained in:
Hamid Reza Mohammadi 2026-10-01 08:01:18 +03:30
parent ddbef76d94
commit cee01357fc
9 changed files with 288 additions and 60 deletions

View File

@ -4,8 +4,12 @@
@using RMuseum.Models.Ganjoor @using RMuseum.Models.Ganjoor
@{ @{
Layout = "_UserPanelLayout"; Layout = "_UserPanelLayout";
ViewData["Title"] = "پیشنهاد ویرایش نسبت خویشاوندی"; bool isAffiliation = Model.Kind == PersonRelationSuggestionKind.Affiliation;
ViewData["Title"] = isAffiliation ? "پیشنهاد ویرایش وابستگی" : "پیشنهاد ویرایش نسبت خویشاوندی";
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData); await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
string formAction = isAffiliation
? $"/User/SuggestPersonRelationEdit?affiliationId={Model.Affiliation.Id}&Handler=SuggestEdit"
: $"/User/SuggestPersonRelationEdit?relationId={Model.Relation.Id}&Handler=SuggestEdit";
} }
@if (!string.IsNullOrEmpty(Model.LastError)) @if (!string.IsNullOrEmpty(Model.LastError))
{ {
@ -15,10 +19,10 @@ else
{ {
<div class="up-page-header"> <div class="up-page-header">
<h1> <h1>
پیشنهاد ویرایش نسبت: @(isAffiliation ? "پیشنهاد ویرایش وابستگی:" : "پیشنهاد ویرایش نسبت:")
<a href="javascript:void(0)" onclick="PersonWindow.open(@Model.Relation.Person1Id)">@(Model.Relation.Person1 != null ? Model.Relation.Person1.Name : Model.Relation.Person1Id.ToString())</a> <a href="javascript:void(0)" onclick="PersonWindow.open(@Model.Person1Id)">@Model.Person1Name</a>
و و
<a href="javascript:void(0)" onclick="PersonWindow.open(@Model.Relation.Person2Id)">@(Model.Relation.Person2 != null ? Model.Relation.Person2.Name : Model.Relation.Person2Id.ToString())</a> <a href="javascript:void(0)" onclick="PersonWindow.open(@Model.Person2Id)">@Model.Person2Name</a>
</h1> </h1>
</div> </div>
@ -32,9 +36,10 @@ else
} }
<div class="up-card"> <div class="up-card">
<form method="post" action="/User/SuggestPersonRelationEdit?relationId=@Model.Relation.Id&amp;Handler=SuggestEdit"> <form method="post" action="@formAction">
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
<input type="hidden" asp-for="Suggestion.ExistingRelationId" /> <input type="hidden" asp-for="Suggestion.ExistingRelationId" />
<input type="hidden" asp-for="Suggestion.ExistingAffiliationId" />
<input type="hidden" asp-for="Suggestion.Person1Id" /> <input type="hidden" asp-for="Suggestion.Person1Id" />
<input type="hidden" asp-for="Suggestion.Person2Id" /> <input type="hidden" asp-for="Suggestion.Person2Id" />
@ -42,11 +47,34 @@ else
<tr> <tr>
<td>نوع درخواست:</td> <td>نوع درخواست:</td>
<td> <td>
<label><input type="radio" name="Action" value="Modify" checked="checked" /> ویرایش این نسبت</label> <label><input type="radio" name="Action" value="Modify" checked="checked" /> @(isAffiliation ? "ویرایش این وابستگی" : "ویرایش این نسبت")</label>
&nbsp; &nbsp;
<label><input type="radio" name="Action" value="Remove" /> حذف این نسبت (اشتباه ثبت شده است)</label> <label><input type="radio" name="Action" value="Remove" /> @(isAffiliation ? "حذف این وابستگی (اشتباه ثبت شده است)" : "حذف این نسبت (اشتباه ثبت شده است)")</label>
</td> </td>
</tr> </tr>
@if (isAffiliation)
{
<tr>
<td>نوع وابستگی:</td>
<td>
<select asp-for="Suggestion.SuggestedAffiliationType">
<option value="@((int)PersonAffiliationType.Minister)">وزیر/کارگزار (طرف اول، زیردست است)</option>
<option value="@((int)PersonAffiliationType.Advisor)">مشاور (طرف اول، مشاور طرف دوم است)</option>
<option value="@((int)PersonAffiliationType.Courtier)">درباری/همراه (طرف اول، همراه طرف دوم است)</option>
<option value="@((int)PersonAffiliationType.Servant)">خدمتگزار (طرف اول، خدمتگزار طرف دوم است)</option>
<option value="@((int)PersonAffiliationType.Patron)">حامی (طرف اول، حامی طرف دوم است)</option>
<option value="@((int)PersonAffiliationType.Successor)">جانشین (طرف اول، جانشین طرف دوم است)</option>
<option value="@((int)PersonAffiliationType.Ally)">متحد/هم‌پیمان</option>
<option value="@((int)PersonAffiliationType.Rival)">رقیب/دشمن</option>
<option value="@((int)PersonAffiliationType.Companion)">همراه/همدم</option>
<option value="@((int)PersonAffiliationType.Other)">نوع دیگر (در یادداشت توضیح دهید)</option>
</select>
<p class="up-hint"><small>جهت وابستگی (کدام طرف زیردست/حامی/... است) قابل تغییر نیست؛ در صورت اشتباه بودن جهت، این وابستگی را حذف و یکی تازه پیشنهاد کنید.</small></p>
</td>
</tr>
}
else
{
<tr> <tr>
<td>نوع نسبت:</td> <td>نوع نسبت:</td>
<td> <td>
@ -65,6 +93,7 @@ else
</td> </td>
<td><input asp-for="Suggestion.SuggestedDegreeHint" /></td> <td><input asp-for="Suggestion.SuggestedDegreeHint" /></td>
</tr> </tr>
}
<tr> <tr>
<td>یادداشت (مستندسازی):</td> <td>یادداشت (مستندسازی):</td>
<td><textarea asp-for="Suggestion.SuggestedNote" rows="3" cols="60"></textarea></td> <td><textarea asp-for="Suggestion.SuggestedNote" rows="3" cols="60"></textarea></td>

View File

@ -12,10 +12,12 @@ using RMuseum.Models.Ganjoor;
namespace GanjooRazor.Areas.User.Pages namespace GanjooRazor.Areas.User.Pages
{ {
/// <summary> /// <summary>
/// contributor-facing form for suggesting a change to, or removal of, an existing /// contributor-facing form for suggesting a change to, or removal of, an existing edge between
/// GanjoorPersonRelation - the kinship-edge counterpart of SuggestPersonEdit.cshtml. Any /// two people - the kinship-edge/affiliation-edge counterpart of SuggestPersonEdit.cshtml. Covers
/// logged-in user may submit here; nothing is changed until a moderator approves it via /// both kinds: pass relationId for a GanjoorPersonRelation (family), or affiliationId for a
/// Admin/ReviewPersonRelationEdits. Reachable from a person's PersonWindow.open() modal. /// GanjoorPersonAffiliation (non-family) - exactly one of the two is expected, matching which ✎
/// link on PersonWindow the contributor came from. Any logged-in user may submit here; nothing is
/// changed until a moderator approves it via Admin/ReviewPersonRelationEdits.
/// </summary> /// </summary>
public class SuggestPersonRelationEditModel : LoginPartialEnabledPageModel public class SuggestPersonRelationEditModel : LoginPartialEnabledPageModel
{ {
@ -27,17 +29,65 @@ namespace GanjooRazor.Areas.User.Pages
public string LastResult { get; set; } public string LastResult { get; set; }
/// <summary>
/// "family" when editing a GanjoorPersonRelation (Relation is populated), "affiliation" when
/// editing a GanjoorPersonAffiliation (Affiliation is populated) - decides which of the two
/// the view renders and which Suggestion.Existing*Id gets set on post
/// </summary>
public PersonRelationSuggestionKind Kind { get; set; }
public GanjoorPersonRelation Relation { get; set; } public GanjoorPersonRelation Relation { get; set; }
public GanjoorPersonAffiliation Affiliation { get; set; }
/// <summary>
/// whichever side (Relation.Person1/Person2 or Affiliation.Person1/Person2) is populated -
/// used by the view for the page heading/links without needing to branch on Kind there too
/// </summary>
public int Person1Id => Kind == PersonRelationSuggestionKind.Affiliation ? Affiliation.Person1Id : Relation.Person1Id;
public string Person1Name => Kind == PersonRelationSuggestionKind.Affiliation ? (Affiliation.Person1?.Name ?? Affiliation.Person1Id.ToString()) : (Relation.Person1?.Name ?? Relation.Person1Id.ToString());
public int Person2Id => Kind == PersonRelationSuggestionKind.Affiliation ? Affiliation.Person2Id : Relation.Person2Id;
public string Person2Name => Kind == PersonRelationSuggestionKind.Affiliation ? (Affiliation.Person2?.Name ?? Affiliation.Person2Id.ToString()) : (Relation.Person2?.Name ?? Relation.Person2Id.ToString());
[BindProperty] [BindProperty]
public GanjoorPersonRelationEditSuggestion Suggestion { get; set; } public GanjoorPersonRelationEditSuggestion Suggestion { get; set; }
[BindProperty] [BindProperty]
public string Action { get; set; } // "Modify" or "Remove", from the posted radio buttons public string Action { get; set; } // "Modify" or "Remove", from the posted radio buttons
private async Task<bool> PrepareRelationAsync(int relationId) private async Task<bool> PrepareAsync(int? relationId, int? affiliationId)
{ {
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/people/relations/{relationId}"); if (affiliationId == null && relationId == null)
{
LastError = "شناسهٔ نسبت یا وابستگی مشخص نشده است.";
return false;
}
if (affiliationId != null)
{
Kind = PersonRelationSuggestionKind.Affiliation;
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/people/affiliations/{affiliationId.Value}");
if (!response.IsSuccessStatusCode)
{
LastError = await ReadErrorMessageAsync(response);
return false;
}
Affiliation = JsonConvert.DeserializeObject<GanjoorPersonAffiliation>(await response.Content.ReadAsStringAsync());
if (Affiliation == null)
{
LastError = "وابستگی‌ای با این کد پیدا نشد.";
return false;
}
return true;
}
else
{
Kind = PersonRelationSuggestionKind.Family;
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/people/relations/{relationId.Value}");
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
LastError = await ReadErrorMessageAsync(response); LastError = await ReadErrorMessageAsync(response);
@ -53,14 +103,31 @@ namespace GanjooRazor.Areas.User.Pages
return true; return true;
} }
}
private void FillSuggestionFromCurrentRelation() private void FillSuggestionFromCurrent()
{ {
// pre-filled with the relation's CURRENT values, same convention as SuggestPersonEdit - // pre-filled with the edge's CURRENT values, same convention as SuggestPersonEdit -
// submitting a plain "Modify" without changing anything is a harmless no-op // submitting a plain "Modify" without changing anything is a harmless no-op
if (Kind == PersonRelationSuggestionKind.Affiliation)
{
Suggestion = new GanjoorPersonRelationEditSuggestion() Suggestion = new GanjoorPersonRelationEditSuggestion()
{ {
Action = PersonRelationSuggestionAction.Modify, Action = PersonRelationSuggestionAction.Modify,
Kind = PersonRelationSuggestionKind.Affiliation,
ExistingAffiliationId = Affiliation.Id,
Person1Id = Affiliation.Person1Id,
Person2Id = Affiliation.Person2Id,
SuggestedAffiliationType = Affiliation.AffiliationType,
SuggestedNote = Affiliation.Note,
};
}
else
{
Suggestion = new GanjoorPersonRelationEditSuggestion()
{
Action = PersonRelationSuggestionAction.Modify,
Kind = PersonRelationSuggestionKind.Family,
ExistingRelationId = Relation.Id, ExistingRelationId = Relation.Id,
Person1Id = Relation.Person1Id, Person1Id = Relation.Person1Id,
Person2Id = Relation.Person2Id, Person2Id = Relation.Person2Id,
@ -69,8 +136,9 @@ namespace GanjooRazor.Areas.User.Pages
SuggestedNote = Relation.Note, SuggestedNote = Relation.Note,
}; };
} }
}
public async Task<IActionResult> OnGetAsync(int relationId) public async Task<IActionResult> OnGetAsync(int? relationId, int? affiliationId)
{ {
InitializeCommonPageState(); InitializeCommonPageState();
@ -79,17 +147,17 @@ namespace GanjooRazor.Areas.User.Pages
return Redirect($"/login?redirect={Uri.EscapeDataString(Request.Path + Request.QueryString)}"); return Redirect($"/login?redirect={Uri.EscapeDataString(Request.Path + Request.QueryString)}");
} }
if (!await PrepareRelationAsync(relationId)) if (!await PrepareAsync(relationId, affiliationId))
{ {
return Page(); return Page();
} }
FillSuggestionFromCurrentRelation(); FillSuggestionFromCurrent();
return Page(); return Page();
} }
public async Task<IActionResult> OnPostSuggestEditAsync(int relationId) public async Task<IActionResult> OnPostSuggestEditAsync(int? relationId, int? affiliationId)
{ {
InitializeCommonPageState(); InitializeCommonPageState();
@ -100,13 +168,23 @@ namespace GanjooRazor.Areas.User.Pages
LastResult = ""; LastResult = "";
if (!await PrepareRelationAsync(relationId)) if (!await PrepareAsync(relationId, affiliationId))
{ {
return Page(); return Page();
} }
Suggestion.ExistingRelationId = Relation.Id; Suggestion.Kind = Kind;
Suggestion.Action = Action == "Remove" ? PersonRelationSuggestionAction.Remove : PersonRelationSuggestionAction.Modify; Suggestion.Action = Action == "Remove" ? PersonRelationSuggestionAction.Remove : PersonRelationSuggestionAction.Modify;
if (Kind == PersonRelationSuggestionKind.Affiliation)
{
Suggestion.ExistingAffiliationId = Affiliation.Id;
Suggestion.ExistingRelationId = null;
}
else
{
Suggestion.ExistingRelationId = Relation.Id;
Suggestion.ExistingAffiliationId = null;
}
using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response)))
{ {
@ -119,13 +197,13 @@ namespace GanjooRazor.Areas.User.Pages
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
LastResult = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()); LastResult = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
FillSuggestionFromCurrentRelation(); FillSuggestionFromCurrent();
return Page(); return Page();
} }
LastResult = $"پیشنهاد شما ثبت شد و پس از بررسی توسط مدیران اعمال خواهد شد. <a role=\"button\" href=\"javascript:void(0)\" onclick=\"PersonWindow.open({Relation.Person1Id})\" class=\"actionlink\">مشاهدهٔ اطلاعات این شخصیت</a>"; LastResult = $"پیشنهاد شما ثبت شد و پس از بررسی توسط مدیران اعمال خواهد شد. <a role=\"button\" href=\"javascript:void(0)\" onclick=\"PersonWindow.open({Person1Id})\" class=\"actionlink\">مشاهدهٔ اطلاعات این شخصیت</a>";
FillSuggestionFromCurrentRelation(); FillSuggestionFromCurrent();
return Page(); return Page();
} }

View File

@ -85,7 +85,13 @@ else
@if (Model.AffiliationRows.Count > 0) @if (Model.AffiliationRows.Count > 0)
{ {
<h3>وابستگی‌های غیرخویشاوندی</h3> <h3>
وابستگی‌های غیرخویشاوندی
@if (Model.LoggedIn)
{
<a href="/User/SuggestNewPersonRelation?personId=@Model.Person.Id" class="up-btn up-btn--ghost up-btn--sm">افزودن وابستگی جدید</a>
}
</h3>
<ul> <ul>
@foreach (var row in Model.AffiliationRows) @foreach (var row in Model.AffiliationRows)
{ {
@ -95,10 +101,21 @@ else
{ {
<text> (@row.Note)</text> <text> (@row.Note)</text>
} }
@if (Model.LoggedIn)
{
<a href="/User/SuggestPersonRelationEdit?affiliationId=@row.AffiliationId" class="up-icon-btn" title="پیشنهاد ویرایش/حذف این وابستگی" aria-label="پیشنهاد ویرایش/حذف این وابستگی">✎</a>
}
</li> </li>
} }
</ul> </ul>
} }
else if (Model.LoggedIn)
{
<h3>
وابستگی‌های غیرخویشاوندی
<a href="/User/SuggestNewPersonRelation?personId=@Model.Person.Id" class="up-btn up-btn--ghost up-btn--sm">افزودن وابستگی جدید</a>
</h3>
}
@if (Model.Poems != null && Model.Poems.Length > 0) @if (Model.Poems != null && Model.Poems.Length > 0)
{ {

View File

@ -61,6 +61,13 @@ namespace GanjooRazor.Pages
public class PersonAffiliationDisplayRow public class PersonAffiliationDisplayRow
{ {
/// <summary>
/// the underlying GanjoorPersonAffiliation row's own id - used to link to
/// /User/SuggestPersonRelationEdit?affiliationId={AffiliationId} for suggesting a
/// change/removal of this edge, same role RelationId plays on PersonRelationDisplayRow
/// </summary>
public int AffiliationId { get; set; }
/// <summary> /// <summary>
/// full Persian sentence with a "{0}" placeholder for where the other person's linked /// full Persian sentence with a "{0}" placeholder for where the other person's linked
/// name goes (kept as a placeholder, rather than a pre-built string, so the .cshtml can /// name goes (kept as a placeholder, rather than a pre-built string, so the .cshtml can
@ -156,6 +163,7 @@ namespace GanjooRazor.Pages
bool subjectServes = a.SubjectIsPerson1 || IsSymmetricAffiliation(a.AffiliationType); bool subjectServes = a.SubjectIsPerson1 || IsSymmetricAffiliation(a.AffiliationType);
AffiliationRows.Add(new PersonAffiliationDisplayRow() AffiliationRows.Add(new PersonAffiliationDisplayRow()
{ {
AffiliationId = a.Id,
SentenceBeforeOtherName = subjectServes ? $"این شخصیت {roleWord} " : "", SentenceBeforeOtherName = subjectServes ? $"این شخصیت {roleWord} " : "",
SentenceAfterOtherName = subjectServes ? " بود" : $" {roleWord} این شخصیت بود", SentenceAfterOtherName = subjectServes ? " بود" : $" {roleWord} این شخصیت بود",
OtherPersonId = a.OtherPersonId, OtherPersonId = a.OtherPersonId,

View File

@ -245,6 +245,24 @@ namespace RMuseum.Controllers
return Ok(res.Result); return Ok(res.Result);
} }
/// <summary>
/// get a single affiliation edge by its own id, with both sides' names resolved - used by
/// /SuggestPersonRelationEdit?affiliationId={affiliationId} to show what it's about
/// </summary>
/// <param name="affiliationId"></param>
/// <returns></returns>
[HttpGet("affiliations/{affiliationId:int}")]
[AllowAnonymous]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPersonAffiliation))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetAffiliationByIdAsync(int affiliationId)
{
var res = await _personService.GetAffiliationByIdAsync(affiliationId);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);
}
/// <summary> /// <summary>
/// suggest an addition, change or removal of a kinship edge - any logged-in user, same as /// suggest an addition, change or removal of a kinship edge - any logged-in user, same as
/// suggesting a person edit. Goes into the pending queue; does not change anything. /// suggesting a person edit. Goes into the pending queue; does not change anything.

View File

@ -74,6 +74,13 @@ namespace RMuseum.Models.Ganjoor.ViewModels
/// </summary> /// </summary>
public class GanjoorPersonAffiliationInfo public class GanjoorPersonAffiliationInfo
{ {
/// <summary>
/// the underlying GanjoorPersonAffiliation row's own id - used to link to
/// /User/SuggestPersonRelationEdit?affiliationId={Id} for suggesting a change/removal of
/// this edge, same role RelationId plays on GanjoorPersonRelationInfo
/// </summary>
public int Id { get; set; }
/// <summary> /// <summary>
/// the other person in this tie /// the other person in this tie
/// </summary> /// </summary>

View File

@ -2929,6 +2929,14 @@
<param name="relationId"></param> <param name="relationId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:RMuseum.Controllers.GanjoorRelatedPersonController.GetAffiliationByIdAsync(System.Int32)">
<summary>
get a single affiliation edge by its own id, with both sides' names resolved - used by
/SuggestPersonRelationEdit?affiliationId={affiliationId} to show what it's about
</summary>
<param name="affiliationId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorRelatedPersonController.SuggestPersonRelationEditAsync(RMuseum.Models.Ganjoor.GanjoorPersonRelationEditSuggestion)"> <member name="M:RMuseum.Controllers.GanjoorRelatedPersonController.SuggestPersonRelationEditAsync(RMuseum.Models.Ganjoor.GanjoorPersonRelationEditSuggestion)">
<summary> <summary>
suggest an addition, change or removal of a kinship edge - any logged-in user, same as suggest an addition, change or removal of a kinship edge - any logged-in user, same as
@ -13559,6 +13567,13 @@
as GanjoorPersonRelationInfo above, but for a non-family tie as GanjoorPersonRelationInfo above, but for a non-family tie
</summary> </summary>
</member> </member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPersonAffiliationInfo.Id">
<summary>
the underlying GanjoorPersonAffiliation row's own id - used to link to
/User/SuggestPersonRelationEdit?affiliationId={Id} for suggesting a change/removal of
this edge, same role RelationId plays on GanjoorPersonRelationInfo
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPersonAffiliationInfo.OtherPersonId"> <member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPersonAffiliationInfo.OtherPersonId">
<summary> <summary>
the other person in this tie the other person in this tie
@ -18422,6 +18437,14 @@
<param name="relationId"></param> <param name="relationId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:RMuseum.Services.IGanjoorRelatedPersonService.GetAffiliationByIdAsync(System.Int32)">
<summary>
get a single affiliation edge by its own id, with both sides' names resolved - used by
/User/SuggestPersonRelationEdit?affiliationId={affiliationId} to show what it's about
</summary>
<param name="affiliationId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorRelatedPersonService.SuggestPersonRelationEditAsync(RMuseum.Models.Ganjoor.GanjoorPersonRelationEditSuggestion)"> <member name="M:RMuseum.Services.IGanjoorRelatedPersonService.SuggestPersonRelationEditAsync(RMuseum.Models.Ganjoor.GanjoorPersonRelationEditSuggestion)">
<summary> <summary>
submit a suggested addition, change or removal of a kinship edge - goes into the submit a suggested addition, change or removal of a kinship edge - goes into the
@ -21997,6 +22020,15 @@
<param name="relationId"></param> <param name="relationId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:RMuseum.Services.Implementation.GanjoorRelatedPersonService.GetAffiliationByIdAsync(System.Int32)">
<summary>
get a single affiliation edge by its own id, with both sides' names resolved - the
Kind == Affiliation counterpart of GetRelationByIdAsync, used the same way by
/User/SuggestPersonRelationEdit?affiliationId={id}
</summary>
<param name="affiliationId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorRelatedPersonService.SuggestPersonRelationEditAsync(RMuseum.Models.Ganjoor.GanjoorPersonRelationEditSuggestion)"> <member name="M:RMuseum.Services.Implementation.GanjoorRelatedPersonService.SuggestPersonRelationEditAsync(RMuseum.Models.Ganjoor.GanjoorPersonRelationEditSuggestion)">
<summary> <summary>
submit a suggested addition, change or removal of a kinship edge submit a suggested addition, change or removal of a kinship edge

View File

@ -105,6 +105,14 @@ namespace RMuseum.Services
/// <returns></returns> /// <returns></returns>
Task<RServiceResult<GanjoorPersonRelation>> GetRelationByIdAsync(int relationId); Task<RServiceResult<GanjoorPersonRelation>> GetRelationByIdAsync(int relationId);
/// <summary>
/// get a single affiliation edge by its own id, with both sides' names resolved - used by
/// /User/SuggestPersonRelationEdit?affiliationId={affiliationId} to show what it's about
/// </summary>
/// <param name="affiliationId"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPersonAffiliation>> GetAffiliationByIdAsync(int affiliationId);
/// <summary> /// <summary>
/// submit a suggested addition, change or removal of a kinship edge - goes into the /// submit a suggested addition, change or removal of a kinship edge - goes into the
/// pending queue, does not change anything until a moderator approves it /// pending queue, does not change anything until a moderator approves it

View File

@ -123,6 +123,7 @@ namespace RMuseum.Services.Implementation
var affiliations = affiliationRows.Select(a => new GanjoorPersonAffiliationInfo() var affiliations = affiliationRows.Select(a => new GanjoorPersonAffiliationInfo()
{ {
Id = a.Id,
OtherPersonId = a.Person1Id == id ? a.Person2Id : a.Person1Id, OtherPersonId = a.Person1Id == id ? a.Person2Id : a.Person1Id,
OtherPersonName = a.Person1Id == id ? a.Person2.Name : a.Person1.Name, OtherPersonName = a.Person1Id == id ? a.Person2.Name : a.Person1.Name,
AffiliationType = a.AffiliationType, AffiliationType = a.AffiliationType,
@ -540,6 +541,36 @@ namespace RMuseum.Services.Implementation
} }
} }
/// <summary>
/// get a single affiliation edge by its own id, with both sides' names resolved - the
/// Kind == Affiliation counterpart of GetRelationByIdAsync, used the same way by
/// /User/SuggestPersonRelationEdit?affiliationId={id}
/// </summary>
/// <param name="affiliationId"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPersonAffiliation>> GetAffiliationByIdAsync(int affiliationId)
{
try
{
var affiliation = await _context.GanjoorPersonAffiliations
.Include(a => a.Person1)
.Include(a => a.Person2)
.Where(a => a.Id == affiliationId)
.SingleOrDefaultAsync();
if (affiliation == null)
{
return new RServiceResult<GanjoorPersonAffiliation>(null, "وابستگی پیدا نشد.");
}
return new RServiceResult<GanjoorPersonAffiliation>(affiliation);
}
catch (Exception exp)
{
return new RServiceResult<GanjoorPersonAffiliation>(null, exp.ToString());
}
}
/// <summary> /// <summary>
/// submit a suggested addition, change or removal of a kinship edge /// submit a suggested addition, change or removal of a kinship edge
/// </summary> /// </summary>