public ActionResult Chat() { //Obtaining the data source var dbTripleThreatGame = new TripleThreatGameDataContext(); //gets stuff from the DB IEnumerable <chatModels> result = (from c in dbTripleThreatGame.chats select new chatModels { chat = c.chat1 }); return(PartialView(result)); }
public ActionResult Chat(string chatField = null) { //Obtaining the data source var dbTripleThreatGame = new TripleThreatGameDataContext(); if (chatField != null) { // Query the database for the row to be updated. var getRowToBeUpdated = from c in dbTripleThreatGame.chats where c.Id == 1 select c; // Execute the query, and change the column values // you want to change. foreach (chat c in getRowToBeUpdated) { c.chat1 += "<br>" + "<span class=\"chat-name\">" + User.Identity.Name + "</span> " + chatField + "<span class=\"chat-time\"> " + DateTime.Now + "</span>"; } // Submit the changes to the database. try { dbTripleThreatGame.SubmitChanges(); } catch (Exception e) { //Console.WriteLine(e); // Provide for exceptions. } } //gets stuff from the DB IEnumerable <chatModels> result = (from c in dbTripleThreatGame.chats select new chatModels { chat = c.chat1 }); return(PartialView(result)); }
public ActionResult Game() { //Obtaining the data source var dbTripleThreatGame = new TripleThreatGameDataContext(); int userId = 1; // Create a Game Object To Store the userid in the games table. game newGame = new game(); newGame.UserId = userId; dbTripleThreatGame.games.InsertOnSubmit(newGame); dbTripleThreatGame.SubmitChanges(); gameModels currentGame = new gameModels(); currentGame.ID = newGame.ID; return(View("Game", currentGame)); }