public async Task <GetJudgeQueryResponse> Handle(GetJudgeQuery request, CancellationToken cancellationToken) { ExecutionStatus <Judge> databaseoperation; if (request.JudgeUniqueId != null) { if (request.queryWitchDataBase == QueryWitchDataBase.WithEventSourcing) { databaseoperation = await _zEsjudgeRepository.GetByIdAsync(request.JudgeUniqueId); } else { databaseoperation = await _judgeRepository.GetByIdAsync(request.JudgeUniqueId); } } else if (request.queryWitchDataBase == QueryWitchDataBase.WithEventSourcing) { databaseoperation = await _zEsjudgeRepository.GetByIdAsync(request.JudeId); } else { databaseoperation = await _judgeRepository.GetByIdAsync(request.JudeId); } if (!databaseoperation.Success) { return(new GetJudgeQueryResponse(databaseoperation.RemoveGeneric())); } var judgeViewModel = _mapper.Map <JudgeViewModel>(databaseoperation.Value); return(new GetJudgeQueryResponse(judgeViewModel)); }
public async Task <PreliminaryAcceptCallForSpeechCommandResponse> Handle(PreliminaryAcceptCallForSpeechCommand request, CancellationToken cancellationToken) { var cfsuniqueId = _mapper.Map <CallForSpeechUniqueId>(request.CallForSpeechUniqueId); var judgeId = _mapper.Map <JudgeId>(request.JudgeId); var databaseOperationCfs = await _callRepository.GetByIdAsync(cfsuniqueId); var databaseOperationJudge = await _judegRepository.GetByIdAsync(judgeId); if (!databaseOperationCfs.Success) { return(new PreliminaryAcceptCallForSpeechCommandResponse(databaseOperationCfs .RemoveGeneric(), "CallForSpeech Problem")); } if (!databaseOperationJudge.Success) { return(new PreliminaryAcceptCallForSpeechCommandResponse(databaseOperationJudge .RemoveGeneric(), "Judge Problem")); } var cfs = databaseOperationCfs.Value; var result = cfs.TryPreliminaryAccept(databaseOperationJudge.Value); if (!result.Success) { return(new PreliminaryAcceptCallForSpeechCommandResponse(result)); } await _callRepository.SavePreliminaryAcceptenceAsync(cfsuniqueId, judgeId, cfs.Status); return(new PreliminaryAcceptCallForSpeechCommandResponse()); }
public async Task <RejectCallForSpeechCommandResponse> Handle(RejectCallForSpeechCommand request, CancellationToken cancellationToken) { var cfsuniqueId = _mapper.Map <CallForSpeechUniqueId>(request.CallForSpeechUniqueId); var judgeId = _mapper.Map <JudgeId>(request.JudgeId); var databaseOperationCfs = await _callRepository.GetByIdAsync(cfsuniqueId); var databaseOperationJudge = await _judegRepository.GetByIdAsync(judgeId); if (!databaseOperationCfs.Success) { if (databaseOperationCfs.Reason == Reason.ReturnedNull) { return(new RejectCallForSpeechCommandResponse(ResponseStatus.NotFoundInDataBase)); } if (databaseOperationCfs.Reason == Reason.Error) { return(new RejectCallForSpeechCommandResponse(ResponseStatus.DataBaseError)); } } if (!databaseOperationJudge.Success) { if (databaseOperationJudge.Reason == Reason.ReturnedNull) { return(new RejectCallForSpeechCommandResponse(ResponseStatus.NotFoundInDataBase)); } if (databaseOperationJudge.Reason == Reason.Error) { return(new RejectCallForSpeechCommandResponse(ResponseStatus.DataBaseError)); } } var cfs = databaseOperationCfs.Value; var judge = databaseOperationJudge.Value; var result = cfs.TryReject(judge); if (!result.Success) { return(new RejectCallForSpeechCommandResponse(result)); } await _callRepository.SaveRejectionAsync(cfsuniqueId, judgeId, cfs.Status); return(new RejectCallForSpeechCommandResponse()); }