
Introduction
Coevery for Windows Phone is a free CRM Windows Phone application. It will allow you to easy filter Lead, Opportunity, Contract and Quote which belong to yourself. Also it will allow you to change
the status and edit comment.
You can find more cases on our website:
http://www.novasoftware.com/Developer/WindowsPhone.aspx?utm_source=codeplex&utm_medium=post&utm_campaign=Jon
Features
1. Login
2. Lead List/Detail/Comment
3. Opportunity List/Detail/Comment
4. Contract List/Detail/Comment
5. Quote List/Detail/Comment
MVVM & OData Protocal
public class BaseViewModel : INotifyPropertyChanged
{
private static CodeFirstContainer _context;
public event PropertyChangedEventHandler PropertyChanged;
public static CodeFirstContainer Context
{
get
{
if(_context == null)
{
_context = new CodeFirstContainer(new Uri("http://api.coevery.com/coevery/EntityDataService.svc"));
_context.MergeOption = MergeOption.OverwriteChanges;
Context.SendingRequest += SendingRequest;
}
return _context;
}
}
public static string Cookie { get; set; }
private static void SendingRequest(object sender, SendingRequestEventArgs e)
{
e.RequestHeaders["Cookie"] = Cookie;
}
protected virtual void OnPropertyChanged(string propertyName)
{
var propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public class OpportunityViewModel : BaseViewModel
{
public Guid OpportunityId { get; set; }
public Popup Popup { get; set; }
public event EventHandler EnableButton;
private DataServiceCollection<Opportunity> _opportunities;
public DataServiceCollection<Opportunity> Opportunities
{
get { return _opportunities; }
set
{
_opportunities = value;
_opportunities.LoadCompleted += LoadOpportunityData;
OnPropertyChanged("Opportunities");
}
}
private DataServiceCollection<Note> _notes;
public DataServiceCollection<Note> Notes
{
get { return _notes; }
set
{
_notes = value;
_notes.LoadCompleted += LoadCommentData;
OnPropertyChanged("Notes");
}
}
public void LoadData()
{
if (!Popup.IsOpen)
{
Popup.IsOpen = true;
EnableButton.Invoke(false, null);
}
Opportunities = new DataServiceCollection<Opportunity>(Context);
Notes = new DataServiceCollection<Note>(Context);
var query = (from cust in Context.Opportunities.Expand("Customer").Expand("Owner").Expand("Department")
where cust.OpportunityId == OpportunityId && cust.IsDeleted == false
select cust);
Opportunities.LoadAsync(query);
}
private void LoadOpportunityData(object sender, LoadCompletedEventArgs e)
{
if (Opportunities.Continuation != null)
{
Opportunities.LoadNextPartialSetAsync();
}
Notes.LoadAsync((from cust in Context.Notes.Expand("ModifiedBy") where cust.ObjectType == "Opportunity" && cust.ObjectId == OpportunityId && cust.IsDeleted == false orderby cust.CreatedOn descending select cust));
}
private void LoadCommentData(object sender, LoadCompletedEventArgs e)
{
if (Notes.Continuation != null)
{
Notes.LoadNextPartialSetAsync();
}
Popup.IsOpen = false;
EnableButton.Invoke(true, null);
}
}
Converter
public class ColorConverter : IValueConverter
{
bool isAlternate;
SolidColorBrush even = new SolidColorBrush(Color.FromArgb(255, 221, 221, 221));
SolidColorBrush odd = new SolidColorBrush(Color.FromArgb(255, 200, 238, 252));
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
isAlternate = !isAlternate;
return isAlternate ? even : odd;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Screenshot

