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)); } }
public async void SubmitFeedback(TravellerFeedback feedbackData) { await this._context.TravellerFeedback.AddAsync(feedbackData); await this._unitOfWork.CompleteAsync(); }