rafaelturon/blockchain-investments

View on GitHub
src/Blockchain.Investments.Core/Domain/ReadModel/Events/ParentAccountAssigned.cs

Summary

Maintainability
A
2 hrs
Test Coverage
using System;
using Blockchain.Investments.Core.Domain;
using CQRSlite.Events;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace Blockchain.Investments.Core.ReadModel.Events
{
    public class ParentAccountAssigned : IEvent 
    {
        private ObjectId _objectId;
        [BsonId]
        public ObjectId ObjectId 
        {
            get
            {
                if (_objectId.ToString().Equals("000000000000000000000000"))
                    _objectId = ObjectId.GenerateNewId();

                return _objectId;
            }
            set
            {
                _objectId = value;
            }
        }
        public Guid Id
        {
            get
            {
                return new Guid(AggregateId);
            }
            set
            {
                AggregateId = value.ToString();
            }
        }
        public string AggregateId {get; set;}
        
        public string ParentAccountId { get; set; }
        public int Version { get; set; }
        public DateTimeOffset TimeStamp { get; set; }
        public ParentAccountAssigned() {}
        public ParentAccountAssigned(Guid id, string parentAccountId) 
        {
            Id = id;
            AggregateId = id.ToString();
            ParentAccountId = parentAccountId;
        }
    }
}