예제 #1
0
 public SocialNetwork(SocialNetworkId socialNetworkId, UserId userId, string url,
                      Network network)
 {
     SocialNetworkId = socialNetworkId;
     UserId          = userId;
     Network         = network;
     Url             = FieldChecker.NotEmpty(url, nameof(url));
 }
예제 #2
0
        public SocialNetwork AddSocialNetwork(Network contactNetwork, string url)
        {
            var socialNetworkId  = SocialNetworkId.FromGuid(Guid.NewGuid());
            var userId           = UserId.FromGuid(Id);
            var newSocialNetwork = new SocialNetwork(socialNetworkId, userId, url, contactNetwork);

            if (_socialNetworks == null)
            {
                _socialNetworks = new HashSet <SocialNetwork>();
            }
            var socialNetworkFound = _socialNetworks.FirstOrDefault(e => e.Network == contactNetwork);

            if (socialNetworkFound != null)
            {
                newSocialNetwork = socialNetworkFound.UpdateUrl(url);
            }
            else
            {
                _socialNetworks.Add(newSocialNetwork);
            }

            return(newSocialNetwork);
        }