public PartialViewResult Index(ContactInputModel inputModel) { if (ModelState.IsValid) { var user = new Customer { FullName = inputModel.FullName, Email = inputModel.Email.ToLower(), Telephone = inputModel.Telephone }; var note = new Note { Message = inputModel.Message }; customerService.EnquiryRequest(user, note); return PartialView("SendMessage"); } var viewModel = new ContactViewModel { FullName = inputModel.FullName, Email = inputModel.Email.ToLower(), Telephone = inputModel.Telephone, Message = inputModel.Message }; return PartialView("Index", viewModel); }
public ProducerViewModel(Producer producer) { Address = new AddressViewModel(producer.Address); AreMultiple = producer.AreMultiple; BusinessName = producer.BusinessName; Contact = new ContactViewModel(producer.Contact); }
public ActionResult Contact(ContactViewModel contactVM) { if (!ModelState.IsValid) { return View(contactVM); } var contact = new Contact { Name = contactVM.Name, Email = contactVM.Email, Subject = contactVM.Subject, Comment = contactVM.Comment }; try { new Email().Send(contact); return RedirectToAction("ContactConfirm"); } catch (Exception ex) { ViewBag.EmailMsg = "Following Error Occured during sending a message: "; ViewBag.Error = ex.Message; return View("Contact"); } }
public ActionResult Update(ContactViewModel viewModel, FormCollection formCollection) { var operation = formCollection["oper"]; if (operation.Equals("add") || operation.Equals("edit")) { repository.SaveOrUpdate(new ContactViewModel { ContactId = viewModel.ContactId, DateOfBirth = viewModel.DateOfBirth, Email = viewModel.Email, IsMarried = viewModel.IsMarried, Name = viewModel.Name, PhoneNumber = viewModel.PhoneNumber }); } else if (operation.Equals("del")) { repository.Delete(new ContactViewModel { ContactId = viewModel.ContactId //ContactId = new Guid(formCollection["id"]) }); } return Content(repository.HasErrors.ToString().ToLower()); }
public override ActionResult Index(RenderModel model) { ContactOperationStatus operationStatus = _contactService.GetContact(); ContactViewModel viewContact = new ContactViewModel(model); if (operationStatus.Status) { viewContact.InjectFrom(operationStatus.Contact); viewContact.ExistingUserName = operationStatus.Contact.UserName; viewContact.ExistingEmail = operationStatus.Contact.Email; if (!String.IsNullOrEmpty(Request["url"])) { viewContact.Url = Request["url"]; } if (!String.IsNullOrEmpty(Umbraco.Field("checkoutPage").ToString())) viewContact.Url = Umbraco.Field("checkoutPage").ToString(); viewContact.Titles = GetContactTitles(); viewContact.Countries = GetCountries(); viewContact.Status = operationStatus.Status; viewContact.Message = operationStatus.Message; return CurrentTemplate(viewContact); } return ReturnErrorView(operationStatus, model); }
public ActionResult Contact(ContactViewModel contactViewModel) { if (ModelState.IsValid) { var email = Startup.ConfigurationBuilder["AppSettings:EmailAddress"]; //If Blank email get received from the config file if (string.IsNullOrEmpty(email)) { //Add Object level Error ModelState.AddModelError("","Some Problem with Email Configuration"); } if (_mailService.SendMail(email, email, $"Contact Mail From {contactViewModel.Name} ({contactViewModel.Email})", contactViewModel.Message)) { //Upon Success, It will just clear the form ModelState.Clear(); ViewBag.MailSent = "Mail Sent, Thanks!"; } } return View(); }
public ActionResult Index() { var model = new ContactViewModel { UserRequest = new ContactInfo() }; return View(model); }
public ImporterViewModel(Importer importer) { Address = new AddressViewModel(importer.Address); BusinessName = importer.BusinessName; Contact = new ContactViewModel(importer.Contact); RegistrationNumber = importer.RegistrationNumber; Type = importer.Type; }
public ExporterViewModel(Exporter exporter) { BusinessName = exporter.BusinessName; Address = new AddressViewModel(exporter.Address); Contact = new ContactViewModel(exporter.Contact); }
public ActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { return RedirectToAction("thanks"); } return View(model); }
public ContactController(IShellService shellService, ContactLayoutViewModel contactLayoutViewModel, ContactListViewModel contactListViewModel, ContactViewModel contactViewModel) { this.shellService = shellService; this.contactLayoutViewModel = contactLayoutViewModel; this.contactListViewModel = contactListViewModel; this.contactViewModel = contactViewModel; this.newContactCommand = new DelegateCommand(NewContact); this.deleteContactCommand = new DelegateCommand(DeleteContact, CanDeleteContact); }
public ContactViewPage(Guid id, ContacListViewModel contacListViewModel) { _contacListViewModel = contacListViewModel; InitializeComponent(); var vm = new ContactViewModel(id, DependencyService.Get<IContactService>()); vm.ItemDeleted += OnBtnClicked; vm.WhatItemDeleted += _contacListViewModel.Delete; BindingContext = vm; }
public static void EditContactDetails(ContactViewModel vm) { IoCServiceLocator.Bus.Send( new ChangeContactDetailsCommand( vm.AggregateId, vm.Version, vm.Email, vm.PhoneNumber)); }
public FacilityViewModel(Facility facility) { FacilityId = facility.Id; Address = new AddressViewModel(facility.Address); BusinessName = facility.BusinessName; Contact = new ContactViewModel(facility.Contact); RegistrationNumber = facility.RegistrationNumber; Type = facility.Type; IsActualSite = facility.IsActualSite; }
public ActionResult Contact(ContactViewModel model) { //Thank you mailer for user mandrillMailer.NotifyUser(model.Email,model.Name, "Thank you for contacting LockYourStay.", "Thank you for contacting Lockyourstay.We will get back to you at earliest.", "Notify User"); //send mail to admin string body = model.Name + " has contacted you. Please find the details below, <br><br> <table><tr><td>Name : </td><td>" + model.Name + "</td></tr><tr><td>Email : </td><td>" + model.Email + "</td></tr><tr><td>Subject : </td><td>" + model.Subject + "</td></tr><tr><td>Message : </td><td>" + model.Message + "</td></tr></table>"; mandrillMailer.NotifySuperAdmin(model.Email,model.Name + " have contacted LockYourStay", body, "Notify Admin"); return Content("Thank you for contacting LockYourStay."); }
public AddContactPage(ContacListViewModel contactsListViewModel) { InitializeComponent(); _contactsListViewModel = contactsListViewModel; var vm = new ContactViewModel(); vm.ItemAdded += _contactsListViewModel.OnNewItemAdded; vm.ItemSaved += OnBtnClicked; vm.ItemCanceled += OnBtnClicked; vm.WhatItemDeleted += _contactsListViewModel.Delete; vm.ItemDeleted += OnBtnClicked; BindingContext = vm; }
public void Delete(ContactViewModel entity) { if (HttpContext.Current.Session["ContactList"] != null) { var list = HttpContext.Current.Session["ContactList"] as IList<ContactViewModel>; if (list != null) { var viewModel = list.FirstOrDefault(x => x.ContactId == entity.ContactId); list.Remove(viewModel); } } }
public IActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { var email = Startup.Configuration["AppSettings:SiteEmailAddress"]; _mailService.SendMail(email, email, $"Contact from {model.Name} ({model.Email})", model.Message); } return View(); }
public void CreateContactFromT() { var newContactMap = new ContactViewModel() { FirstName = "Joey", LastName = "Peters" }; var contact = contactService.CreateContact<ContactViewModel>(newContactMap); Assert.IsNotNull(contact); Assert.IsNotNull(contact.Id); Assert.AreEqual(newContactMap.FirstName, contact.FirstName); Assert.AreEqual(newContactMap.LastName, contact.LastName); }
public ActionResult Contact() { HeaderViewModel header = new HeaderViewModel() { Heading = ContactHeading, SubHeading = ContactSubHeading }; ContactViewModel contactModel = new ContactViewModel() { Header = header }; return this.View("Contact", contactModel); }
public ActionResult Create(ContactViewModel contact) { if (ModelState.IsValid) { var contactEntity = Mapper.Map<Contact>(contact); this.Data.Contacts.Add(contactEntity); this.Data.SaveChanges(); this.Notify(GlobalConstants.AddContact, NotificationType.success); return this.RedirectToAction("Index"); } return this.View(contact); }
public ActionResult Edit(int id, ContactViewModel contact) { if (ModelState.IsValid) { var updatedContact = Mapper.Map<Contact>(contact); updatedContact.Id = id; this.Data.Contacts.Update(updatedContact); this.Data.SaveChanges(); this.Notify(GlobalConstants.EditContact, NotificationType.success); return this.RedirectToAction("Index"); } return this.View(contact); }
public ActionResult Create([DataSourceRequest] DataSourceRequest request, ContactViewModel model) { if (this.ModelState.IsValid && model != null) { int id = this.contactService .Create(model.PhoneNumber, model.Email, int.Parse(model.AddressId)) .Id; model = this.contactService .GetById(id) .To<ContactViewModel>() .FirstOrDefault(); } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public IActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { var email = Startup.Configuration["AppSettings:SiteEmailAddress"]; if (string.IsNullOrWhiteSpace(email)) { ModelState.AddModelError("", "Could not send email, configuration problem."); } if(_mailService.SendMail(email, email, $"Contact Page from {model.Name} ({model.Email})", model.Message)) { ModelState.Clear(); ViewBag.Message = "Mail Sent. Thanks!"; } } return View(); }
public IActionResult Contact(ContactViewModel viewModel) { if (this.ModelState.IsValid) { var email = Startup.Configuration["AppSettings:SiteEmailAddress"]; if (string.IsNullOrWhiteSpace(email)) { throw new Exception("Email is null"); } if (this.mailService.SendMail(email, email, $"Contact from {viewModel.Email}", viewModel.Message)) { this.ModelState.Clear(); this.ViewBag.Message = "Meesage sent, thanks!"; } } return View(); }
public ActionResult ContactUs(ContactViewModel cvw) { if (!ModelState.IsValid) { return View(cvw); } string body = string.Format("{0} has sent you a message with a subject of: {1}. <br/> The message is {2}. <br/>" + "You can contact them at {3}.", cvw.Name, cvw.Subject, cvw.Message, cvw.Email); MailMessage msg = new MailMessage( "*****@*****.**", //From: "*****@*****.**", //To: "New Message from website", //Subject: body); //body is the message constructed above msg.Priority = MailPriority.High; msg.IsBodyHtml = true; using (SmtpClient client = new SmtpClient()) { //Settings to use Centriq Gmail Relay client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential( "*****@*****.**", "c3ntriQc3ntriQ"); client.Host = "smtp.gmail.com"; client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Send(msg); } //using (SmtpClient client = new SmtpClient("relay-hosting.secureserver.net")) //{ // client.Send(msg); //} return RedirectToAction("ReallyThankYou"); }
public static bool isContactValid(ContactViewModel cvm) { if (cvm.name.Equals("")) { return(false); } if (cvm.num1.Equals("")) { return(false); } if (cvm.street.Equals("Street")) { cvm.street = ""; } if (cvm.city.Equals("City")) { cvm.city = ""; } if (cvm.state.Equals("State/Province")) { cvm.state = ""; } if (cvm.zip.Equals("Zip/Postal Ciode")) { cvm.zip = ""; } if (cvm.country.Equals("Country/Region")) { cvm.country = ""; } DataBaseConnection db = new DataBaseConnection(); if (db.saveContact(cvm)) { return(true); } return(false); }
public async Task <ActionResult> Contact(ContactViewModel model) { if (!ModelState.IsValid) { //return View(model); return(await Task.Run(() => View(model))); } //var basePath = HttpContext.Current.Server.MapPath(@"~\Content\EmailTemplates\contactEmail.html"); //var basePath = System.IO.File.ReadAllLines(Server.MapPath(@"\Content\EmailTemplates\contactEmail.html")); var basePath = Server.MapPath(@"\Content\EmailTemplates\contactEmail.html"); var body = System.IO.File.ReadAllText(basePath); body = body.Replace("@fullName", model.Name); body = body.Replace("@custEmail", model.Email); body = body.Replace("@custNumber", model.PhoneNumber); body = body.Replace("@Body", model.Message); MailMessage msg = new MailMessage(); msg.Subject = model.Subject; msg.From = new MailAddress(WebConfigurationManager.AppSettings["fromEmail"]); msg.To.Add(new MailAddress("*****@*****.**")); msg.Subject = model.Subject; msg.Body = body; msg.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient(WebConfigurationManager.AppSettings["smtpHost"], Convert.ToInt32(WebConfigurationManager.AppSettings["smtpPort"])); NetworkCredential credentials = new NetworkCredential(WebConfigurationManager.AppSettings["smtpUser"], WebConfigurationManager.AppSettings["smtpPassword"]); smtpClient.Credentials = credentials; smtpClient.EnableSsl = false; await smtpClient.SendMailAsync(msg); //return View(); return(await Task.Run(() => RedirectToAction("Contact"))); }
public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // HttpClient client = new HttpClient(); Contact cc = null; HttpResponseMessage response = await client.GetAsync("https://localhost:44386/api/Contact/" + id); if (response.IsSuccessStatusCode) { cc = await response.Content.ReadAsAsync <Contact>(); } // if (cc == null) { return(HttpNotFound()); } ContactViewModel ccc = new ContactViewModel() { ContactId = cc.ContactId, FirstName = cc.FirstName, LastName = cc.LastName, Email = cc.Email, PhoneNo = cc.PhoneNo, Status = cc.Status }; return(View(ccc)); }
public IActionResult Add([FromBody] ContactViewModel contactViewModel) { try { Guid id = Guid.NewGuid(); var customerContact = ObjectMapper <ContactViewModel, CustomerContact> .Map(contactViewModel); customerContact.ContactTypeGuid = contactViewModel.ContactType; customerContact.ContactGuid = id; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } customerContact.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); customerContact.CreatedBy = UserHelper.CurrentUserGuid(HttpContext); customerContact.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime(); customerContact.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext); customerContact.IsActive = true; customerContact.IsDeleted = false; var CustomerContact = _customerContactService.Add(customerContact); var jsonObjects = new { contactguid = customerContact.ContactGuid, searchvalue = customerContact.SearchValue, customerguid = customerContact.CustomerGuid, customerName = customerContact.CustomerName, customerLastName = customerContact.LastName, customerPhoneNumber = customerContact.PhoneNumber, fullName = Infrastructure.Helpers.FormatHelper.FormatFullName(customerContact.FirstName, customerContact.MiddleName, customerContact.LastName) }; return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", CustomerContact = jsonObjects })); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public async Task <ContactViewModel> Create(ContactViewModel viewModel) { var contact = new Contact { FirstName = viewModel.FirstName, LastName = viewModel.LastName, CompanyId = viewModel.CompanyId, ContactTypeId = viewModel.ContactTypeId, EmailId = viewModel.Email, Phone = viewModel.Phone, Cell = viewModel.Cell, OwnerId = viewModel.OwnerId, IsKeyContact = viewModel.IsKeyContact, Street = viewModel.Street, City = viewModel.City, ProvinceId = viewModel.StateId, CountryId = viewModel.CountryId, Postal = viewModel.PostalCode, CreatedBy = viewModel.CreatedBy, CreatedOn = viewModel.CreatedOn, LastModifiedBy = viewModel.LastModifiedBy, LastModifiedOn = viewModel.LastModifiedOn, IsActive = viewModel.IsActive }; contact = this.ContactRepository.Add(contact); if (contact.ContactId > 0) { viewModel.ContactId = contact.ContactId; } else { viewModel.HasError = true; } return(viewModel); }
public ActionResult Contact(ContactViewModel cvm) { string emailServer = WebConfigurationManager.AppSettings["EmailServer"]; string emailPW = WebConfigurationManager.AppSettings["EmailPW"]; string emailUser = WebConfigurationManager.AppSettings["EmailUser"]; string emailToAddress = WebConfigurationManager.AppSettings["EmailToAddress"]; if (!ModelState.IsValid) { return(View(cvm)); } // 1. build the body of the email string body = $"You have revieved an email from {cvm.Name} at the address {cvm.Email} with a subject of {cvm.Subject}<br><strong>Message:</strong>{cvm.Message}"; // 2.instantiate the MainMessage object (needs System.Net.Mail) MailMessage msg = new MailMessage($"{emailUser}", $"{emailToAddress}", cvm.Subject, body); // (optional) customize the MainMessage properties msg.IsBodyHtml = true; //instantiate the SmtpClient SmtpClient client = new SmtpClient($"{emailServer}"); // 4. provide credentials for the client (needs the System.Net namespace) client.Credentials = new NetworkCredential($"{emailUser}", $"{emailPW}"); // 5. attempt to send the email try { client.Send(msg); } catch (System.Exception ex) { ViewBag.ErrorMessage = "Sorry, had some trouble with that. see stacktrace or contact an admin." + ex.StackTrace; } return(View("EmailConfirmation", cvm)); }
/// <summary> /// To get a contact by name, I will use a stored procedure to achieve one of test goals. /// </summary> /// <param name="contactName"></param> /// <returns></returns> public ContactViewModel GetContactByName( string contactName) { ContactViewModel contact = new ContactViewModel(); try { string sql = "SP_GetContactByName"; using ( SqlConnection connection = new SqlConnection( _connectionString ) ) { using ( SqlCommand command = new SqlCommand( sql, connection ) ) { command.CommandType = CommandType.StoredProcedure; if ( !string.IsNullOrEmpty( contactName ) ) command.Parameters.Add( "@contactName", SqlDbType.VarChar ).Value = contactName; else command.Parameters.Add( "@contactName", SqlDbType.VarChar ).Value = DBNull.Value; connection.Open(); using ( SqlDataReader dataReader = command.ExecuteReader() ) { if ( dataReader.HasRows && dataReader.Read() ) { contact.Id = Convert.ToInt32( dataReader["contacId"] ); contact.Name = dataReader["name"].ToString(); contact.PhoneNumber = dataReader["phoneNumber"].ToString(); contact.BirthDate = Convert.ToDateTime( dataReader["birth"].ToString() ); contact.ContactTypeId = Convert.ToInt32( dataReader["contactTypeId"] ); contact.ContactType = dataReader["contactTyppe"].ToString(); } } } } } catch ( Exception ex ) { throw; } return contact; }
public async Task <ActionResult> SendSug(ContactViewModel model) { var response = new AjaxResponse { Success = false }; var errorMessages = new List <string>(); try { if (ModelState.IsValid) { var user = new ContactUser { Names = model.ContactNames, Email = model.ContactEmail, PhoneNumber = model.ContactPhoneNumber, Suggests = model.ContactSuggests, DateCreation = DateTime.Now }; var result = storeDB.ContactUsers.Add(user); await storeDB.SaveChangesAsync(); response.Success = true; response.Message = "Los datos fueron enviados correctamente"; return(Json(response, JsonRequestBehavior.AllowGet)); } else { response.Message = "Lo sentimos, no se pudo realizar la operación. Ha ocurrido un error en el servidor."; return(Json(response, JsonRequestBehavior.AllowGet)); } } catch (Exception) { response.Message = "Lo sentimos, no se pudo realizar la operación. Ha ocurrido un error en el servidor."; return(Json(response, JsonRequestBehavior.AllowGet)); } }
public IActionResult Contact(ContactViewModel model) { try { //preparamos el mensaje de email var from = new List <EmailAddress>(); from.Add(new EmailAddress { Address = "*****@*****.**", Name = model.Email }); var to = new List <EmailAddress>(); to.Add(new EmailAddress { Address = "*****@*****.**", Name = "PoyectoFinal" }); EmailMessage message = new EmailMessage { FromAddresses = from, ToAddresses = to, Subject = model.Subject, Content = model.Message }; //enviamos el email email.Send(message); TempData["sent"] = "Se ha enviado el correo correctamente"; return(View()); } catch (Exception ex) { //guardamos el log si se produce una excepcion _logger.LogError(ex.Message, ex); TempData["error"] = "Error al enviar el mensaje por favor intentalo de nuevo, o contacte con su administrador"; return(View(model)); } }
public HttpResponseMessage contactus(ContactViewModel contact) { try { if (ModelState.IsValid) { string CustomerName = contact.Name; string CustomerMessage = contact.Message; string CustomerEmail = contact.EmailAddress; string adminemail = ConfigurationManager.AppSettings["adminemail"].ToString(); string admintemple = ConfigurationManager.AppSettings["admintemple"].ToString(); string subject = ConfigurationManager.AppSettings["subject"].ToString(); string Thankyou = ConfigurationManager.AppSettings["Thankyou"].ToString(); string CustomerContactus = ConfigurationManager.AppSettings["CustomerContactus"].ToString(); string AdminUserName = ConfigurationManager.AppSettings["adminusername"].ToString(); var sendemail = new EmailService.Service.EmailService(); //for cutomer sendemail.SendEmail(CustomerEmail, Thankyou, "Thank you For Contant us", CustomerName); //for Admin sendemail.SendEmail(adminemail, CustomerContactus, subject, CustomerEmail + " Message: " + CustomerMessage); var result = new { success = true, }; return(Request.CreateResponse(HttpStatusCode.OK, result)); } } catch (Exception ex) { var result = new { error = ex.InnerException.Message.ToString(), success = false }; return(Request.CreateResponse(HttpStatusCode.OK, result)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task <List <ContactViewModel> > GetAllContacts() { List <ContactViewModel> contactDetails = new List <ContactViewModel>(); List <Customer> customers = await _dbConext.Customers.OrderBy(c => c.FirstName).ToListAsync(); if (customers.Count > 0 && customers != null) { foreach (var customer in customers) { if (customer != null) { ContactDetails details = await _dbConext.ContactDetails.FirstOrDefaultAsync(d => d.CustomerId.Equals(customer.Id)); Address address = await _dbConext.Address.FirstOrDefaultAsync(a => a.ContactDetailsId.Equals(details.Id)); var contact = new ContactViewModel { CustomerId = customer.Id.ToString(), FirstName = customer.FirstName, LastName = customer.LastName, Gender = customer.Gender, Email = details.Email, MobilePhone = details.MobilePhone, HomePhone = details.HomePhone, FacebookId = details.FacebookId, ContactDetailsId = details.Id.ToString(), Street = address.Street, City = address.City, Province = address.Province, ZipCode = address.ZipCode }; contactDetails.Add(contact); } } return(contactDetails); } return(null); }
public ActionResult Index(ContactViewModel model) { if (!ModelState.IsValid) { return(View(model)); } if (!Utils.CrawlerDetection.IsCrawler(Request.UserAgent)) { MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(new MailAddress("*****@*****.**")); mail.Subject = "Contactformulier op ttkaart.nl ingevuld"; mail.IsBodyHtml = false; mail.Body = "Iemand heeft een contactformulier op ttkaart.nl ingevuld.\n\n" + "Naam: " + model.Name + "\n" + "Email: " + model.Email + "\n" + "IP: " + Request.ServerVariables["REMOTE_ADDR"] + "\n" + "Onderwerp: " + model.Subject + "\n" + "Bericht: " + model.Message + "\n\n"; SmtpClient SmtpServer = new SmtpClient { DeliveryMethod = SmtpDeliveryMethod.Network, Host = "smtp.ttkaart.nl", Port = 25 }; SmtpServer.Send(mail); return(RedirectToRoute("Bedankt")); } return(View()); }
public async Task <List <ContactViewModel> > SearchContactByNumber(string number) { List <ContactViewModel> contactDetails = new List <ContactViewModel>(); List <ContactDetails> details = new List <ContactDetails>(); string[] words = number.Split(' '); foreach (var word in words) { List <ContactDetails> resultMobile = await _dbConext.ContactDetails.Where(c => c.MobilePhone.Contains(word)).ToListAsync(); if (resultMobile.Count > 0) { details.AddRange(resultMobile); } List <ContactDetails> resultHome = await _dbConext.ContactDetails.Where(c => c.HomePhone.Contains(word)).ToListAsync(); if (resultHome.Count > 0) { details.AddRange(resultHome); } } if (details.Count > 0) { List <ContactDetails> uniqueDetails = details.Distinct().ToList(); foreach (var detail in uniqueDetails) { if (detail != null) { ContactViewModel contact = await GetContactById(detail.CustomerId.ToString()); contactDetails.Add(contact); } } return(contactDetails); } return(null); }
public IActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { var email = Startup.Configuration["AppSettings:SiteEmailAddress"]; if (string.IsNullOrWhiteSpace(email)) { ModelState.AddModelError("", "Could not send email, configuration problem"); } if (_mailService.SendMail(email, email, $"Contact Page from {model.Name} ({model.Email})", model.Message)) { ModelState.Clear(); ViewBag.Message = "Mail Sent"; } } return(View()); }
public async Task Contact_ReturnRedirectToActionResult_ForValidModel() { //Arrange var model = new ContactViewModel { Message = "test", Topic = "test", EContact = Models.Enums.EContact.NotSelected }; mockUserManager.Setup(s => s.FindByNameAsync(It.IsAny <string>())).ReturnsAsync(new ApplicationUser { Id = "test" }); _contactRepository.Setup(s => s.SaveToDatabase(It.IsAny <Contact>())).Verifiable(); //Act var result = await _controller.Contact(model, "test"); //Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Success", redirectToActionResult.ActionName); Assert.Equal("Success", redirectToActionResult.ControllerName); }
public IActionResult Contact(ContactViewModel contact) { if (ModelState.IsValid) { var email = Startup.configuration["AppSettings:SiteEmailAdress"]; if (string.IsNullOrEmpty(email)) { ModelState.AddModelError("", "Could not send email, configuration is not found."); } if (_mailService.sendMail(email, email, $"Contact Page From {contact.Name} ({contact.Email})", contact.Message)) { ModelState.Clear(); ViewBag.Message = "Mail Sent. Thanks!"; } } return(View()); }
// GET: Contacts/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ContactViewModel contact = Mapper.Map <ContactViewModel>(contactService.Get(id.Value)); if (contact == null) { return(HttpNotFound()); } ViewBag.CityId = new SelectList(cityService.GetAllByCountryId(contact.CountryId ?? Guid.NewGuid()), "Id", "Name", contact.CityId); ViewBag.CompanyId = new SelectList(companyService.GetAll(), "Id", "Name", contact.CompanyId); ViewBag.CountryId = new SelectList(countryService.GetAll(), "Id", "Name", contact.CountryId); ViewBag.LeadSourceId = new SelectList(leadSourceService.GetAll(), "Id", "Name", contact.LeadSourceId); ViewBag.OtherCityId = new SelectList(cityService.GetAll(), "Id", "Name", contact.OtherCityId); ViewBag.OtherCountryId = new SelectList(countryService.GetAll(), "Id", "Name", contact.OtherCountryId); ViewBag.OtherRegionId = new SelectList(regionService.GetAll(), "Id", "Name", contact.OtherRegionId); ViewBag.RegionId = new SelectList(regionService.GetAllByCityId(contact.CityId ?? Guid.NewGuid()), "Id", "Name", contact.RegionId); ViewBag.ReportsToContactId = new SelectList(reportService.GetAll(), "Id", "Name", contact.ReportsToContactId); return(View(contact)); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (indexPath.Row == 0) { var createGroupTableViewController = (CreateGroupTableViewController)uiNewView.Storyboard.InstantiateViewController("CreateGroupTableViewController"); uiNewView.NavigationController.PushViewController(createGroupTableViewController, true); } else { var ChatCon = searchContact[indexPath.Row]; var ContactUser = ContactRepository.GetContactbyUserId(Convert.ToInt64(ChatCon.contactId)); var ContactView = new ContactViewModel { ContactId = (long)ChatCon.contactId, ProfileImageUrl = ContactUser.contactPicUrl }; var chatViewContaroller = (PrivateChatListViewController)uiNewView.Storyboard.InstantiateViewController("PrivateChatListViewController"); // var chatViewContaroller = (NewChatViewController)uiNewView.Storyboard.InstantiateViewController("NewChatViewController"); chatViewContaroller.contactViewModel = ContactView; uiNewView.NavigationController.PushViewController(chatViewContaroller, true); } }
private async void Directions_Clicked(object sender, EventArgs e) { ContactViewModel vmContact = ((ContactViewModel)BindingContext); Organization organization = vmContact.Organization; Friend.Contact contact = vmContact.Contact; Friend.Address address = contact.Address; var placemark = new Placemark { CountryName = address.Country, AdminArea = address.State, Thoroughfare = address.Address1 + " " + address.Address2, Locality = address.City, PostalCode = address.Postcode }; var options = new MapLaunchOptions { Name = organization.Name }; await Map.OpenAsync(placemark, options); }
public ActionResult ProcessOrder(ContactViewModel contactModel, string returnUrl) { if (ModelState.IsValid) { ShoppingCartModel cart = GetCart(); var model = new CreateOrderViewModel { Cart = cart, OrderInfo = contactModel, }; model.OrderInfo.Comment = contactModel.Comment; apiModelOrder.SaveOrderToDb("api/APIDbOrder", model); cart.Clear(); return(PartialView("_ThankYou")); } apiModelPayment.Payments = apiModelPayment.GetAllPaymentsFromDb("api/APIDbPayment"); contactModel.PaymentTypeList = apiModelPayment.Payments; apiModelDelivery.Deliveries = apiModelDelivery.GetAllDeliveriesFromDb("api/APIDbDelivery"); contactModel.DeliveryTypeList = apiModelDelivery.Deliveries; return(PartialView("OrderDetails", contactModel)); }
public JsonResult Update_Contact_Custom_Fields(ContactViewModel cViewModel) { try { cViewModel.Contact.Custom_Fields.UpdatedBy = ((UserInfo)Session["User"]).UserId; cViewModel.Contact.Custom_Fields.UpdatedOn = DateTime.Now; _contactMan.Update_Contact_Custom_Fields(cViewModel.Contact.Custom_Fields); cViewModel.Contact = _contactMan.Get_Contact_By_Id(cViewModel.Contact.Custom_Fields.Contact_Id); cViewModel.Friendly_Message.Add(MessageStore.Get("CO004")); } catch (Exception ex) { cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01")); Logger.Error("Contact Controller - Update_Contact_Custom_Fields " + ex.ToString()); } return(Json(cViewModel)); }
public IHttpActionResult GetContactByID(int id) { ContactViewModel contact = null; using (var cont = new ContactDatabaseEntities()) { contact = cont.Tables.Select(a => new ContactViewModel() { ContactID = a.ContactID, FirstName = a.FirstName, LastName = a.LastName, Email = a.Email, PhoneNumber = a.PhoneNumber, Status = a.Status }).Where(a => a.ContactID == id).FirstOrDefault <ContactViewModel>(); if (contact == null) { return(NotFound()); } return(Ok(contact)); } }
public async Task SendInternshipApplicationEmail(ContactViewModel form) { var body = "<p>Dear Administrator, </p>" + "<p> A new message has been submitted from the Contact page. <br/><br/>" + "==User details== <br/>" + "Name: {0}<br/>" + "Surname: {1}<br/>" + "Phone Number: {2}<br/>" + "Email Address: {3}<br/>" + "Message: {4}</p>"; var emailMessage = new MailMessage(); emailMessage.To.Add(new MailAddress("*****@*****.**")); emailMessage.From = new MailAddress("*****@*****.**"); emailMessage.Subject = "New Feedback/Question"; emailMessage.Body = string.Format(body, form.Name, form.Surname, form.PhoneNumber, form.EmailAddress, form.Message); emailMessage.IsBodyHtml = true; using (var smtp = new SmtpClient()) { await smtp.SendMailAsync(emailMessage); } }
public bool SendEmail(ContactViewModel model) { try { MailMessage message = new MailMessage(); SmtpClient client = new SmtpClient(); string toAddress = "*****@*****.**"; string fromAddress = "*****@*****.**"; message.Subject = $"Enquiry from: {model.Name} - {model.Email}"; message.Body = model.Message; message.To.Add(new MailAddress(toAddress, toAddress)); message.From = new MailAddress(fromAddress, fromAddress); client.Send(message); return(true); } catch (Exception ex) { _logger.Error(typeof(ContactSurfaceController), ex, "Error sending contact form."); return(false); } }
public ActionResult Contact(ContactViewModel customer) { string constr = ConfigurationManager.ConnectionStrings["ProductsModel"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { string query = "INSERT INTO dbo.ContactData(NameClient, Mail, City,Message) VALUES(@NameClient, @Mail, @City, @Message)"; query += " SELECT SCOPE_IDENTITY()"; using (SqlCommand cmd = new SqlCommand(query)) { cmd.Connection = con; con.Open(); cmd.Parameters.AddWithValue("@NameClient", customer.NameClient); cmd.Parameters.AddWithValue("@Mail", customer.Mail); cmd.Parameters.AddWithValue("@City", customer.City); cmd.Parameters.AddWithValue("@Message", customer.Message); customer.IdClient = Convert.ToInt32(cmd.ExecuteScalar()); con.Close(); } } return(RedirectToAction("ContactSent", "Contact"));; }
public async Task <IActionResult> Update([FromBody] ContactViewModel contactVm) { var hasPermission = await _authorizationService.AuthorizeAsync(User, "CONTACT", Operations.Update); if (hasPermission.Succeeded == false) { return(new BadRequestObjectResult(CommonConstants.Forbidden)); } if (ModelState.IsValid) { try { _contactService.Update(contactVm); _contactService.SaveChanges(); return(new OkObjectResult(contactVm.Id)); } catch (Exception ex) { return(new BadRequestObjectResult(ex.Message)); } } return(new BadRequestObjectResult(ModelState)); }
public ActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { try { var body = new StringBuilder(); body.AppendLine("Ad: " + model.Name); body.AppendLine("Soyad: " + model.Surname); body.AppendLine("Telefon: " + model.Phone); body.AppendLine("Eposta: " + model.Email); body.AppendLine("Mesaj: " + model.Message); Gmail.SendMail(body.ToString()); ViewBag.Success = true; ViewBag.Message = "Mesajınız Gönderildi.Teşekkür Ederiz."; } catch (Exception ex) { ViewBag.Eror = ("Form gönderimi başarısız oldu. Lütfen daha sonra tekrar deneyiniz.", ex); } } return(View(model)); }
public ActionResult Contact(ContactViewModel userdata) { if (!ModelState.IsValid) { return(View()); } var messageBody = string.Format("{0}{1}---{1}Sent by: {2}", userdata.Message, Environment.NewLine, userdata.GetNameDetails()); var message = new MailMessage(EmailService.DefaultContactEmail, EmailService.DefaultContactEmail) { Body = messageBody, Subject = "TeamReview.net - contact form" }; var displayName = userdata.GetDisplayName(); message.ReplyToList.Add(new MailAddress(userdata.EmailAddress, displayName)); new SmtpClient().Send(message); TempData["MessageSent"] = "true"; return(RedirectToAction("Contact")); }
public ActionResult Edit(int id) { ContactViewModel contact = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:51850/api/"); //HTTP GET var responseTask = client.GetAsync("contacts?id=" + id.ToString()); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <ContactViewModel>(); readTask.Wait(); contact = readTask.Result; } } return(View(contact)); }
public bool SendEmail(ContactViewModel model) { try { MailMessage message = new MailMessage(); SmtpClient client = new SmtpClient(); string toAddress = System.Web.Configuration.WebConfigurationManager.AppSettings["ContactEmailTo"]; string fromAddress = System.Web.Configuration.WebConfigurationManager.AppSettings["ContactEmailFrom"]; message.Subject = string.Format("Enquiry from: {0} - {1}", model.Name, model.Email); message.Body = model.Message; message.To.Add(new MailAddress(toAddress, toAddress)); message.From = new MailAddress(fromAddress, fromAddress); client.Send(message); return(true); } catch (System.Exception ex) { Logger.Error(MethodBase.GetCurrentMethod().DeclaringType, "Contact Form Error", ex); return(false); } }
public ActionResult EditContact(ContactViewModel vm) { if (!ModelState.IsValid) { return View(vm); } if (!this.IsContactDirty(vm)) { return RedirectToAction("Details", new { id = vm.AggregateId }); } CommandStackWorkerService.EditContactDetails(vm); return RedirectToAction("Details", new { id = vm.AggregateId }); }
private bool IsContactDirty(ContactViewModel vm) { var model = QueryStackWorkerService.GetContactForBankAccount(vm.AggregateId); return !model.Email.Equals(vm.Email.Trim()) || !model.PhoneNumber.Equals(vm.PhoneNumber.Trim()); }
public MainPage() { this.InitializeComponent(); DataContext = new ContactViewModel(); }
public ExporterViewModel() { Address = new AddressViewModel(); Contact = new ContactViewModel(); }