Пример #1
0
 public void SaveAccountDto(AccountDto accountDto)
 {
     if (accountDto.IsNew)
     {
         accountDto.Id = Guid.NewGuid();
     }
     SaveSpecificAccountDto(accountDto);
 }
Пример #2
0
 public static AccountDto GetTwitterAccount()
 {
     var twitterAccount = new AccountDto { ProviderKey = TwitterProviderKey, Notes = Note2 };
     twitterAccount.Fields.Add(new FieldDto { Id = Guid.NewGuid(), FieldTypeKey = "email", Name = "E-Mail", Value = TwitterEmail });
     twitterAccount.Fields.Add(new FieldDto { Id = Guid.NewGuid(), FieldTypeKey = "username", Name = "User name", Value = TwitterUserName });
     twitterAccount.Fields.Add(GetTwitterPassword());
     twitterAccount.Tags.Add(new TagDto { Key = Tag1 });
     return twitterAccount;
 }
Пример #3
0
 public AccountDto GetGoogle1Account()
 {
     var google1Account = new AccountDto { ProviderKey = GoogleProviderKey };
     google1Account.Fields.Add(new FieldDto { Id = Guid.NewGuid(), FieldTypeKey = "email", Name = "E-Mail", Value = Google1Email });
     google1Account.Tags.Add(new TagDto { Key = Tag1 });
     google1Account.Tags.Add(new TagDto { Key = Tag2 });
     google1Account.Tags.Add(new TagDto { Key = Tag3 });
     return google1Account;
 }
Пример #4
0
 public static AccountDto GetFacebookAccount()
 {
     var facebookAccount = new AccountDto { ProviderKey = FacebookProviderKey, Notes = Note1 };
     facebookAccount.Fields.Add(new FieldDto {Id = Guid.NewGuid(), FieldTypeKey = "email", Name = "E-Mail", Value = FacebookEmail });
     facebookAccount.Fields.Add(GetFacebookPassword());
     facebookAccount.Tags.Add(new TagDto { Key = Tag1 });
     facebookAccount.Tags.Add(new TagDto { Key = Tag2 });
     return facebookAccount;
 }
Пример #5
0
 public bool Equals(AccountDto otherAccountDto)
 {
     if (ReferenceEquals(null, otherAccountDto)) return false;
     if (ReferenceEquals(this, otherAccountDto)) return true;
     return otherAccountDto.ProviderKey.Equals(ProviderKey)
         && otherAccountDto.IsDeleted.Equals(IsDeleted)
         && otherAccountDto.Id.Equals(Id)
         && otherAccountDto.Fields.SequenceEqual(Fields)
         && otherAccountDto.Tags.SequenceEqual(Tags)
         && otherAccountDto.Notes.Equals(Notes);
 }
Пример #6
0
 public bool Equals(AccountDto otherAccountDto)
 {
     if (ReferenceEquals(null, otherAccountDto))
     {
         return(false);
     }
     if (ReferenceEquals(this, otherAccountDto))
     {
         return(true);
     }
     return(otherAccountDto.ProviderKey.Equals(ProviderKey) &&
            otherAccountDto.IsDeleted.Equals(IsDeleted) &&
            otherAccountDto.Id.Equals(Id) &&
            otherAccountDto.Fields.SequenceEqual(Fields) &&
            otherAccountDto.Tags.SequenceEqual(Tags) &&
            otherAccountDto.Notes.Equals(Notes));
 }
Пример #7
0
 protected abstract void SaveSpecificAccountDto(AccountDto accountDto);
Пример #8
0
 public void DeleteAccountDto(Guid accountId)
 {
     var deletedAccountDto = new AccountDto { Id = accountId, IsDeleted = true };
     SaveAccountDto(deletedAccountDto);
 }
Пример #9
0
 protected abstract void SaveSpecificAccountDto(AccountDto accountDto);
Пример #10
0
        internal void Update(AccountDto accountDto)
        {
            if (accountDto.Id != Id) {
                throw new Exception("Cannot update a different DTO, ID don't match");
            };
            accountDto.Fields.Clear();
            foreach (var field in Fields) {
                var fieldDto = new FieldDto {
                    Id = field.Id,
                    FieldTypeKey = field.FieldType.Key.ToString(),
                    Name = field.Name,
                    Value = field.Value
                };
                accountDto.Fields.Add(fieldDto);
            }

            accountDto.Tags.Clear();
            foreach (var tag in Tags) {
                accountDto.Tags.Add(new TagDto {
                    Key = tag.Key
                });
            }
            accountDto.Notes = Notes;
        }
Пример #11
0
        internal void Load(AccountDto accountDto)
        {
            Id = accountDto.Id;
            _provider = new Provider(accountDto.ProviderKey);
            foreach (var fieldDto in accountDto.Fields) {
                var field = new Field(
                        new FieldType(fieldDto.FieldTypeKey.ToEnum<FieldTypeKey>()),
                        fieldDto.Id,
                        fieldDto.Name) {
                    Value = fieldDto.Value
                };
                _fields.Add(field);
            }
            foreach (var tagDto in accountDto.Tags) {
                Tags.Add(tagDto.Key);
            }
            Notes = accountDto.Notes;
            LastChangedUtc = accountDto.LastChangedUtc;

            SetClean();
        }