/// <summary>Save the typo to the database.</summary> public void Save() { var typoRepository = new RelationalRepository <TypoRecord>(); var typoRecord = new TypoRecord { ID = this.Id, Note = this.Note, Resolved = this.Resolved, ResolvedByPlayerID = (long)this.ResolvedByPlayerId, RoomID = Convert.ToInt64(this.PlaceID), SubmittedByPlayerID = Convert.ToInt64(this.SubmittedByPlayerID), }; if (this.ResolvedDateTime != null) { typoRecord.ResolvedDateTime = this.ResolvedDateTime.ToString(); } else { typoRecord.ResolvedDateTime = null; } typoRecord.SubmittedDateTime = this.SubmittedDateTime.ToString(CultureInfo.InvariantCulture); if (typoRecord.ID == 0) { typoRepository.Add(typoRecord); this.Id = typoRecord.ID; } else { typoRepository.Update(typoRecord); } }
public void Remove(TypoRecord typo) { using (IDbCommand session = Helpers.OpenSession()) using (IDbTransaction transaction = session.Connection.BeginTransaction()) { session.Connection.Delete(typo); transaction.Commit(); } }
/// <summary>Initializes a new instance of the TypoEntry class.</summary> /// <param name="record"> The record that contains the information from the database.</param> public TypoEntry(TypoRecord record) { this.Id = record.ID; this.Note = record.Note; this.Resolved = record.Resolved; this.ResolvedByPlayerId = record.ResolvedByPlayerID; this.PlaceID = record.RoomID.ToString(CultureInfo.InvariantCulture); this.SubmittedByPlayerID = record.SubmittedByPlayerID.ToString(CultureInfo.InvariantCulture); this.SubmittedDateTime = DateTime.Parse(record.SubmittedDateTime); if (record.ResolvedDateTime != null) { this.ResolvedDateTime = DateTime.Parse(record.ResolvedDateTime); } else { this.ResolvedDateTime = null; } }