Skip to content

Commit

Permalink
redesigned the contact edit screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rawbenny committed Feb 28, 2014
1 parent 22b1c88 commit 0253c1a
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 368 deletions.
3 changes: 0 additions & 3 deletions App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

<Presenters:PhoneConverter x:Key="phoneConverter" />

<ObjectDataProvider x:Key="stateNames"
MethodName="GetNames"
ObjectType="{x:Type Model:States}" />

</ResourceDictionary>

Expand Down
2 changes: 0 additions & 2 deletions ContactManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Model\Address.cs" />
<Compile Include="Model\Contact.cs" />
<Compile Include="Model\ContactRepository.cs" />
<Compile Include="Model\States.cs" />
<Compile Include="Notifier.cs" />
<Compile Include="Presenters\ApplicationPresenter.cs" />
<Compile Include="Presenters\ContactListPresenter.cs" />
Expand Down
75 changes: 0 additions & 75 deletions Model/Address.cs

This file was deleted.

95 changes: 39 additions & 56 deletions Model/Contact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ namespace ContactManager.Model
[Serializable]
public class Contact : Notifier
{
private Address _address = new Address();
private string _name;
private int _age;
private string _address;
private string _cellPhone;
private string _firstName;
private string _homePhone;
private string _homePhone;
private Guid _id = Guid.Empty;
private string _imagePath;
private string _jobTitle;
private string _lastName;
private string _officePhone;
private string _organization;
private string _primaryEmail;
private string _secondaryEmail;
private string _studentId;
private string _grade;
private string _email;

public Guid Id
{
Expand All @@ -38,58 +36,50 @@ public string ImagePath
}
}

public string FirstName
public string Name
{
get { return _firstName; }
get { return _name; }
set
{
_firstName = value;
OnPropertyChanged("FirstName");
OnPropertyChanged("LookupName");
}
}
_name = value;
OnPropertyChanged("Name");

public string LastName
{
get { return _lastName; }
set
{
_lastName = value;
OnPropertyChanged("LastName");
OnPropertyChanged("LookupName");
}
}

public string Organization
public int Age
{
get { return _organization; }

get { return _age; }
set
{
_organization = value;
OnPropertyChanged("Organization");
_age = value;
OnPropertyChanged("Age");
}
}

public string JobTitle
public string Grade
{
get { return _jobTitle; }
get { return _grade; }
set
{
_jobTitle = value;
OnPropertyChanged("JobTitle");
_grade = value;
OnPropertyChanged("Grade");
}
}

public string OfficePhone
public string StudentId
{
get { return _officePhone; }
get { return _studentId; }
set
{
_officePhone = value;
OnPropertyChanged("OfficePhone");
_studentId = value;
OnPropertyChanged("StudentId");
}
}



public string CellPhone
{
get { return _cellPhone; }
Expand All @@ -110,27 +100,18 @@ public string HomePhone
}
}

public string PrimaryEmail
public string Email
{
get { return _primaryEmail; }
get { return _email; }
set
{
_primaryEmail = value;
OnPropertyChanged("PrimaryEmail");
_email = value;
OnPropertyChanged("Email");
}
}

public string SecondaryEmail
{
get { return _secondaryEmail; }
set
{
_secondaryEmail = value;
OnPropertyChanged("SecondaryEmail");
}
}

public Address Address
public string Address
{
get { return _address; }
set
Expand All @@ -140,20 +121,22 @@ public Address Address
}
}

public string LookupName
{
get { return string.Format("{0}, {1}", _lastName, _firstName); }
}

public override string ToString()
{
return LookupName;
return Name;
}

public override bool Equals(object obj)
{
Contact other = obj as Contact;
return other != null && other.Id == Id;
}
public override int GetHashCode()
{
int hash = 17;
// hash += CellPhone.GetHashCode();
//hash += HomePhone.GetHashCode();
return hash;
}
}
}
6 changes: 3 additions & 3 deletions Model/ContactRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public void Delete(Contact contact)
Serialize();
}

public List<Contact> FindByLookup(string lookupName)
public List<Contact> FindByLookup(string keyword)
{
IEnumerable<Contact> found =
from c in _contactStore
where c.LookupName.StartsWith(
lookupName,
where c.Name.StartsWith(
keyword,
StringComparison.OrdinalIgnoreCase
)
select c;
Expand Down
70 changes: 0 additions & 70 deletions Model/States.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Presenters/ApplicationPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void SaveContact(Contact contact)

StatusText = string.Format(
"Contact '{0}' was saved.",
contact.LookupName
contact.Name
);
}

Expand All @@ -92,7 +92,7 @@ public void DeleteContact(Contact contact)

StatusText = string.Format(
"Contact '{0}' was deleted.",
contact.LookupName
contact.Name
);
}

Expand Down
2 changes: 1 addition & 1 deletion Presenters/EditContactPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public EditContactPresenter(
ApplicationPresenter applicationPresenter,
EditContactView view,
Contact contact)
: base(view, "Contact.LookupName")
: base(view, "Contact.Name")
{
_applicationPresenter = applicationPresenter;
_contact = contact;
Expand Down
Loading

0 comments on commit 0253c1a

Please sign in to comment.