public async Task <bool> AddRepresentation(Representation representation)
        {
            using (var transaction = await _context.Database.BeginTransactionAsync().ConfigureAwait(false))
            {
                var result = true;
                try
                {
                    var record = new Model.Representation
                    {
                        Id           = representation.Id,
                        Created      = representation.Created,
                        LastModified = representation.LastModified,
                        ResourceType = representation.ResourceType,
                        Version      = representation.Version,
                        Attributes   = GetRepresentationAttributes(representation)
                    };
                    _context.Representations.Add(record);
                    await _context.SaveChangesAsync().ConfigureAwait(false);

                    transaction.Commit();
                }
                catch
                {
                    result = false;
                    transaction.Rollback();
                }

                return(result);
            }
        }
        private List <RepresentationAttribute> GetRepresentationAttributes(Model.Representation representation)
        {
            if (representation.Attributes == null)
            {
                return(new List <RepresentationAttribute>());
            }

            return(GetRepresentationAttributes(representation.Attributes));
        }
        public static Model.Representation SetData(this Model.Representation representation, Domain.Representation repr)
        {
            if (repr == null)
            {
                throw new ArgumentNullException(nameof(repr));
            }

            representation.Created      = repr.Created;
            representation.LastModified = repr.LastModified;
            representation.ResourceType = repr.ResourceType;
            representation.Version      = repr.Version;
            return(representation);
        }
        public Task <bool> AddRepresentation(Representation representation)
        {
            var record = new Model.Representation
            {
                Id           = representation.Id,
                Created      = representation.Created,
                LastModified = representation.LastModified,
                ResourceType = representation.ResourceType,
                Version      = representation.Version,
                Attributes   = GetRepresentationAttributes(representation)
            };

            _representations.Add(record);
            return(Task.FromResult(true));
        }
        public static Domain.Representation ToDomain(this Model.Representation representation)
        {
            if (representation == null)
            {
                throw new ArgumentNullException(nameof(representation));
            }

            return(new Domain.Representation
            {
                Id = representation.Id,
                Created = representation.Created,
                LastModified = representation.Created,
                ResourceType = representation.ResourceType,
                Version = representation.Version
            });
        }