Skip to content

Commit

Permalink
Implemented evne the skill planning module, fixed minor bugs, improve…
Browse files Browse the repository at this point in the history
…d general handling
  • Loading branch information
Steffen Nörtershäuser committed Mar 11, 2018
1 parent 51e6ed8 commit 84bcf7c
Show file tree
Hide file tree
Showing 320 changed files with 37,820 additions and 6,517 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,5 @@ NpcImages/**
KirjaFiles/**
ItemImages/**
MapImages/*/**
TaskImages/**
TaskImages/**
SkillImages/**
57 changes: 55 additions & 2 deletions Controllers/Api/AikaApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ public class ChapterDetailQueryResult
public IList<AikaChapterDetail> Details { get; set; }
}

/// <summary>
/// Chapter Detail Delete Validation Result
/// </summary>
public class ChapterDetailDeleteValidationResult
{
/// <summary>
/// true if the detail can be deleted
/// </summary>
public bool CanBeDeleted { get; set; }

/// <summary>
/// Error Message
/// </summary>
public string ErrorMessage { get; set; }
}

/// <summary>
/// Chapter Overview Db Service
/// </summary>
Expand Down Expand Up @@ -611,6 +627,43 @@ public async Task<IActionResult> GetChapterDetailsByQuest(string questId)
return Ok(details);
}

/// <summary>
/// Returns if a chapter detail can be deleted
/// </summary>
/// <param name="id">Id of the Chapter Detail</param>
/// <returns>Chapter detaildelete validation result</returns>
[HttpGet]
public async Task<IActionResult> ValidateChapterDetailDelete(string id)
{
if(string.IsNullOrEmpty(id))
{
return StatusCode((int)HttpStatusCode.BadRequest);
}

AikaChapterDetail detail = await _chapterDetailDbAccess.GetChapterDetailById(id);
ChapterDetailDeleteValidationResult validationResult = new ChapterDetailDeleteValidationResult();
validationResult.CanBeDeleted = true;

if((detail.Finish != null && detail.Finish.Count > 0) || (detail.Detail != null && detail.Detail.Count > 0) ||
(detail.Quest != null && detail.Quest.Count > 0) || (detail.AllDone != null && detail.AllDone.Count > 0))
{
bool isDetailView = string.IsNullOrEmpty(detail.ChapterId);
bool canBeDeleted = false;
if(isDetailView)
{
canBeDeleted = await _chapterDetailDbAccess.DetailUsedInNodesCount(id, string.Empty) > 1;
}

if(!canBeDeleted)
{
validationResult.CanBeDeleted = false;
validationResult.ErrorMessage = isDetailView ? _localizer["CanNotDeleteNonEmptyChapterDetail"].Value : _localizer["CanNotDeleteNonEmptyChapter"].Value;
}
}

return Ok(validationResult);
}


/// <summary>
/// Creates the detail views for detail nodes in a chapter detail
Expand Down Expand Up @@ -738,7 +791,7 @@ public async Task<IActionResult> UpdateChapterDetail(string id, [FromBody]AikaCh
continue;
}

bool detailIsStillUsed = await _chapterDetailDbAccess.IsDetailUsedInOtherNode(curDeletedChapterDetail.DetailViewId, curDeletedChapterDetail.Id);
bool detailIsStillUsed = await _chapterDetailDbAccess.DetailUsedInNodesCount(curDeletedChapterDetail.DetailViewId, curDeletedChapterDetail.Id) > 0;
if(detailIsStillUsed)
{
continue;
Expand Down Expand Up @@ -1017,7 +1070,7 @@ private void CopyValidQuestProperties(AikaQuest targetQuest, AikaQuest sourceQue
FlexFieldApiUtil.SetFieldIdsForNewFields(targetQuest.Fields);

targetQuest.Start = GetStartNodeList(sourceQuest.Start);
targetQuest.Text = sourceQuest.Text != null ? sourceQuest.Text : new List<AikaTextNode>();
targetQuest.Text = sourceQuest.Text != null ? sourceQuest.Text : new List<TextNode>();
targetQuest.Finish = sourceQuest.Finish != null ? sourceQuest.Finish : new List<AikaFinish>();
targetQuest.Condition = sourceQuest.Condition != null ? sourceQuest.Condition : new List<ConditionNode>();
targetQuest.Action = sourceQuest.Action != null ? sourceQuest.Action : new List<ActionNode>();
Expand Down

0 comments on commit 84bcf7c

Please sign in to comment.