public int InsertTypeSession(TypeSession typeSession) { using (var _sqlConnection = new SqlConnection(_config.GetConnectionString("mssql"))) { _sqlConnection.Open(); if (typeSession.UserId != "guest") { return(_sqlConnection.Execute(TypeSessionCommand.INSERT, new { userId = typeSession.UserId, sonnetId = typeSession.SonnetId, secondsElapsed = typeSession.SecondsElapsed, correctWordCount = typeSession.CorrectWordCount, typedWordCount = typeSession.TypedWordCount, misspelledWordCount = typeSession.MisspelledWordCount, quit = typeSession.Quit, touchScreen = typeSession.TouchScreen })); } else { return(_sqlConnection.Execute(TypeSessionCommand.INSERT_GUEST, new { sonnetId = typeSession.SonnetId, secondsElapsed = typeSession.SecondsElapsed, correctWordCount = typeSession.CorrectWordCount, typedWordCount = typeSession.TypedWordCount, misspelledWordCount = typeSession.MisspelledWordCount, quit = typeSession.Quit, touchScreen = typeSession.TouchScreen })); } } }
public ActionResult Post(TypeSession typeSession) { try { _service.AddTypeSession(typeSession); return(Ok()); } catch { return(BadRequest($"Invalid session data { typeSession }")); } }
public LogUser(Session ObjSession, TypeSession Option) { InitializeComponent(); this.ObjSession = ObjSession; OptionSession = (byte)Option; TextBoxPassword.PasswordTextBox = '*'; if (OptionSession.Equals(TypeSession.LogIn)) { LabelTitle.Text = "Iniciar Sesión"; LabelSubTitle.Text = "Ingresa tu usuario y contraseña"; } else { LabelTitle.Text = "Cerrar Sesión"; LabelSubTitle.Text = string.Empty; } } //Clave de Constructor: LogUser-C
public void InsertWordTuples(TypeSession typeSession) { List <WordTuple> wordTuples = typeSession.MisspelledWords; using (var _sqlConnection = new SqlConnection(_config.GetConnectionString("mssql"))) { dynamic result = null; _sqlConnection.Open(); // Find latest TypeSession.Id if (typeSession.UserId != "guest") { result = _sqlConnection.Query <TypeSession>(TypeSessionCommand.SELECT, new { userId = typeSession.UserId }).FirstOrDefault(); } else { result = _sqlConnection.Query <TypeSession>(TypeSessionCommand.SELECT_GUEST).FirstOrDefault(); } // Iterate over each List of WordTuples and INSERT foreach (WordTuple wt in wordTuples) { _sqlConnection.Execute(MisspellingCommand.INSERT, new { typeSessionId = result.Id, lineNumber = wt.LineNumber, index = wt.Index, modelWord = wt.ModelWord, typedWord = wt.TypedWord }); } } }
public void AddTypeSession(TypeSession typeSession) { _dao.InsertTypeSession(typeSession); Console.WriteLine("Completed to write session."); _dao.InsertWordTuples(typeSession); }