public async Task<IEnumerable<Feedback>> GetAllAsync(string campaignId, FeedbackRequest request = null) { using (var client = CreateMailClient("campaigns/")) { var response = await client.GetAsync($"{campaignId}/feedback{request?.ToQueryString()}"); await response.EnsureSuccessMailChimpAsync(); var listResponse = await response.Content.ReadAsAsync<FeedBackResponse>(); return listResponse.Feedback; } }
public async Task <IActionResult> UpdateFeedback(int feedbackId, [FromBody] FeedbackRequest request) { try { var feedback = await _feedbackApp.Update(request); return(Ok(feedback)); } catch (Exception e) { return(BadRequest(new { Message = e.Message })); } }
/// <summary> /// The get all async. /// </summary> /// <param name="campaignId"> /// The campaign id. /// </param> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> /// <exception cref="ArgumentNullException"><paramref> /// <name>uriString</name> /// </paramref> /// is null. </exception> /// <exception cref="UriFormatException">In the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, <see cref="T:System.FormatException" />, instead.<paramref name="uriString" /> is empty.-or- The scheme specified in <paramref name="uriString" /> is not correctly formed. See <see cref="M:System.Uri.CheckSchemeName(System.String)" />.-or- <paramref name="uriString" /> contains too many slashes.-or- The password specified in <paramref name="uriString" /> is not valid.-or- The host name specified in <paramref name="uriString" /> is not valid.-or- The file name specified in <paramref name="uriString" /> is not valid. -or- The user name specified in <paramref name="uriString" /> is not valid.-or- The host or authority name specified in <paramref name="uriString" /> cannot be terminated by backslashes.-or- The port number specified in <paramref name="uriString" /> is not valid or cannot be parsed.-or- The length of <paramref name="uriString" /> exceeds 65519 characters.-or- The length of the scheme specified in <paramref name="uriString" /> exceeds 1023 characters.-or- There is an invalid character sequence in <paramref name="uriString" />.-or- The MS-DOS path specified in <paramref name="uriString" /> must start with c:\\.</exception> /// <exception cref="ArgumentOutOfRangeException">Enlarging the value of this instance would exceed <see cref="P:System.Text.StringBuilder.MaxCapacity" />. </exception> /// <exception cref="MailChimpException"> /// Custom Mail Chimp Exception /// </exception> /// <exception cref="NotSupportedException"><paramref name="element" /> is not a constructor, method, property, event, type, or field. </exception> /// <exception cref="TypeLoadException">A custom attribute type cannot be loaded. </exception> public async Task <FeedBackResponse> GetResponseAsync(string campaignId, FeedbackRequest request = null) { using (var client = this.CreateMailClient("campaigns/")) { var response = await client.GetAsync($"{campaignId}/feedback{request?.ToQueryString()}").ConfigureAwait(false); await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false); var listResponse = await response.Content.ReadAsAsync <FeedBackResponse>().ConfigureAwait(false); return(listResponse); } }
public async Task <IEnumerable <Feedback> > GetAllAsync(string campaignId, FeedbackRequest request = null) { using (var client = CreateMailClient("campaigns/")) { var response = await client.GetAsync($"{campaignId}/feedback{request?.ToQueryString()}"); response.EnsureSuccessStatusCode(); var listResponse = await response.Content.ReadAsAsync <FeedBackResponse>(); return(listResponse.Feedback); } }
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); }
public async Task <ActionResult <FeedbackRequestDto> > PostFeedbackRequest([FromBody] FeedbackRequestDto feedbackRequestDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } FeedbackRequest feedbackRequest = DtoToEntityIMapper.Map <FeedbackRequestDto, FeedbackRequest>(feedbackRequestDto); repository.Add(feedbackRequest); await uoW.SaveAsync(); return(CreatedAtAction("GetFeedbackRequest", new { id = feedbackRequest.ID }, feedbackRequestDto)); }
public IActionResult Feedback(FeedbackViewModel model) { var _user = new AuthenticateResponse { MembershipKey = 1006979, //1007435, EmailAddress = "*****@*****.**", //"*****@*****.**", FirstName = "Tolulope", LastName = "Olusakin", FullName = "Olusakin Tolulope S"//"Funmilayo Ruth Adeyemi", }; try { if (!ModelState.IsValid) { TempData["message"] = ViewBag.Message = "Error! Incorrect form details."; return(View(model)); } var fbRequest = new FeedbackRequest { MembershipNumber = _user.MembershipKey, FirstName = _user.FirstName, LastName = _user.LastName, EmailAddress = _user.EmailAddress, MobileNumber = model.MobileNumber, MessageCategory = model.MessageCategory, Message = model.Message }; var fbResponse = _clientService.SendFeedback(fbRequest); if (fbResponse != null && fbResponse.TrackingID != null) { var msg = "Success: " + fbResponse.StatusMessage + ":" + fbResponse.TrackingID; TempData["message"] = msg; return(RedirectToAction("Location", "Contact")); } else { TempData["message"] = ViewBag.Message = fbResponse.StatusMessage; } } catch (Exception ex) { TempData["message"] = ViewBag.Message = ex.Message; Utilities.ProcessError(ex, _contentRootPath); _logger.LogError(null, ex, ex.Message); } return(View(model)); }
public IActionResult SendMessage(FeedbackRequest feedbackRequest) { if (feedbackRequest is null) { return(BadRequest("feedbackRequest is null")); } if (feedbackRequest.MailSender is null || !feedbackRequest.MailSender.Contains("@")) { return(BadRequest("MailSender not contains @")); } return(Ok()); }
public async Task <ActionResult> Handle(FeedbackRequest request) { try { Feedback newFeedback = _mapper.Map(request); await _feedbackRepository.Create(newFeedback); return(new OkObjectResult(newFeedback)); } catch (Exception ex) { return(new BadRequestObjectResult(ex.StackTrace)); } }
public async Task <IHttpActionResult> DeleteFeedbackRequest(int id) { FeedbackRequest feedbackRequest = await UoW.GetRepository <FeedbackRequest>().GetItemAsycn(e => e.ID == id); if (feedbackRequest == null) { return(NotFound()); } UoW.GetRepository <FeedbackRequest>().Delete(feedbackRequest); await UoW.SaveAsync(); return(Ok(feedbackRequest)); }
public async Task <IEnumerable <FeedbackResponse> > LeaveFeedbackAsync(FeedbackRequest feedbackRequest, string userId) { var feedback = new Feedback { FilmId = feedbackRequest.FilmId, Text = feedbackRequest.Message, UserId = userId, DateOfPublication = DateTime.Now }; await _feedbaclRepository.SaveFeedbackAsync(feedback); return(await GetFeedbacksAsync(feedbackRequest.FilmId)); }
public IActionResult SubmitFeedback(FeedbackRequest request) { if (!ModelState.IsValid) { return(new BadRequestResult()); } Console.WriteLine(request); if (!string.IsNullOrWhiteSpace(request?.Feedback)) { Logger.LogInformation(request.Feedback); } return(new OkResult()); }
public async Task FilmManagementService_LeaveFeedbackAsync_VerifyExecution() { var userId = "asdfasdf"; var feedback = new FeedbackRequest { FilmId = 2, Message = "Foo" }; var filmManagementService = _autoMockContext.Create <FilmManagementService>(); await filmManagementService.LeaveFeedbackAsync(feedback, userId); _autoMockContext.Mock <IFeedbackRepository>() .Verify(m => m.SaveFeedbackAsync(It.IsAny <Feedback>())); }
public IActionResult Post([FromBody] FeedbackRequest model) { int response; try { response = _imisModules.GetFeedbackModule().GetFeedbackLogic().Post(model); } catch (ValidationException e) { return(BadRequest(new { error = new { message = e.Message, value = e.Value } })); } return(Ok(response)); }
public async Task <FeefoClientResponse> GetFeedbackAsync(FeedbackRequest feedbackRequest, CancellationToken cancellationToken = default(CancellationToken)) { var httpClient = CreateHttpClient(); var queryString = _queryStringFactory.Create(_feefoSettings.Logon, feedbackRequest); var response = await httpClient.GetAsync(queryString, cancellationToken) .ConfigureAwait(false); response.EnsureSuccessStatusCode(); var content = await response.Content.ReadAsAsync <Rootobject>(cancellationToken) .ConfigureAwait(false); return(new FeefoClientResponse(content?.FeedbackList)); }
public void RemoveFeedbackRequest(FeedbackRequest request) { var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) { if (proxyRequest.node == Node.LeftHand) { m_LeftProxyNode.RemoveFeedbackRequest(proxyRequest); } else if (proxyRequest.node == Node.RightHand) { m_RightProxyNode.RemoveFeedbackRequest(proxyRequest); } } }
public IActionResult Create([FromBody] FeedbackRequest model) { if (!ModelState.IsValid) { return(BadRequest()); } var feedback = Mapper.Map <Feedback.FeedbackDetails>(model); feedback.UserId = CurrentUserId; feedback.Created = DateTimeOffset.Now; _feedbackRepository.CreateFeedback(feedback); var result = Mapper.Map <FeedbackDetailsResponse>(feedback); return(Ok(result)); }
public async Task <HttpResponseMessage> SaveFeedback(FeedbackRequest feedbackRequest) { httpResponseMessage = new HttpResponseMessage(); if (feedbackRequest != null && ModelState.IsValid) { var feedback = await _ICommonService.SaveFeedback(feedbackRequest); httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, feedback); } else { httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, new { Message = CustomErrorMessages.INVALID_INPUTS, Success = false }); } return(httpResponseMessage); }
public async Task <IActionResult> Submit(FeedbackRequest feedback) { string email = null; string userName = null; if (this.User.Identity.IsAuthenticated) { var user = await this.userManager.GetUserAsync(this.User); email = await this.userManager.GetEmailAsync(user); userName = user.UserName; } else if (!string.IsNullOrWhiteSpace(feedback.Email)) { email = feedback.Email; } var feedbackData = new Dictionary <string, string> { { "Email", email ?? "<anonymous>" }, { "UserName", userName ?? "<anonymous>" }, { "Page", this.Request.Headers["Referer"] }, { "Comments", feedback.Comments }, }; this.telemetryClient.TrackEvent("FeedbackSubmit", feedbackData); var client = new SendGridClient(this.emailSenderSettings.ApiKey); var message = new SendGridMessage { From = new EmailAddress(email ?? "*****@*****.**", userName ?? "Clicker Heroes Tracker"), Subject = $"Clicker Heroes Tracker Feedback from {userName ?? "<anonymous>"}", PlainTextContent = JsonConvert.SerializeObject(feedbackData, Formatting.Indented), }; foreach (var feedbackReciever in this.emailSenderSettings.FeedbackRecievers) { message.AddTo(new EmailAddress(feedbackReciever)); } await client.SendEmailAsync(message); return(this.Ok()); }
public async Task <FeefoClientResponse> GetFeedbackAsync(FeedbackRequest feedbackRequest, CancellationToken cancellationToken = default(CancellationToken)) { var httpClient = CreateHttpClient(); var queryString = _queryStringFactory.Create(_feefoSettings.Logon, feedbackRequest); var response = await httpClient.GetAsync(queryString); response.EnsureSuccessStatusCode(); var jsonContent = await response.Content.ReadAsStringAsync(); var parsedContent = JObject.Parse(jsonContent); var content = parsedContent.ToObject <Rootobject>(); return(new FeefoClientResponse(content?.FeedbackList)); }
public FeedbackResponse SendFeedback(FeedbackRequest request) { try { const string MailingAddressFrom = "[email protected] "; const string MailingAddressTo = "*****@*****.**"; const string SmtpHost = "smtp.contoso.com"; const int SmtpPort = 587; const bool SmtpEnableSsl = true; const string SmtpCredentialsUsername = "******"; const string SmtpCredentialsPassword = "******"; var subject = "Sample add-in feedback, " + DateTime.Now.ToString("MMM dd, yyyy, hh:mm tt"); var body = "Rating: " + request.Rating + "\n\n" + "Feedback:\n" + request.Feedback; MailMessage mail = new MailMessage(MailingAddressFrom, MailingAddressTo, subject, body); mail.IsBodyHtml = false; // Send as plain text, to avoid needing to escape special characters, etc. var smtp = new SmtpClient(SmtpHost, SmtpPort) { EnableSsl = SmtpEnableSsl, Credentials = new NetworkCredential(SmtpCredentialsUsername, SmtpCredentialsPassword) }; smtp.Send(mail); // If still here, the feedback was sent successfully. return(new FeedbackResponse() { Status = "Thank you for your feedback!", Message = "Your feedback has been sent successfully." }); } catch (Exception) { // Could add some logging functionality here. For a a more thorough discussion on error handling, // see the "Try-catch" section in the accompanying walkthrough doc for an earlier version of this sample: // http://blogs.msdn.com/b/officeapps/archive/2013/06/05/create-a-web-service-for-an-app-for-office-using-the-asp-net-web-api.aspx return(new FeedbackResponse() { Status = "Sorry, your feedback could not be sent", Message = "You may try emailing it directly to the support team." }); } }
public FeedbackResponse SendFeedback(FeedbackRequest request) { try { const string MailingAddressFrom = "[email protected] "; const string MailingAddressTo = "*****@*****.**"; const string SmtpHost = "smtp.contoso.com"; const int SmtpPort = 587; const bool SmtpEnableSsl = true; const string SmtpCredentialsUsername = "******"; const string SmtpCredentialsPassword = "******"; var subject = "Sample add-in feedback, " + DateTime.Now.ToString("MMM dd, yyyy, hh:mm tt"); var body = "Rating: " + request.Rating + "\n\n" + "Feedback:\n" + request.Feedback; MailMessage mail = new MailMessage(MailingAddressFrom, MailingAddressTo, subject, body); mail.IsBodyHtml = false; // Send as plain text, to avoid needing to escape special characters, etc. var smtp = new SmtpClient(SmtpHost, SmtpPort) { EnableSsl = SmtpEnableSsl, Credentials = new NetworkCredential(SmtpCredentialsUsername, SmtpCredentialsPassword) }; smtp.Send(mail); // If still here, the feedback was sent successfully. return new FeedbackResponse() { Status = "Thank you for your feedback!", Message = "Your feedback has been sent successfully." }; } catch (Exception) { // Could add some logging functionality here. For a a more thorough discussion on error handling, // see the "Try-catch" section in the accompanying walkthrough doc for an earlier version of this sample: // http://blogs.msdn.com/b/officeapps/archive/2013/06/05/create-a-web-service-for-an-app-for-office-using-the-asp-net-web-api.aspx return new FeedbackResponse() { Status = "Sorry, your feedback could not be sent", Message = "You may try emailing it directly to the support team." }; } }
public async Task <IHttpActionResult> SaveFeedback(FeedbackRequest feedbackRequest) { if (!ModelState.IsValid) { return(BadRequest()); } try { _unitOfWork.GetInterviewRepository().SaveFeedback(feedbackRequest.StageId, feedbackRequest.InterviewId, feedbackRequest.Feedback); await _unitOfWork.Save(); return(Ok("Feedback send successfully")); } catch (Exception e) { return(InternalServerError(e)); } }
public IActionResult SubmitFeedback(Guid id, [FromBody] FeedbackRequest request) { if (!pairs.Find(id, out var pair)) { return(NotFound()); } switch (request.Content) { case "yes": pair.Outcome = PairOutcome.Success; break; case "no": pair.Outcome = PairOutcome.Failure; break; } pairs.Update(pair); return(Ok()); }
private void OnFormSubmitted(FeedbackRequest request) { var form = new WWWForm(); form.AddField("subject", request.Subject); form.AddField("title", request.Title); form.AddField("text", request.Text); form.AddField("version", Game.Instance.Version); #if !DISABLESTEAMWORKS if (SteamManager.Initialized) { form.AddField("steam_user_id", SteamUser.GetSteamID().ToString()); } #endif View.SetFormFieldsInteractable(false); Timer.Instance.StartCoroutine(SendRequest(form)); }
public async Task <IActionResult> AddMessage(FeedbackRequest feedback) { var user = await MainRepository.FindUserAsync(feedback.Email, feedback.Phone); if (user == null) { user = new User(feedback.Name, feedback.Email, feedback.Phone); await MainRepository.AddUserAsync(user); } var subject = await MainRepository.GetSubjectByIdAsync(feedback.SubjectId); var message = new Message(user.UserId, subject.SubjectId, feedback.Message); await MainRepository.AddMessageAsync(message); var response = new FeedbackResponse( message.UserId, message.MessageId, message.User.Phone, message.User.Email, message.Subject.SubjectName, message.Text); return(CreatedAtAction(nameof(AddMessage), response)); }
public IActionResult Post([FromBody] FeedbackRequest model) { if (!ModelState.IsValid) { var error = ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage; return(BadRequest(new { error_occured = true, error_message = error })); } int response; try { response = _imisModules.GetFeedbackModule().GetFeedbackLogic().Post(model); } catch (ValidationException e) { throw new BusinessException(e.Message); } return(Ok(response)); }
public async Task <ActionResult <FeedbackRequestDto> > DeleteFeedbackRequest([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } FeedbackRequest feedbackRequest = await repository.GetAsync(a => a.ID == id); if (feedbackRequest == null) { return(NotFound()); } repository.Delete(feedbackRequest); await uoW.SaveAsync(); FeedbackRequestDto feedbackRequestDto = EntityToDtoIMapper.Map <FeedbackRequest, FeedbackRequestDto>(feedbackRequest); return(Ok(feedbackRequestDto)); }
public async Task <FeedbackResponse> Create(FeedbackRequest request) { if (request.Vote <= 0) { throw new Exception("Vote must be between 1 and 5"); } var feedback = new Feedback(request); try { _context.Feedbacks.Add(feedback); await _context.SaveChangesAsync(); return(new FeedbackResponse(feedback)); } catch (Exception) { throw new Exception("Can not create feedback"); } }
public async Task <ActionResult> SubmitAsync([FromForm] FeedbackRequest feedback) { string email = null; string userName = null; if (User.Identity.IsAuthenticated) { ApplicationUser user = await _userManager.GetUserAsync(User); email = await _userManager.GetEmailAsync(user); userName = user.UserName; } else if (!string.IsNullOrWhiteSpace(feedback.Email)) { email = feedback.Email; } Dictionary <string, string> feedbackData = new() { { "Email", email ?? "<anonymous>" }, { "UserName", userName ?? "<anonymous>" },
public async Task <FeedbackDto> CreateEntityAsync(FeedbackRequest request) { var entity = _mapper.Map <FeedbackRequest, Feedback>(request); entity = await _uow.FeedbackRepository.CreateAsync(entity); var result = await _uow.SaveAsync(); if (!result) { return(null); } if (entity == null) { return(null); } var dto = _mapper.Map <Feedback, FeedbackDto>(entity); return(dto); }
private bool TryCatch(FeedbackRequest callback, out string feedback) { feedback = null; try { feedback = callback(); return(true); } catch (BusinessRuleCollectionException ex) { HandleException(ex); } catch (DbEntityValidationException ex) { HandleException(ex); } catch (Exception ex) { HandleException(ex); } return(false); }
/// <summary> /// <para>Adds feedback to a listing. POST /// </para> /// REQUIRES AUTHENTICATION. /// </summary> /// <param name="request">FeedbackRequest</param> /// <returns>XDocument: FeedbackResponse.</returns> public XDocument AddFeedback(FeedbackRequest request) { if (_myTradeMe == null) { _myTradeMe = new MyTradeMeMethods(_connection); } return _myTradeMe.AddFeedback(request); }
/// <summary> /// <para>Adds feedback to a listing. POST /// </para> /// REQUIRES AUTHENTICATION. /// </summary> /// <param name="request">FeedbackRequest</param> /// <returns>XDocument: FeedbackResponse.</returns> public XDocument AddFeedback(FeedbackRequest request) { var query = String.Format(Constants.Culture, "{0}/Feedback/Update{1}", Constants.MY_TRADEME, Constants.XML); return _connection.Post(request, query, true); }
/// <summary> /// The get all async. /// </summary> /// <param name="campaignId"> /// The campaign id. /// </param> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> /// <exception cref="ArgumentNullException"><paramref> /// <name>uriString</name> /// </paramref> /// is null. </exception> /// <exception cref="UriFormatException">In the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, <see cref="T:System.FormatException" />, instead.<paramref name="uriString" /> is empty.-or- The scheme specified in <paramref name="uriString" /> is not correctly formed. See <see cref="M:System.Uri.CheckSchemeName(System.String)" />.-or- <paramref name="uriString" /> contains too many slashes.-or- The password specified in <paramref name="uriString" /> is not valid.-or- The host name specified in <paramref name="uriString" /> is not valid.-or- The file name specified in <paramref name="uriString" /> is not valid. -or- The user name specified in <paramref name="uriString" /> is not valid.-or- The host or authority name specified in <paramref name="uriString" /> cannot be terminated by backslashes.-or- The port number specified in <paramref name="uriString" /> is not valid or cannot be parsed.-or- The length of <paramref name="uriString" /> exceeds 65519 characters.-or- The length of the scheme specified in <paramref name="uriString" /> exceeds 1023 characters.-or- There is an invalid character sequence in <paramref name="uriString" />.-or- The MS-DOS path specified in <paramref name="uriString" /> must start with c:\\.</exception> /// <exception cref="ArgumentOutOfRangeException">Enlarging the value of this instance would exceed <see cref="P:System.Text.StringBuilder.MaxCapacity" />. </exception> /// <exception cref="MailChimpException"> /// Custom Mail Chimp Exception /// </exception> /// <exception cref="NotSupportedException"><paramref name="element" /> is not a constructor, method, property, event, type, or field. </exception> /// <exception cref="TypeLoadException">A custom attribute type cannot be loaded. </exception> public async Task<FeedBackResponse> GetResponseAsync(string campaignId, FeedbackRequest request = null) { using (var client = this.CreateMailClient("campaigns/")) { var response = await client.GetAsync($"{campaignId}/feedback{request?.ToQueryString()}").ConfigureAwait(false); await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false); var listResponse = await response.Content.ReadAsAsync<FeedBackResponse>().ConfigureAwait(false); return listResponse; } }