public async Task <IActionResult> LabelTranslationRevisionsData(Guid id) { var labelTranslationUid = id; if (labelTranslationUid.IsEmptyGuid()) { return(NotFound()); } var request = new LabelTranslationRevisionReadListRequest(CurrentUser.Id, labelTranslationUid); var response = await _labelService.GetLabelTranslationRevisions(request); if (response.Status.IsNotSuccess) { return(NotFound()); } var result = new DataResult(); result.AddHeaders("revision", "revisioned_by", "revisioned_at", "label_translation_name", "created_at", ""); for (var i = 0; i < response.Items.Count; i++) { var revisionItem = response.Items[i]; var item = revisionItem.Item; var stringBuilder = new StringBuilder(); stringBuilder.Append($"{item.Uid}{DataResult.SEPARATOR}"); stringBuilder.Append($"{revisionItem.Revision}{DataResult.SEPARATOR}"); stringBuilder.Append($"{revisionItem.RevisionedByName}{DataResult.SEPARATOR}"); stringBuilder.Append($"{GetDateTimeAsString(revisionItem.RevisionedAt)}{DataResult.SEPARATOR}"); stringBuilder.Append($"{result.PrepareLink($"/Label/Detail/{item.Uid}", item.Name)}{DataResult.SEPARATOR}"); stringBuilder.Append($"{GetDateTimeAsString(item.CreatedAt)}{DataResult.SEPARATOR}"); stringBuilder.Append($"{result.PrepareRestoreButton("restore", "/Label/RestoreLabelTranslation/", "/Label/LabelTranslationDetail")}{DataResult.SEPARATOR}"); result.Data.Add(stringBuilder.ToString()); } return(Json(result)); }
public async Task <LabelTranslationRevisionReadListResponse> GetLabelTranslationRevisions(LabelTranslationRevisionReadListRequest request) { var response = new LabelTranslationRevisionReadListResponse(); var currentUser = _cacheManager.GetCachedCurrentUser(request.CurrentUserId); var labelTranslation = await _labelTranslationRepository.Select(x => x.Uid == request.LabelTranslationUid); if (labelTranslation.IsNotExist()) { response.SetInvalid(); response.ErrorMessages.Add("label_translation_not_active"); return(response); } var revisions = await _labelTranslationRepository.SelectRevisions(labelTranslation.Id); for (int i = 0; i < revisions.Count; i++) { var revision = revisions[i]; var revisionDto = new RevisionDto <LabelTranslationDto>(); revisionDto.Revision = revision.Revision; revisionDto.RevisionedAt = revision.RevisionedAt; var user = _cacheManager.GetCachedUser(revision.RevisionedBy); revisionDto.RevisionedByUid = user.Uid; revisionDto.RevisionedByName = user.Name; revisionDto.Item = _labelTranslationFactory.CreateDtoFromEntity(revision.Entity); response.Items.Add(revisionDto); } response.Status = ResponseStatus.Success; return(response); }
public static LabelTranslationRevisionReadListRequest GetLabelTranslationRevisionReadListRequest() { var request = new LabelTranslationRevisionReadListRequest(CurrentUserId, UidOne); return(request); }