/// <summary> /// Search StepParagraph by id. /// </summary> /// <param name="request">The StepParagraph Request Pivot to retrive.</param> /// <returns>StepParagraph Response Pivot response.</returns> public StepParagraphResponsePivot FindStepParagraphs(StepParagraphRequestPivot request) { if (request?.StepParagraphPivot == null) { throw new ArgumentNullException(nameof(request)); } List <StepParagraphPivot> results = new List <StepParagraphPivot>(); StepParagraphPivot result = new StepParagraphPivot(); switch (request.FindStepParagraphPivot) { case FindStepParagraphPivot.StepParagraphId: result = _unitOfWork.StepParagraphRepository.GetById(request.StepParagraphPivot.ParagraphId)?.ToPivot(); break; case FindStepParagraphPivot.StepId: results = _unitOfWork.StepParagraphRepository.Get(p => p.StepId == request.StepParagraphPivot.StepId)?.ToList().ToPivotList(); break; } return(new StepParagraphResponsePivot { StepParagraphPivotList = results, StepParagraphPivot = result }); }
/// <summary> /// Remove StepParagraph. /// </summary> /// <param name="request">The StepParagraph Request Pivot to remove.</param> public void DeleteStepParagraph(StepParagraphRequestPivot request) { if (request?.StepParagraphPivot == null) { throw new ArgumentNullException(nameof(request)); } StepParagraph stepParagraph = _unitOfWork.StepParagraphRepository.GetById(request.StepParagraphPivot.ParagraphId); _unitOfWork.StepParagraphRepository.Delete(stepParagraph); _unitOfWork.Save(); }
/// <summary> /// Remove StepParagraph. /// </summary> /// <param name="stepParagraphRequestPivot">The StepParagraph Request Pivot to remove.</param> public void DeleteStepParagraph(StepParagraphRequestPivot stepParagraphRequestPivot) { if (stepParagraphRequestPivot == null) { throw new Exception("The request pivot is null."); } StepParagraph stepParagraph = UnitOfWork.StepParagraphRepository.GetByID(stepParagraphRequestPivot.StepParagraphPivot.ParagraphId); stepParagraph.Deleted = true; UnitOfWork.Save(); }
/// <summary> /// Change StepParagraph values. /// </summary> /// <param name="stepParagraphRequestPivot">The StepParagraph Request Pivot to change.</param> public void UpdateStepParagraph(StepParagraphRequestPivot stepParagraphRequestPivot) { if (stepParagraphRequestPivot == null) { throw new Exception("The request pivot is null."); } StepParagraph stepParagraph = UnitOfWork.StepParagraphRepository.GetByID(stepParagraphRequestPivot.StepParagraphPivot.ParagraphId); UnitOfWork.StepParagraphRepository.DetachObject(stepParagraph); UnitOfWork.StepParagraphRepository.Update(stepParagraphRequestPivot.StepParagraphPivot.ToStepParagraph()); UnitOfWork.Save(); }
/// <summary> /// Create new StepParagraph. /// </summary> /// <param name="stepParagraphRequestPivot">The StepParagraph Request Pivot to add.</param> /// <returns>StepParagraph Response Pivot created.</returns> public StepParagraphResponsePivot CreateStepParagraph(StepParagraphRequestPivot stepParagraphRequestPivot) { if (stepParagraphRequestPivot == null) { throw new Exception("The request pivot is null."); } StepParagraph stepParagraph = stepParagraphRequestPivot.StepParagraphPivot.ToStepParagraph(); UnitOfWork.StepParagraphRepository.Insert(stepParagraph); UnitOfWork.Save(); return(new StepParagraphResponsePivot() { StepParagraphPivot = stepParagraph.ToPivot() }); }
/// <summary> /// Create new StepParagraph. /// </summary> /// <param name="request">The StepParagraph Request Pivot to add.</param> /// <returns>StepParagraph Response Pivot created.</returns> public StepParagraphResponsePivot CreateStepParagraph(StepParagraphRequestPivot request) { if (request?.StepParagraphPivot == null) { throw new ArgumentNullException(nameof(request)); } StepParagraph stepParagraph = request.StepParagraphPivot.ToEntity(); _unitOfWork.StepParagraphRepository.Insert(stepParagraph); _unitOfWork.Save(); return(new StepParagraphResponsePivot { StepParagraphPivot = stepParagraph.ToPivot() }); }
/// <summary> /// Search StepParagraph by id. /// </summary> /// <param name="stepParagraphRequestPivot">The StepParagraph Request Pivot to retrive.</param> /// <returns>StepParagraph Response Pivot response.</returns> public StepParagraphResponsePivot FindStepParagraph(StepParagraphRequestPivot stepParagraphRequestPivot) { if (stepParagraphRequestPivot == null) { throw new Exception("The request pivot is null."); } List <StepParagraphPivot> results = new List <StepParagraphPivot>(); StepParagraphPivot result = new StepParagraphPivot(); switch (stepParagraphRequestPivot.FindStepParagraphPivot) { case FindStepParagraphPivot.StepParagraphId: result = UnitOfWork.StepParagraphRepository.GetById(stepParagraphRequestPivot.StepParagraphPivot.ParagraphId)?.ToPivot(); break; } return(new StepParagraphResponsePivot() { StepParagraphPivotList = results, StepParagraphPivot = result }); }