/// <summary> /// Search SectionTranslation by id. /// </summary> /// <param name="request">The SectionTranslation Request Pivot to retrive.</param> /// <returns>SectionTranslation Response Pivot response.</returns> public SectionTranslationResponsePivot FindSectionTranslations(SectionTranslationRequestPivot request) { if (request?.SectionTranslationPivot == null) { throw new ArgumentNullException(nameof(request)); } List <SectionTranslationPivot> results = new List <SectionTranslationPivot>(); SectionTranslationPivot result = new SectionTranslationPivot(); switch (request.FindSectionTranslationPivot) { case FindSectionTranslationPivot.SectionTranslationId: result = _unitOfWork.SectionTranslationRepository.GetById(request.SectionTranslationPivot.TranslationId)?.ToPivot(); break; case FindSectionTranslationPivot.SectionId: results = _unitOfWork.SectionTranslationRepository.Get(o => o.SectionId == request.SectionTranslationPivot.SectionId, null, "Section,Language")?.ToList().ToPivotList(); break; } return(new SectionTranslationResponsePivot() { SectionTranslationPivotList = results, SectionTranslationPivot = result }); }
/// <summary> /// Remove SectionTranslation. /// </summary> /// <param name="request">The SectionTranslation Request Pivot to remove.</param> public void DeleteSectionTranslation(SectionTranslationRequestPivot request) { if (request?.SectionTranslationPivot == null) { throw new ArgumentNullException(nameof(request)); } SectionTranslation sectionTranslation = _unitOfWork.SectionTranslationRepository.GetById(request.SectionTranslationPivot.TranslationId); _unitOfWork.SectionTranslationRepository.Delete(sectionTranslation); _unitOfWork.Save(); }
/// <summary> /// Change SectionTranslation values. /// </summary> /// <param name="request">The SectionTranslation Request Pivot to change.</param> public void UpdateSectionTranslation(SectionTranslationRequestPivot request) { if (request?.SectionTranslationPivot == null) { throw new ArgumentNullException(nameof(request)); } SectionTranslation sectionTranslation = _unitOfWork.SectionTranslationRepository.GetById(request.SectionTranslationPivot.TranslationId); sectionTranslation.SectionDesciption = request.SectionTranslationPivot.SectionDesciption; sectionTranslation.SectionTitle = request.SectionTranslationPivot.SectionTitle; _unitOfWork.Save(); }
/// <summary> /// Change SectionTranslation values. /// </summary> /// <param name="request">The SectionTranslation Request Pivot to change.</param> public void UpdateSectionTranslationRange(SectionTranslationRequestPivot request) { if (request?.SectionTranslationPivotList == null) { throw new ArgumentNullException(nameof(request)); } foreach (var item in request.SectionTranslationPivotList) { SectionTranslation sectionTranslation = _unitOfWork.SectionTranslationRepository.GetById(item.TranslationId); sectionTranslation.SectionDesciption = item.SectionDesciption; sectionTranslation.SectionTitle = item.SectionTitle; _unitOfWork.Save(); } }
/// <summary> /// Create new SectionTranslation. /// </summary> /// <param name="request">The SectionTranslation Request Pivot to add.</param> /// <returns>SectionTranslation Response Pivot created.</returns> public SectionTranslationResponsePivot CreateSectionTranslationRange(SectionTranslationRequestPivot request) { if (request?.SectionTranslationPivotList == null) { throw new ArgumentNullException(nameof(request)); } List <SectionTranslation> sectionTranslationList = request.SectionTranslationPivotList.ToEntityList(); _unitOfWork.SectionTranslationRepository.Insert(sectionTranslationList); _unitOfWork.Save(); return(new SectionTranslationResponsePivot { SectionTranslationPivotList = sectionTranslationList.ToPivotList() }); }