/// <summary> /// Remove Occurrence. /// </summary> /// <param name="request">The Occurrence Request Pivot to remove.</param> public void DeleteOccurrence(OccurrenceRequestPivot request) { if (request?.OccurrencePivot == null) { throw new ArgumentNullException(nameof(request)); } Occurrence occurrence = _unitOfWork.OccurrenceRepository.GetById(request.OccurrencePivot.OccurrenceId); _unitOfWork.OccurrenceRepository.Delete(occurrence); _unitOfWork.Save(); }
/// <summary> /// Change Occurrence values. /// </summary> /// <param name="request">The Occurrence Request Pivot to change.</param> public void UpdateOccurrence(OccurrenceRequestPivot request) { if (request?.OccurrencePivot == null) { throw new ArgumentNullException(nameof(request)); } Occurrence occurrence = _unitOfWork.OccurrenceRepository.GetById(request.OccurrencePivot.OccurrenceId); occurrence.OccurrenceStartDate = request.OccurrencePivot.OccurrenceStartDate; occurrence.OccurrenceEndDate = request.OccurrencePivot.OccurrenceEndDate; occurrence.OccurrenceLink = request.OccurrencePivot.OccurrenceLink; _unitOfWork.Save(); }
/// <summary> /// Create new Occurrence. /// </summary> /// <param name="request">The Occurrence Request Pivot to add.</param> /// <returns>Occurrence Response Pivot created.</returns> public OccurrenceResponsePivot CreateOccurrence(OccurrenceRequestPivot request) { if (request?.OccurrencePivot == null) { throw new ArgumentNullException(nameof(request)); } Occurrence occurrence = request.OccurrencePivot.ToEntity(); _unitOfWork.OccurrenceRepository.Insert(occurrence); _unitOfWork.Save(); return(new OccurrenceResponsePivot { OccurrencePivot = occurrence.ToPivot() }); }
/// <summary> /// Search Occurrence by id. /// </summary> /// <param name="request">The Occurrence Request Pivot to retrive.</param> /// <returns>Occurrence Response Pivot response.</returns> public OccurrenceResponsePivot FindOccurrences(OccurrenceRequestPivot request) { if (request?.OccurrencePivot == null) { throw new ArgumentNullException(nameof(request)); } List <OccurrencePivot> results = new List <OccurrencePivot>(); OccurrencePivot result = new OccurrencePivot(); switch (request.FindOccurrencePivot) { case FindOccurrencePivot.OccurrenceId: result = _unitOfWork.OccurrenceRepository.GetById(request.OccurrencePivot.OccurrenceId).ToPivot(); break; } return(new OccurrenceResponsePivot { OccurrencePivotList = results, OccurrencePivot = result }); }