示例#1
0
        public TravellerResponse SubmitFeedback(TravellerFeedbackViewModel feedbackData)
        {
            _logger.LogInfo("Trying to submit feedback with device id " + feedbackData.DeviceId);
            try
            {
                //Get Traveller info based on device id
                Traveller traveller = _travellerRepository.GetTravellerByDeviceId(feedbackData.DeviceId);
                if (traveller == null)
                {
                    throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.BookingWithInvalidDeviceId)));
                }

                //Convert view model to entity
                TravellerFeedback feedbackInfo = _mapper.Map <TravellerFeedback>(feedbackData);
                feedbackInfo.TravellerId = traveller.Id;
                feedbackInfo.IsActive    = true;
                _travellerRepository.SubmitFeedback(feedbackInfo);
                _logger.LogInfo("Successfully submitted feedback with device id " + feedbackData.DeviceId);
                feedbackData.DeviceId = null;
                TravellerResponse response = new TravellerResponse(true, string.Format(_messageHandler.GetSuccessMessage(SuccessMessagesEnum.SuccessfullySaved)));
                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(new TravellerResponse(false, ex.Message));
            }
        }
示例#2
0
        public async void SubmitFeedback(TravellerFeedback feedbackData)
        {
            await this._context.TravellerFeedback.AddAsync(feedbackData);

            await this._unitOfWork.CompleteAsync();
        }