docs: #275 GanjoorPoetSuggestedSpecLine crud methods is now complete
This commit is contained in:
parent
e6a18140cd
commit
1097d456e0
@ -10438,6 +10438,37 @@
|
||||
<param name="metre"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoetSuggestedSpecLinesAsync(System.Int32,System.Nullable{System.Guid},System.Boolean)">
|
||||
<summary>
|
||||
return list of suggested spec lines
|
||||
</summary>
|
||||
<param name="poetId"></param>
|
||||
<param name="userId"></param>
|
||||
<param name="includeUnpublished"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.AddPoetSuggestedSpecLinesAsync(RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetSuggestedSpecLineViewModel)">
|
||||
<summary>
|
||||
add a suggestion for poets spec lines
|
||||
</summary>
|
||||
<param name="model"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.ModifyPoetSuggestedSpecLinesAsync(RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetSuggestedSpecLineViewModel)">
|
||||
<summary>
|
||||
modify a suggestion for poets spec lines
|
||||
</summary>
|
||||
<param name="model"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.DeletePoetSuggestedSpecLinesAsync(System.Int32,System.Guid)">
|
||||
<summary>
|
||||
delete a suggestion for poets spec lines
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="deleteUserId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IGanjoorTranslationService">
|
||||
<summary>
|
||||
translation service implementation
|
||||
@ -11840,6 +11871,21 @@
|
||||
<param name="model"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.ModifyPoetSuggestedSpecLinesAsync(RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetSuggestedSpecLineViewModel)">
|
||||
<summary>
|
||||
modify a suggestion for poets spec lines
|
||||
</summary>
|
||||
<param name="model"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.DeletePoetSuggestedSpecLinesAsync(System.Int32,System.Guid)">
|
||||
<summary>
|
||||
delete a suggestion for poets spec lines
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="deleteUserId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartFindingMissingRhythms(System.Boolean,System.Int32)">
|
||||
<summary>
|
||||
Start finding missing rhthms
|
||||
|
||||
@ -734,5 +734,37 @@ namespace RMuseum.Services
|
||||
/// <param name="metre"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> SaveGanjoorPoemProbableMetre(int id, string metre);
|
||||
|
||||
/// <summary>
|
||||
/// return list of suggested spec lines
|
||||
/// </summary>
|
||||
/// <param name="poetId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="includeUnpublished"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoetSuggestedSpecLineViewModel[]>> GetPoetSuggestedSpecLinesAsync(int poetId, Guid? userId, bool includeUnpublished);
|
||||
|
||||
/// <summary>
|
||||
/// add a suggestion for poets spec lines
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
Task<RServiceResult<GanjoorPoetSuggestedSpecLineViewModel>> AddPoetSuggestedSpecLinesAsync(GanjoorPoetSuggestedSpecLineViewModel model);
|
||||
|
||||
/// <summary>
|
||||
/// modify a suggestion for poets spec lines
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> ModifyPoetSuggestedSpecLinesAsync(GanjoorPoetSuggestedSpecLineViewModel model);
|
||||
|
||||
/// <summary>
|
||||
/// delete a suggestion for poets spec lines
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="deleteUserId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> DeletePoetSuggestedSpecLinesAsync(int id, Guid deleteUserId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,5 +80,77 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<GanjoorPoetSuggestedSpecLineViewModel>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modify a suggestion for poets spec lines
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> ModifyPoetSuggestedSpecLinesAsync(GanjoorPoetSuggestedSpecLineViewModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var dbModel = await _context.GanjoorPoetSuggestedSpecLines.Where(s => s.Id == model.Id).SingleAsync();
|
||||
bool publishIsChanged = model.Published != dbModel.Published;
|
||||
dbModel.LineOrder = model.LineOrder;
|
||||
dbModel.Contents = model.Contents;
|
||||
dbModel.Published = model.Published;
|
||||
_context.Update(dbModel);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
if(publishIsChanged && model.Published && dbModel.SuggestedById != null)
|
||||
{
|
||||
var userRes = await _appUserService.GetUserInformation((Guid)dbModel.SuggestedById);
|
||||
var poet = await _context.GanjoorPoets.AsNoTracking().Where(p => p.Id == dbModel.PoetId).SingleAsync();
|
||||
await _notificationService.PushNotification((Guid)dbModel.SuggestedById,
|
||||
$"پذیرش مشارکت شما در مشخصات {poet.Nickname}",
|
||||
$"با سپاس! پیشنهاد شما برای مشخصات {poet.Nickname} مورد پذیرش قرار گرفت. پیشنها شما: {Environment.NewLine}" +
|
||||
$"{model.Contents}"
|
||||
);
|
||||
}
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// delete a suggestion for poets spec lines
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="deleteUserId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> DeletePoetSuggestedSpecLinesAsync(int id, Guid deleteUserId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dbModel = await _context.GanjoorPoetSuggestedSpecLines.Where(s => s.Id == id).SingleAsync();
|
||||
|
||||
|
||||
if (!dbModel.Published && dbModel.SuggestedById != null && deleteUserId != dbModel.SuggestedById)
|
||||
{
|
||||
var userRes = await _appUserService.GetUserInformation((Guid)dbModel.SuggestedById);
|
||||
var poet = await _context.GanjoorPoets.AsNoTracking().Where(p => p.Id == dbModel.PoetId).SingleAsync();
|
||||
await _notificationService.PushNotification((Guid)dbModel.SuggestedById,
|
||||
$"عدم پذیرش مشارکت شما در مشخصات {poet.Nickname}",
|
||||
$"متأسفانه پیشنهاد شما برای مشخصات {poet.Nickname} مورد پذیرش قرار نگرفت. پیشنها شما: {Environment.NewLine}" +
|
||||
$"{dbModel.Contents}"
|
||||
);
|
||||
}
|
||||
|
||||
_context.Remove(dbModel);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user