Esempio n. 1
0
 /// <summary>
 /// Create model
 /// </summary>
 /// <param name="document"></param>
 public static TrustRelationshipModel ToServiceModel(
     this TrustDocument document)
 {
     return(new TrustRelationshipModel {
         TrustedId = document.TrustedId,
         TrustingId = document.TrustingId,
         TrustingType = document.TrustingType,
         TrustedType = document.TrustedType,
     });
 }
Esempio n. 2
0
 /// <summary>
 /// Convert to service model
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static TrustDocument Clone(this TrustDocument model)
 {
     return(new TrustDocument {
         Id = model.Id,
         TrustedId = model.TrustedId,
         TrustingId = model.TrustingId,
         TrustingType = model.TrustingType,
         TrustedType = model.TrustedType,
         ETag = model.ETag,
         ClassType = model.ClassType
     });
 }
Esempio n. 3
0
        /// <summary>
        /// Convert to service model
        /// </summary>
        /// <param name="model"></param>
        /// <param name="id"></param>
        /// <param name="etag"></param>
        /// <returns></returns>
        public static TrustDocument ToDocumentModel(
            this TrustRelationshipModel model, string id = null, string etag = null)
        {
            if (string.IsNullOrEmpty(id))
            {
                // Assign unique id
                id = "utr" + (model.TrustedId + model.TrustingId).ToSha1Hash();
            }
            var document = new TrustDocument {
                ETag         = etag,
                Id           = id,
                TrustedId    = model.TrustedId,
                TrustingId   = model.TrustingId,
                TrustingType = model.TrustingType,
                TrustedType  = model.TrustedType,
                ClassType    = TrustDocument.ClassTypeName
            };

            return(document);
        }