/// <summary> /// Creates a new cigar. /// </summary> public static Cigar New() { CigarState state = new CigarState() { Id = Guid.NewGuid() }; return(new Cigar(state)); }
public void ShouldBindStateToProperties() { CigarState state = new CigarState() { Id = Guid.NewGuid() }; Cigar cigar = Cigar.Load(state); Assert.Equal(state.Id, cigar.Id); }
/// <inheritdoc /> public async Task <Cigar> Load(Guid id) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", id, DbType.Guid, ParameterDirection.Input); EntityState entityState = await _client.ExecuteInManagedConnectionAsync(connection => connection.QuerySingleOrDefaultAsync <EntityState>( "[Catalog].[Cigars_GetSingle]", parameters, commandType: CommandType.StoredProcedure) ); if (entityState == null) { return(null); } CigarState cigarState = _serializer.Deserialize <CigarState>(entityState.SerializedContent); return(Cigar.Load(cigarState)); }
/// <summary> /// Loads a previously saved cigar. /// </summary> /// <param name="state"> /// Required state of the cigar to load. /// </param> public static Cigar Load(CigarState state) { return(new Cigar(state)); }
/// <summary> /// Creates a new instance of the <see cref="Cigar"/> class. /// </summary> /// <param name="state"> /// Required cigar state. /// </param> private Cigar(CigarState state) { _state = state ?? throw new ArgumentNullException(nameof(state)); }