Example #1
0
        /// <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();
        }
Example #2
0
        /// <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();
        }
Example #3
0
        /// <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()
            });
        }
Example #4
0
        /// <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
            });
        }