/// <summary> /// Search OccurrenceTranslation by id. /// </summary> /// <param name="request">The OccurrenceTranslation Request Pivot to retrive.</param> /// <returns>OccurrenceTranslation Response Pivot response.</returns> public OccurrenceTranslationResponsePivot FindOccurrenceTranslations(OccurrenceTranslationRequestPivot request) { if (request?.OccurrenceTranslationPivot == null) { throw new ArgumentNullException(nameof(request)); } List <OccurrenceTranslationPivot> results = new List <OccurrenceTranslationPivot>(); OccurrenceTranslationPivot result = new OccurrenceTranslationPivot(); switch (request.FindOccurrenceTranslationPivot) { case FindOccurrenceTranslationPivot.OccurrenceTranslationId: result = _unitOfWork.OccurrenceTranslationRepository.GetById(request.OccurrenceTranslationPivot.TranslationId)?.ToPivot(); break; case FindOccurrenceTranslationPivot.OccurrenceId: results = _unitOfWork.OccurrenceTranslationRepository.Get(o => o.OccurrenceId == request.OccurrenceTranslationPivot.OccurrenceId, null, "Occurrence,Language")?.ToList().ToPivotList(); break; } return(new OccurrenceTranslationResponsePivot() { OccurrenceTranslationPivotList = results, OccurrenceTranslationPivot = result }); }
/// <summary> /// From OccurrenceTranslationPivot to OccurrenceTranslation. /// </summary> /// <param name="occurrenceTranslationPivot">occurrenceTranslationPivot to assemble.</param> /// <returns>OccurrenceTranslation result.</returns> public static OccurrenceTranslation ToEntity(this OccurrenceTranslationPivot occurrenceTranslationPivot) { if (occurrenceTranslationPivot == null) { return(null); } return(new OccurrenceTranslation() { TranslationId = occurrenceTranslationPivot.TranslationId, OccurrenceTitle = occurrenceTranslationPivot.OccurrenceTitle, OccurrenceDescription = occurrenceTranslationPivot.OccurrenceDescription, OccurrenceId = occurrenceTranslationPivot.OccurrenceId, Occurrence = occurrenceTranslationPivot.Occurrence.ToEntity(), LanguageId = occurrenceTranslationPivot.LanguageId, Language = occurrenceTranslationPivot.Language.ToEntity() }); }