public void SaveAccountDto(AccountDto accountDto) { if (accountDto.IsNew) { accountDto.Id = Guid.NewGuid(); } SaveSpecificAccountDto(accountDto); }
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; }
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; }
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; }
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); }
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)); }
protected abstract void SaveSpecificAccountDto(AccountDto accountDto);
public void DeleteAccountDto(Guid accountId) { var deletedAccountDto = new AccountDto { Id = accountId, IsDeleted = true }; SaveAccountDto(deletedAccountDto); }
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; }
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(); }