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
                       ));
        }
示例#2
0
 public async Task <JsonResult> Feedback(int id, FeedbackRequestModel model)
 {
     try
     {
         FeedbackDTO feedbackDTO = Mapper.Map <FeedbackRequestModel, FeedbackDTO>(model);
         if (base.CurrentUser != null)
         {
             feedbackDTO.UserId = base.CurrentUser.UserId;
         }
         feedbackDTO.PlaceId = id;
         try
         {
             feedbackDTO.IpAddress = this.Request.HttpContext.Connection
                                     .RemoteIpAddress
                                     .ToString();
         }
         catch (Exception ex)
         {
             LoggerExtensions.LogError(_logger, ex, "IP Address error", Array.Empty <object>());
         }
         return(this.Json((object)(await _feedbackService.AddFeedbackAsync(feedbackDTO))));
     }
     catch (Exception ex2)
     {
         return(this.Json((object)Result.Fail("İşleminiz gerçekleştirilemedi", ex2)));
     }
 }
示例#3
0
        public async Task <IActionResult> AddFeedback(FeedbackAddDTO model)
        {
            try
            {
                var data = await _feedbackService.AddFeedbackAsync(model);

                return(Ok(data));
            }
            catch (UnauthorizedAccessException)
            {
                return(Unauthorized());
            }
            catch (Exception e)
            {
                return(BadRequest(new { e.Message }));
            }
        }