public async Task <ContactMessage> Put(ContactMessage updateContactMessage) { _context.Update(updateContactMessage); await _context.SaveChangesAsync(); return(updateContactMessage); }
/// <summary> /// Dodaje kontakt na bazę [WWW.ContactMessage] /// </summary> public Result AddContactMessage(ContactMessage message) { Result result = new Result(); try { FillMessage(message); _contactRepo.AddMessage(message); if (message.ID > 0) { result.IsOK = true; result.Message = $"Wiadomość wysłana pomyślnie! Otrzymała ID = '{message.ID}'"; _log.Debug("[AddContactMessage] Dodano wiadomosc o temacie = '{0}' z IP = '{1}'. Otrzymala ID = '{2}'", message.Subject, message.Content, message.ID); } else { result.Message = "Wystąpił błąd podczas wysyłania wiadomości!"; } } catch (Exception ex) { _log.Error("[AddContactMessage] Ex: {0} StackTrace: {1}", ex.MessageFromInnerEx(), ex.StackTrace); result.Message = $"Ex: {ex.MessageFromInnerEx()}"; } return(result); }
public async Task DeleteAsync_WithExistingMessage_ReturnsTrue() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new ContactMessage() { FullName = "TestFullName", Email = "*****@*****.**", Subject = "TestSubject", Message = "MessageTest" }; context.ContactMessages.Add(model); await context.SaveChangesAsync(); var contactMessagesService = new ContactMessagesService(new EfRepository <ContactMessage>(context), new EfRepository <User>(context)); var result = await contactMessagesService.DeleteAsync(model.Id); Assert.True(result); var dbModels = await context.ContactMessages.AnyAsync(); Assert.False(dbModels); }
public void DeleteContactMessageShouldDeleteMessageCorrect() { // Arrange var options = new DbContextOptionsBuilder <WAGDbContext>() .UseInMemoryDatabase(databaseName: "Delete_Message_Db") .Options; var dbContext = new WAGDbContext(options); var service = new ContactMessageService(dbContext); string userId = Guid.NewGuid().ToString(); var message = new ContactMessage() { Title = "Test title", TextBody = "Test textBody", WAGUserId = userId, }; dbContext.ContactMessages.Add(message); dbContext.SaveChanges(); var messageId = dbContext.ContactMessages.LastOrDefault().Id; // Act service.DeleteContactMessage(messageId); // Assert Assert.Null(dbContext.ContactMessages.FirstOrDefault(m => m.Id == messageId)); }
public ActionResult Contact(ContactMessage message) { if (!ModelState.IsValid) { return(RedirectToAction("Listen")); } MailMessage mail = new MailMessage(); SmtpClient client = new SmtpClient(); mail.From = new MailAddress("*****@*****.**", "CCP Website"); mail.To.Add(new MailAddress("*****@*****.**")); if (message.Subject == null) { mail.Subject = "Too cool for a subject"; } mail.Subject = message.Subject; mail.Body = message.Body + Environment.NewLine + "Return Email: " + message.ReturnEmail; client.Host = "smtp.gmail.com"; client.Port = 587; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "ultimatepassword"); client.EnableSsl = true; client.Send(mail); return(RedirectToAction("Thanks")); }
public IActionResult _Contact(ContactMessage contact) { ContactMessage cm = new ContactMessage(); cm.CreatedDate = DateTime.Now; cm.EmailUser = contact.EmailUser; cm.IPAddress = contact.IPAddress; cm.Message = contact.Message; cm.Name = contact.Name; cm.UserAgent = Request.Headers["User-Agent"]; _context.ContactMessage.Add(cm); var message = ""; try { _context.SaveChanges(); message = "Terima kasih telah menghubungi kami."; } catch { message = "Mohon maaf, terdapat kesalahan di sistem. Silahkan input pesan kembali."; } var routeValues = new RouteValueDictionary { { "message", message } }; return(Redirect(Url.RouteUrl(new { controller = "Home", action = "Index" }) + "?message=" + message + "#contact")); }
public async Task AddContactMessageAsync(CreateContactMessageCommand command) { var contactmessage = new ContactMessage(command.Name, command.Email, command.Text); await _context.ContactMessages.AddAsync(contactmessage); await _context.SaveChangesAsync(); }
public ActionResult <string> Post([FromBody] ContactMessage message) { if (message is null) { return(JsonConvert.SerializeObject(new { status = "error", message = "invalid input" })); } try { string result = _SlackClient.PostMessage(message.Message); if (result.Equals("ok")) { return(JsonConvert.SerializeObject(new { status = "ok", message = "message successfully submitted" })); } else { return(JsonConvert.SerializeObject(new { status = "error", message = "failed to send message" })); } } catch { return(JsonConvert.SerializeObject(new { status = "error", message = "System Error" })); } }
public async Task AddMessageAsync(NewMessageInputModel input, string userId) { var user = this.userRepository.All().FirstOrDefault(x => x.Id == userId); var contactMassage = new ContactMessage { Name = input.Name, Email = input.Email, Subject = input.Subject, Message = input.Massage, AnswerMassage = null, Status = "NotAnswered", SendDate = DateTime.UtcNow, AnswerDate = null, }; var userMassage = new UserMessage { User = user, ContactMassage = contactMassage, }; await this.usermassageRepository.AddAsync(userMassage); await this.usermassageRepository.SaveChangesAsync(); }
public void Add(ContactMessage contactMessage) { var conn = DbConnection.GetConnection(); const string cmdText = @"sp_ContactMessagesInsert"; using (var cmd = new SqlCommand(cmdText, conn) { CommandType = CommandType.StoredProcedure }) { cmd.Parameters.AddWithValue("@Name", contactMessage.Name); cmd.Parameters.AddWithValue("@Email", contactMessage.Email); cmd.Parameters.AddWithValue("@Subject", contactMessage.Subject); cmd.Parameters.AddWithValue("@MessageBody", contactMessage.Message); cmd.Parameters.AddWithValue("@TimePosted", DateTime.Now); try { conn.Open(); var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected != 1) { throw new ApplicationException(DbError.CreateFailed.ToString()); } } catch (Exception) { throw; } } }
public void Update(ContactMessage message) { _ChangeTextColorOfConversationTxt(true, MessageParser.CreateConversationMessageForUser(conversationTxt.Text, message.GetMessage(), _contact.GetName() + ": ")); _windowReceiveId = message.GetEmissorId(); _senderService.SendData(_windowEmissorId, _contact.GetIp(), 13); Focus(); }
public async Task <IActionResult> Post(ContactMessage model) { using (var smtpClient = new SmtpClient(_options.Host, _options.Port) { UseDefaultCredentials = false, Credentials = new NetworkCredential(_options.Username, _options.Password), EnableSsl = _options.UseSTARTTLS, DeliveryMethod = SmtpDeliveryMethod.Network, }) { var message = new MailMessage() { Subject = model.Subject, Body = model.Message, IsBodyHtml = true, }; foreach (var receiver in _options.Recipients) { message.To.Add(receiver); } message.From = new MailAddress(_options.From); message.ReplyToList.Add(new MailAddress(model.Email, model.Name)); _logger.LogDebug("Attempting to send Email:\n{mail}", model); await smtpClient.SendMailAsync(message); _logger.LogInformation("Sent Email '{subject}' to {receipients}", message.Subject, string.Join(", ", message.To.Select(t => t.Address))); return(Ok()); } }
public ActionResult Invite(ContactMessage contact) //sent here from the HouseHold details page { var inv = new Invite(); inv.EmailInvite = contact.Email; inv.HhId = contact.HhId; inv.CodeNr = KeyGenerator.GetUniqueKey(7); db.Invites.Add(inv); db.SaveChanges(); var requestor = contact.FName + ' ' + contact.LName; var Emailer = new EmailService(); contact.Message = "Please join my financial household. You will have to create an account on the application. Begin by going to Http://jmm-financialportal.azurewebsites.net to login and use the code listed below to validate"; var mail = new IdentityMessage { Subject = "Invitation to Join", Destination = contact.Email, Body = "You have received an invitation with the following contents. \n\n" + contact.Message + "\n\n Your Invitation Code is: " + inv.CodeNr }; Emailer.SendAsync(mail); return(RedirectToAction("Details", new { id = inv.HhId })); }
public ActionResult Contact(ContactMessage model) { if (ModelState.IsValid) { ContactMessage message = new ContactMessage() { Name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Name).Trim(), Surname = CultureInfo.CurrentCulture.TextInfo.ToUpper(model.Surname).Trim(), Email = CultureInfo.CurrentUICulture.TextInfo.ToLower(model.Email).Trim().Replace(" ", string.Empty), Subject = model.Subject.Trim(), Text = model.Text.Trim(), IsRead = false, DateTime = DateTime.Now }; int db_Res = _contactManager.Insert(message); if (db_Res > 0) { ViewBag.Result = true; } else { ViewBag.Result = false; } } return(View(model)); }
public ActionResult Index(ContactMessage message) { ContactViewModel model = new ContactViewModel { SocialLinks = _context.SocialLinks.OrderBy(s => s.Orderby).ToList(), ContactUs = _context.ContactUs.FirstOrDefault(), Message = new ContactMessage { Name = message.Name, Phone = message.Phone, Email = message.Email, Desc = message.Desc } }; if (ModelState.IsValid) { message.Status = true; db.ContactMessages.Add(message); db.SaveChanges(); return(RedirectToAction("index")); } return(View(model)); }
public override void Process(HttpRequestArgs args) { Assert.ArgumentNotNull(args, "args"); if (Tracker.Current != null && Tracker.Current.IsActive && Tracker.Current.Session != null) { var currentContact = Tracker.Current.Session.Contact; var currentInteraction = Tracker.Current.Session.Interaction; if (currentContact != null && currentInteraction != null) { var personalInfo = currentContact.GetFacet <Sitecore.Analytics.XConnect.Facets.IXConnectFacets>("XConnectFacets"); var contactMessage = new ContactMessage() { ContactId = currentContact.ContactId.ToString(), //ContactName = $"{personalInfo} {personalInfo.LastName}", CurrentPage = currentInteraction.CurrentPage.Url.ToString(), SiteName = currentInteraction.SiteName, UserAgent = currentInteraction.UserAgent, SessionType = ContactSessionEventType.UpdateSession, IP = currentInteraction.Ip.ToString(), Location = $"{currentInteraction.GeoData.City} , {currentInteraction.GeoData.Country}" }; //RD.MessageQueue.Service //var messageService = Sitecore.Configuration.Factory.CreateObject("rd/messagequeue/service/contactmessagequeueservice", true) //as Service.ContactMessageQueueService; Service.ContactMessageQueueService messageService = (Service.ContactMessageQueueService)ServiceLocator.ServiceProvider.GetService(typeof(Service.IContactMessageQueueService)); //Relay Message messageService.SendContactMessage(contactMessage); } } }
public void SaveContactMessageShouldSaveContactMsgCorrect() { // Arrange var options = new DbContextOptionsBuilder <WAGDbContext>() .UseInMemoryDatabase(databaseName: "Save_ContactMessage_Db") .Options; var dbContext = new WAGDbContext(options); var service = new ContactMessageService(dbContext); var contactMessageViewModel = new ContactMessage() { Title = "Test title", TextBody = "Test textBody", }; string userId = Guid.NewGuid().ToString(); // Act service.SaveContactMessage(contactMessageViewModel, userId); var savedMessage = dbContext.ContactMessages.LastOrDefault(); // Assert Assert.NotNull(savedMessage); Assert.Equal(userId, savedMessage.WAGUserId); Assert.Equal(contactMessageViewModel.Title, savedMessage.Title); Assert.Equal(contactMessageViewModel.TextBody, savedMessage.TextBody); }
public static ContactMessageDto ToDto(this ContactMessage contactMessage) => new ContactMessageDto { ContactMessageId = contactMessage.ContactMessageId, Value = contactMessage.Value, Version = contactMessage.Version };
public ActionResult Contact(string data) { JObject o = JObject.Parse(data); string Name = (string)o["Name"]; string Email = (string)o["Email"]; string Subject = (string)o["Subject"]; string Message = (string)o["Message"]; ContactMessage CMessage = new ContactMessage() { Name = Name, Email = Email, Date = DateTime.Now, Subject = Subject, Message = Message, IsRead = false }; try { unitOfWork.ContactMessageRepository.Create(CMessage); unitOfWork.Save(); //_repositoryContact.New(CMessage); Response.StatusCode = 200; } catch (Exception e) { Response.StatusCode = 500; } return(View()); }
public IActionResult Edit(int id, [Bind("Id,FullName,Email,Messsage")] ContactMessage contactMessage) { return(RedirectToAction(nameof(Index))); //if (id != contactMessage.Id) //{ // return NotFound(); //} //if (ModelState.IsValid) //{ // try // { // _context.Update(contactMessage); // await _context.SaveChangesAsync(); // } // catch (DbUpdateConcurrencyException) // { // if (!ContactMessageExists(contactMessage.Id)) // { // return NotFound(); // } // else // { // throw; // } // } // return RedirectToAction(nameof(Index)); //} //return View(contactMessage); }
public async Task <IActionResult> Message(ContactMessage message1) { Contact contact = await _context.Contacts.Include(x => x.ContactMessages).FirstOrDefaultAsync(x => x.Id == message1.ContactId); if (contact == null) { return(NotFound()); } ContactMessage contactMessage = new ContactMessage { CreatedAt = DateTime.UtcNow, ModifiedAt = DateTime.UtcNow, Email = message1.Email, FullName = message1.FullName, ContactId = message1.ContactId, Subject = message1.Subject, Message = message1.Message }; contact.ContactMessages.Add(contactMessage); await _context.SaveChangesAsync(); return(RedirectToAction("index")); }
public async Task <IActionResult> PutContactMessage([FromRoute] Guid id, [FromBody] ContactMessage contactMessage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != contactMessage.Id) { return(BadRequest()); } _context.Entry(contactMessage).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactMessageExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult Contact(ContactMessage contact) { ContactMessage cm = new ContactMessage { CreatedDate = DateTime.Now, EmailUser = contact.EmailUser, IPAddress = contact.IPAddress, Message = contact.Message, Name = contact.Name, UserAgent = Request.Headers["User-Agent"] }; _context.ContactMessage.Add(cm); try { _context.SaveChanges(); ViewBag.Message = "Terima kasih telah menghubungi kami."; } catch { ViewBag.Message = "Mohon maaf, terdapat kesalahan di sistem. Silahkan input pesan kembali."; } return(View()); }
/// <summary> /// 接收消息 /// </summary> /// <param name="session"></param> /// <param name="message"></param> public void ReceiveMessage(ContactSession session, Message message) { try { if (message.Type == InstanceAnswerPro.Core.MessageType.ContactMessage) { ContactMessage message2 = message as ContactMessage; Buddy sender = ComponentManager.GetBuddyListBuilder().FindOrCreateBuddy(message2.Uin, true); SessionTabItem item = this.FindIMSession(session); if ((sender != null) && (item != null)) { item.AddMsg(sender, message2.Time, message2.MessagePack); } } else if (message.Type == InstanceAnswerPro.Core.MessageType.InfoMessage) { InfoMessage message3 = message as InfoMessage; SessionTabItem item2 = this.FindIMSession(session); if (item2 != null) { item2.AddMsg(null, message3.Time, message3.MessagePack); } } } catch (Exception) { } }
public ActionResult Contact(ContactMessage form) { if (!ModelState.IsValid) { return(View(form)); } var emailer = new EmailService(); var mail = new IdentityMessage() { Destination = ConfigurationManager.AppSettings["PersonalEmail"], Subject = form.Subject, Body = "You have received a new contact form submission from" + form.Name + "(" + form.FromEmail + ") with the following contents:<br /><br /><br />" + form.Message }; emailer.SendAsync(mail); //TempData["MessageSent"] = "Your message has been delivered successfully."; ViewBag.Messagesent = "Your message has been delivered successfully."; return(View()); //return RedirectToAction("Contact"); /* ViewBag.Message = "Contact Shane Overby"; * return View();*/ }
public async Task <ContactMessage> Post(ContactMessage ContactMessage) { _context.ContactMessage.Add(ContactMessage); await _context.SaveChangesAsync(); return(ContactMessage); }
public void GetContactMessageByIdShouldReturnsMessageCorrect() { // Arrange var options = new DbContextOptionsBuilder <WAGDbContext>() .UseInMemoryDatabase(databaseName: "Get_Message_ById_Db") .Options; var dbContext = new WAGDbContext(options); var service = new ContactMessageService(dbContext); string userId = Guid.NewGuid().ToString(); var message = new ContactMessage() { Title = "Test title", TextBody = "Test textBody", WAGUserId = userId, }; dbContext.ContactMessages.Add(message); dbContext.SaveChanges(); var messageId = dbContext.ContactMessages.LastOrDefault().Id; // Act var savedMessage = service.GetContactMessageById(messageId); // Assert Assert.Equal(message, savedMessage); }
public void UpdateContactMessage(ContactMessage message) { if (message == null) { throw new ArgumentNullException("ContactMessage"); } _contactMessageRepository.Update(message); }
/// <summary> /// 添加数据 /// </summary> /// <param name="message"></param> public void InsertContactMessage(ContactMessage message) { if (message == null) { throw new ArgumentNullException("ContactMessage"); } _contactMessageRepository.Insert(message); }
public ActionResult DeleteConfirmed(int id) { ContactMessage contactMessage = db.ContactMessages.Find(id); db.ContactMessages.Remove(contactMessage); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult SendMessage(ContactMessage cm) { if (ModelState.IsValid) { // FakeContactRepository.Send(message); _repository.Add(new InternalMessage() { Author = cm.Name, Content = cm.Message, CreationDate = cm.CreationDate }); return RedirectToAction("MessageSent", cm); } else { return View(cm); } }
public ActionResult Index(ContactMessageData contactMessageData) { if (contactMessageData == null) return View(); if (!validator.IsValid(contactMessageData)) { AddErrorMessage("Please fill in all fields correctly, thanks!"); return View(); } var contactMessage = new ContactMessage(contactMessageData.Email, contactMessageData.Name, contactMessageData.Subject, contactMessageData.Message); try { emailService.Send(contactMessage); TempData["ContactMessage"] = contactMessage; } catch (Exception ex) { AddErrorMessage(ex.Message); } return RedirectToAction("Sent"); }
public ActionResult MessageSent(ContactMessage message) { return View(message); }
public static void Send(ContactMessage message) { _messages.Add(message); }
public void ReceiveMessage(ContactMessage contactMessage) { try { InstanceAnswerPro.Core.Buddy sender = ComponentManager.GetBuddyListBuilder().FindOrCreateBuddy(contactMessage.Uin, true); if (sender != null) { this.AddMsg(sender, contactMessage.Time, contactMessage.MessagePack); } } catch (Exception) { } }
public ActionResult SendMessage() { ContactMessage message = new ContactMessage(); return View(message); }