Skip to content

Commit

Permalink
Added FullName property to Contact model. Added more sample data. Add…
Browse files Browse the repository at this point in the history
…ed AddRange() method to InMemoryRepository. Added Haversine class for coordinate distance calculation, and updated map generation to appropriately include all locations (previously, the map region was sometimes excluding locations). Updated DetailEditPage and DetailPage to omit the FullName field from being displayed.
  • Loading branch information
jsauvexamarin committed Jul 1, 2015
1 parent 0dc6540 commit 0fd0b06
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 75 deletions.
26 changes: 26 additions & 0 deletions MobileCRM/MobileCRM.Services/Models/Contact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ public string LastName {
}
}

[Display("Full Name")]
public string FullName
{
get {
if (string.IsNullOrWhiteSpace(FirstName) && string.IsNullOrWhiteSpace(LastName))
return string.Empty;
if (string.IsNullOrWhiteSpace(FirstName))
return LastName;
if (string.IsNullOrWhiteSpace(LastName))
return FirstName;
return string.Format("{0} {1}", FirstName, LastName);
}
}

public string Company {
get {
return InnerContact.Company ;
Expand Down Expand Up @@ -247,6 +261,18 @@ public string LastName {
get;
set;
}
public string FullName
{
get {
if (string.IsNullOrWhiteSpace(FirstName) && string.IsNullOrWhiteSpace(LastName))
return string.Empty;
if (string.IsNullOrWhiteSpace(FirstName))
return LastName;
if (string.IsNullOrWhiteSpace(LastName))
return FirstName;
return string.Format("{0} {1}", FirstName, LastName);
}
}
public string Company {
get;
set;
Expand Down
1 change: 1 addition & 0 deletions MobileCRM/MobileCRM.Services/Models/IContact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IContact
{
string FirstName { get; set; }
string LastName { get; set; }
string FullName { get; }

string Company { get; set; }
string Title { get; set; }
Expand Down
40 changes: 34 additions & 6 deletions MobileCRM/MobileCRM.Services/Repositories/AccountRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,42 @@

namespace MobileCRM.Services
{

public class AccountRepository : InMemoryRepository<Account>
public class AccountRepository : InMemoryRepository<Account>
{
public AccountRepository()
{
Add(new Account { Company = "InnoTech", Industry = "Software", Address = new Address { Street = "700 Pacific Ave", City = "San Francisco", State = "CA", PostalCode = "94111", Latitude = 37.79832, Longitude = -122.44 }});
Add(new Account { Company = "Umbrella Corp", Industry = "Medical" , Address = new Address { Street = "231 Broadway St", City = "San Francisco", State = "CA", PostalCode = "94111", Latitude = 37.79715, Longitude = -122.40358 }});
Add(
new Account
{
Company = "InnoTech",
Industry = "Software",
Address = new Address
{
Street = "700 Pacific Ave",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.79832,
Longitude = -122.44
}
});

Add(
new Account
{
Company = "Umbrella Corp",
Industry = "Medical",
Address = new Address
{
Street = "231 Broadway St",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.79715,
Longitude = -122.40358
}
});
}
}
}

}
46 changes: 40 additions & 6 deletions MobileCRM/MobileCRM.Services/Repositories/ContactRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,48 @@

namespace MobileCRM.Services
{

public class ContactRepository : InMemoryRepository<Contact>
public class ContactRepository : InMemoryRepository<Contact>
{
public ContactRepository()
{
Add(new Contact { FirstName = "Bob", LastName = "Harlan", Industry = "Software", Address = new Address { Latitude = 37.7993396, Longitude = -122.4017555 } });
Add(new Contact { FirstName = "Dory", LastName = "Himenez", Industry = "Logistic", Address = new Address { Latitude = 37.79798, Longitude = -122.40247 } });
Add(new Contact { FirstName = "Aria", LastName = "Patel", Industry = "Aerospace", Address = new Address { Latitude = 37.79632, Longitude = -122.40136 } });
Add(
new Contact
{
FirstName = "Bob",
LastName = "Harlan",
Industry = "Software",
Address = new Address
{
Latitude = 37.7993396,
Longitude = -122.4017555
}
});

Add(
new Contact
{
FirstName = "Dory",
LastName = "Himenez",
Industry = "Logistic",
Address = new Address
{
Latitude = 37.79798,
Longitude = -122.40247
}
});

Add(
new Contact
{
FirstName = "Aria",
LastName = "Patel",
Industry = "Aerospace",
Address = new Address
{
Latitude = 37.79632,
Longitude = -122.40136
}
});
}
}
}
}
12 changes: 12 additions & 0 deletions MobileCRM/MobileCRM.Services/Repositories/InMemoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Xamarin.Forms;
using MobileCRM.Services;
using MobileCRM.Models;
using System.Collections;

namespace MobileCRM.Services
{
Expand Down Expand Up @@ -76,6 +77,17 @@ public Task<T> Add (T item)
});
}

