/// <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> /// From StepParagraph To StepParagraph Pivot. /// </summary> /// <param name="stepParagraph">stepParagraph TO ASSEMBLE</param> /// <returns>StepParagraphPivot result.</returns> public static StepParagraphPivot ToPivot(this StepParagraph stepParagraph) { if (stepParagraph == null) { return(null); } return(new StepParagraphPivot() { ParagraphId = stepParagraph.ParagraphId, StepId = stepParagraph.StepId.Value, Step = stepParagraph.Step?.ToPivot(), }); }
/// <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() }); }