public ActionResult ReadMessage(MessageModel model) { MessageRepository repository = new MessageRepository(); repository.MarkRead(model.id); return View(model); }
public MessageModel GetBy(int id) { MessageModel message = new MessageModel(); var sql = string.Format("SELECT * FROM Message WHERE msg_id = '{0}'", id); var connectionString = "Server=(local);Database=Savnac.Database;Trusted_Connection=True;"; var command = new SqlCommand(sql, new SqlConnection(connectionString)); using (var connection = command.Connection) { connection.Open(); using (var reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { message = new MessageModel() { id = (int)reader["msg_id"], sender = reader["msg_sEmail"].ToString(), recipient = reader["msg_rEmail"].ToString(), subject = reader["msg_subject"].ToString(), message = reader["msg_content"].ToString(), timeSent = (DateTime)reader["msg_dateTime"], isRead = (bool)reader["msg_isRead"] }; } } return message; }
public ActionResult ComposeMessage(MessageModel model) { MessageRepository repository = new MessageRepository(); repository.AddMessage(User.Identity.Name, model.recipient, model.subject, model.message); return RedirectToAction("SendMessage"); }