public Task<List<T>> AddRange(List<T> range)
{
return Task.Factory.StartNew(() => {
foreach (var item in range)
{
Items.Add(item);
}
return range;
});
}

#endregion

#region IDisposable implementation
Expand Down
103 changes: 98 additions & 5 deletions MobileCRM/MobileCRM.Services/Repositories/LeadRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,106 @@

namespace MobileCRM.Services
{

public class LeadRepository : InMemoryRepository<Lead>, IRepository<Lead>
public class LeadRepository : InMemoryRepository<Lead>, IRepository<Lead>
{
public LeadRepository()
{
Add(new Lead { FirstName = "Roy", LastName = "Ginsberg", Industry = "Retail", Address = new Address { Street = "394 Pacific Ave", City = "San Francisco", State = "CA", PostalCode = "94111", Latitude = 37.7970564, Longitude = -122.4034628 } });
var royGinsberg =
new Lead
{
FirstName = "Roy",
LastName = "Ginsberg",
Industry = "Retail",
Address = new Address
{
Street = "394 Pacific Ave",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.7970564,
Longitude = -122.4034628
}
};

var skipTaylor =
new Lead
{
FirstName = "Don",
LastName = "Draper",
Industry = "Advertising",
Address = new Address
{
Street = "120 Broadway",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.798861,
Longitude = -122.40039
}
};

var jimGeoffrey =
new Lead
{
FirstName = "Jim",
LastName = "Geoffrey",
Industry = "Entertainment",
Address = new Address
{
Street = "444 Battery St",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.795626,
Longitude = -122.400000
}
};

var turnerMcAvoy =
new Lead
{
FirstName = "Turner",
LastName = "McAvoy",
Industry = "Finance",
Address = new Address
{
Street = "600 Montgomery St",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.795212,
Longitude = -122.402836
}
};

var maxRockatansky =
new Lead
{
FirstName = "Max",
LastName = "Rockatansky",
Industry = "Motorsports",
Address = new Address
{
Street = "1 Embarcadero Center",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.794997,
Longitude = -122.399435
}
};

AddRange(
new List<Lead>
{
royGinsberg,
skipTaylor,
jimGeoffrey,
turnerMcAvoy,
maxRockatansky
}
);

}
}

}
}
44 changes: 37 additions & 7 deletions MobileCRM/MobileCRM.Services/Repositories/OpportunityRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,45 @@

namespace MobileCRM.Services
{

public class OpportunityRepository : InMemoryRepository<Opportunity>
public class OpportunityRepository : InMemoryRepository<Opportunity>
{
public OpportunityRepository()
{
var contact = new Contact { FirstName = "Henry", LastName = "Hunan", Address = new Address { Street = "518 Sansome St", City = "San Francisco", State = "CA", PostalCode = "94111", Latitude = 37.7980160, Longitude = -122.4019871 } };
var id = new User(new Contact { FirstName = "Javier", LastName = "Vasquez" }) { Username = "jvasquez" };
Add(new Opportunity(contact) { Company = "Capricorn Media", Industry = "Entertainment", EstimatedAmount = 15000.00M, Owner = id });
var contact =
new Contact
{
FirstName = "Henry",
LastName = "Hunan",
Address = new Address
{
Street = "518 Sansome St",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Latitude = 37.7980160,
Longitude = -122.4019871
}
};

var id =
new User(
new Contact
{
FirstName = "Javier",
LastName = "Vasquez"
})
{
Username = "jvasquez"
};

Add(
new Opportunity(contact)
{
Company = "Capricorn Media",
Industry = "Entertainment",
EstimatedAmount = 15000.00M,
Owner = id
});
}
}

}
}
27 changes: 23 additions & 4 deletions MobileCRM/MobileCRM.Services/Repositories/UserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,31 @@

namespace MobileCRM.Services
{
public class UserRepository : InMemoryRepository<User>, IRepository<User>
public class UserRepository : InMemoryRepository<User>, IRepository<User>
{
public UserRepository ()
public UserRepository()
{
Add(new User(new Contact { FirstName = "Javier", LastName = "Vasquez" }) { Username = "jvasquez" });
Add(new User(new Contact { FirstName = "Davon", LastName = "Smith" }) { Username = "dsmith" });
Add(
new User(
new Contact
{
FirstName = "Javier",
LastName = "Vasquez"
})
{
Username = "jvasquez"
});

Add(
new User(
new Contact
{
FirstName = "Davon",
LastName = "Smith"
})
{
Username = "dsmith"
});
}
}
}
Expand Down
Loading

0 comments on commit 0fd0b06

Please sign in to comment.