public ActionResult GetAdminMessageWindow(message_table model) { MailMessage mail = new MailMessage(); SmtpClient smtpServer = new SmtpClient("smtp.gmail.com"); smtpServer.Credentials = new System.Net.NetworkCredential("stevecoautoparts", "******"); smtpServer.Port = 587; // Gmail works on this port string userEmail = ""; foreach (var userItem in storeDB.users_table) { // Created_by_user_num is just a placeholder for who the message is being sent to in this case if (userItem.user_num == model.created_by_user_num) { userEmail = userItem.user_email; } } // Send the message that the store owner created mail.From = new MailAddress("*****@*****.**"); mail.To.Add(userEmail); mail.Subject = "New Message"; mail.Body = model.user_message; smtpServer.EnableSsl = true; smtpServer.Send(mail); return(RedirectToAction("Account", "Account")); }
public ActionResult Account(message_table model) { message_table addedMessage = new message_table(); addedMessage.message_status = "Unreplied"; // Get user num int usernum = 0; foreach (var users in storeDB.users_table) { if (users.username == HttpContext.User.Identity.Name) { usernum = users.user_num; } } addedMessage.created_by_user_num = usernum; addedMessage.message_time = model.message_time; addedMessage.user_message = model.user_message; storeDB.message_table.Add(addedMessage); storeDB.SaveChanges(); TempData["messageSent"] = "Sent"; return(View(model)); }
public ActionResult GetAdminMessageWindow(int id) { message_table userToMessage = new message_table(); userToMessage.created_by_user_num = id; return(View("AccountAdminMessageUser", userToMessage)); }
public ActionResult GetMessageDetails(int id) { message_table currentMessage = new message_table(); foreach (var messageItem in storeDB.message_table) { if (messageItem.message_id == id) { currentMessage = messageItem; } } return(View("Index", currentMessage)); }
public ActionResult Account() { if (User.Identity.Name.ToLower() == "admin") { return(View("AccountAdmin")); } else if (User.Identity.Name.ToLower() == "owner") { return(View("AccountOwner")); } else { message_table model = new message_table(); return(View(model)); } }
public ActionResult GetPersonalDetails(users_table userEdit) { var userItem = storeDB.users_table.FirstOrDefault(users_table => users_table.username == HttpContext.User.Identity.Name); userItem.address = userEdit.address; userItem.first_name = userEdit.first_name; userItem.last_name = userEdit.last_name; userItem.user_email = userEdit.user_email; storeDB.Entry(userItem).State = System.Data.EntityState.Modified; storeDB.SaveChanges(); // Create new message table to give a date variable a placeholder in the account view message_table model = new message_table(); return(View("Account", model)); }
public ActionResult GetMessageDetails(message_table model) { MailMessage mail = new MailMessage(); SmtpClient smtpServer = new SmtpClient("smtp.gmail.com"); smtpServer.Credentials = new System.Net.NetworkCredential("stevecoautoparts", "******"); smtpServer.Port = 587; // Gmail works on this port string userEmail = ""; foreach (var userItem in storeDB.users_table) { if (userItem.user_num == model.created_by_user_num) { userEmail = userItem.user_email; } } // Send the message that the store owner created mail.From = new MailAddress("*****@*****.**"); mail.To.Add(userEmail); mail.Subject = "Reply to your question"; mail.Body = model.user_message; smtpServer.EnableSsl = true; smtpServer.Send(mail); var modifiedMessage = storeDB.message_table.FirstOrDefault(msg_table => msg_table.message_id == model.message_id); modifiedMessage.message_status = "Responded"; storeDB.Entry(modifiedMessage).State = System.Data.EntityState.Modified; storeDB.SaveChanges(); return(RedirectToAction("Account", "Account")); }
public ActionResult AccountAdminMessageUser(message_table userToMessage) { return(View(userToMessage)); }