/// <summary> /// Search ActivityFile by id. /// </summary> /// <param name="request">The ActivityFile Request Pivot to retrive.</param> /// <returns>ActivityFile Response Pivot response.</returns> public ActivityFileResponsePivot FindActivityFiles(ActivityFileRequestPivot request) { if (request?.ActivityFilePivot == null) { throw new ArgumentNullException(nameof(request)); } List <ActivityFilePivot> results = new List <ActivityFilePivot>(); ActivityFilePivot result = new ActivityFilePivot(); switch (request.FindActivityFilePivot) { case FindActivityFilePivot.ActivityFileId: result = _unitOfWork.ActivityFileRepository.Get(f => f.ActivityFileId == request.ActivityFilePivot.ActivityFileId, null, "Activity")?.FirstOrDefault().ToPivot(); break; case FindActivityFilePivot.ActivityId: results = _unitOfWork.ActivityFileRepository.Get(f => f.ActivityId == request.ActivityFilePivot.ActivityId, null, "Activity")?.ToList().ToPivotList(); break; } return(new ActivityFileResponsePivot { ActivityFilePivotList = results, ActivityFilePivot = result }); }
/// <summary> /// Remove ActivityFile. /// </summary> /// <param name="request">The ActivityFile Request Pivot to remove.</param> public void DeleteActivityFile(ActivityFileRequestPivot request) { if (request?.ActivityFilePivot == null) { throw new ArgumentNullException(nameof(request)); } ActivityFile activityFile = _unitOfWork.ActivityFileRepository.GetById(request.ActivityFilePivot.ActivityFileId); _unitOfWork.ActivityFileRepository.Delete(activityFile); _unitOfWork.Save(); }
/// <summary> /// Create new ActivityFile. /// </summary> /// <param name="request">The ActivityFile Request Pivot to add.</param> /// <returns>ActivityFile Response Pivot created.</returns> public ActivityFileResponsePivot CreateActivityFile(ActivityFileRequestPivot request) { if (request?.ActivityFilePivot == null) { throw new ArgumentNullException(nameof(request)); } ActivityFile activityFile = request.ActivityFilePivot.ToEntity(); _unitOfWork.ActivityFileRepository.Insert(activityFile); _unitOfWork.Save(); return(new ActivityFileResponsePivot { ActivityFilePivot = activityFile.ToPivot() }); }