public async Task Create(ContactUsInputModel model) { var entity = this.Mapper.Map <ContactUs>(model); await this.contractUsRepository.AddAsync(entity); await this.contractUsRepository.SaveChangesAsync(); }
public async Task <IActionResult> Contact(ContactUsInputModel inputModel) { await this.emailSender.SendEmailAsync( inputModel.Email, inputModel.Name, GlobalConstants.SystemEmail, inputModel.Subject, inputModel.Message); return(this.View("Sent")); }
public async Task <IActionResult> Index(ContactUsInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } await this.emailSender.SendEmailAsync(input.Email, input.FullName, GlobalConstants.AdministratorEmailAddress, input.Subject, input.Message, null); return(this.Redirect("/")); }
public async Task <object> ContactUs([FromBody] ContactUsInputModel model) { try { await this.contactUsService.Create(model); return(this.Ok(new ReturnMessage() { Message = "Thank you for reaching us. We will contact you soon." })); } catch (Exception e) { return(this.BadRequest(new ReturnMessage { Message = e.Message })); } }
public async Task <IActionResult> Index(ContactUsInputModel model) { if (this.ModelState.IsValid) { var email = model.Email; var name = model.Name; var subject = model.Subject; var content = model.Message; await this.emailSender.SendPlainEmailAsync(email, name, HomySupportEmail, subject, content, null); return(this.RedirectToAction( nameof(HomeController.Index), "Home", new { area = string.Empty }) .WithSuccess(string.Empty, MessageSentSuccessfully)); } return(this.View(model)); }
public async Task ContactUsFailWithInvalidModelData(string email, string subject, string description) { var form = new ContactUsInputModel { Email = email, Subject = subject, Description = description }; var json = new StringContent( JsonConvert.SerializeObject(form), Encoding.UTF8, "application/json"); var response = await client.PostAsync(ContactUsEndpoint, json); var content = JsonConvert.DeserializeObject <ProblemDetails>(await response.Content.ReadAsStringAsync()); Assert.Equal(StatusCodes.Status400BadRequest, content.Status); Assert.Equal(ValidationMessage, content.Title); }
public async Task ContactUsSuccessful(string email, string subject, string description) { var form = new ContactUsInputModel { Email = email, Subject = subject, Description = description }; var json = new StringContent( JsonConvert.SerializeObject(form), Encoding.UTF8, "application/json"); var response = await client.PostAsync(ContactUsEndpoint, json); response.EnsureSuccessStatusCode(); var content = JsonConvert.DeserializeObject <ReturnMessage>(await response.Content.ReadAsStringAsync()); Assert.Equal(StatusCodes.Status200OK, content.Status); Assert.Equal(ContactUsSuccessMessage, content.Message); }
public async Task <IActionResult> ContactUs(ContactUsInputModel inputModel) { if (!ModelState.IsValid) { return(View(inputModel)); } SendGrid.Response result = await emailsService .SendAsync(configuration["SendGrid:To"], $"From: {inputModel.Email}", inputModel.Message); if (result.StatusCode.ToString() == "Accepted") { TempData["contact"] = true; return(RedirectToAction(nameof(ContactUs))); } else { TempData["contact"] = false; return(View(inputModel)); } }
public async Task <IActionResult> Index() { var viewModel = new ContactUsInputModel(); return(this.View(viewModel)); }