コード例 #1
0
        public async Task <SessionFeedbackDto> HandleAsync(FeedbackCreateModel model)
        {
            var sessionId = model.SessionId.Value;
            var userId    = model.UserId.Value;
            var rating    = model.Rating.Value;

            var session = await _gameSessionService.GetAsync(sessionId);

            if (session == null)
            {
                throw new SessionNotFoundException(model.SessionId.Value);
            }

            var count = await _feedbackService.GetFeedbackCountPerUserSessionAsync(sessionId : sessionId, userId : userId);

            if (count > 0)
            {
                throw new FeedbackCreateRequestNotAllowedException(sessionId: sessionId, userId: userId);
            }

            return(await _feedbackService.AddFeedbackAsync(
                       sessionId : sessionId,
                       userId : userId,
                       rating : rating
                       ));
        }