public HttpResponseMessage Post([FromBody] FeedbackRequest request) { HttpResponseMessage response; try { FeedbackResponse feedbackResponse = new FeedbackResponse(); using (TechReady.Portal.Models.TechReadyDbContext ctx = new TechReady.Portal.Models.TechReadyDbContext()) { var appUserId = Convert.ToInt32(request.AppUserId); var appuser = (from c in ctx.AppUsers where c.AppUserID == appUserId select c). FirstOrDefault(); if (appuser != null) { AppFeedback feedback = new AppFeedback() { AppUserID = appUserId, Email = request.Email, FeedbackText = request.Feedback, FeedbackType = request.FeedbackType, Name = request.Name }; ctx.AppFeedbacks.Add(feedback); ctx.SaveChanges(); feedbackResponse.ResponseText = "Thank you for sharing your feedback!"; } else { feedbackResponse.ResponseText = "User is not registered, Please register to provide feedback"; } } response = this.Request.CreateResponse(HttpStatusCode.OK, feedbackResponse); response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(300)); } catch (Exception ex) { HttpError myCustomError = new HttpError(ex.Message) { { "IsSuccess", false } }; return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, myCustomError)); } return(response); }
private void SendFeedback() { // Set the project key AppFeedback.Configure(PROJECT_KEY); // Build the request AppFeedback.SendFeedbackRequest request = new AppFeedback.SendFeedbackRequest(); request.feedback = m_FeedbackString; request.email = m_EmailString; request.happiness = (m_HappinessToggleIndexSelected + 1) * 2; request.version = m_VersionCode; request.additionalData = null; if (m_HasHardwarePermission) { // You do not need to send this, but as useful example to show some fields you might want to send // to help with user diagnostics etc // You must make it clear to the end user what you intend to do with this data, otherwise you may breach GDPR regulations // We let them know in this sample that we want to use their device information purely for diagnostic/debugging reasons request.additionalData = new Dictionary <string, string> { { "device_model", SystemInfo.deviceModel }, { "device_gpu_name", SystemInfo.graphicsDeviceName }, { "device_os", SystemInfo.operatingSystem }, { "device_cpu_name", string.Format("{0} : CORES({1})", SystemInfo.processorType, SystemInfo.processorCount) }, { "device_ram", SystemInfo.systemMemorySize.ToString() }, { "device_vram", SystemInfo.graphicsMemorySize.ToString() }, { "system_language", Application.systemLanguage.ToString() }, }; } ; // Show our generic popup m_CurrentlyShowingPopup = Instantiate(m_GenericPopupPrefab, this.transform).GetComponent <AppFeedbackGenericPopup>(); m_CurrentlyShowingPopup.SetText("Sending Feedback..."); m_CurrentlyShowingPopup.SetAllowDismissal(false); // This is where you send the request, but also setup any callbacks AppFeedback.Send(request, OnAppFeedbackSuccessCB, OnAppFeedbackFailureCB); }
public async Task SubmitFeedback(AppFeedback feedback) { // await azure.Client.InvokeApiAsync<bool>("Search", feedback); }