Skip to content

Instantly share code, notes, and snippets.

@csharpfritz
Created February 18, 2014 21:39
Show Gist options
  • Save csharpfritz/9080787 to your computer and use it in GitHub Desktop.
Save csharpfritz/9080787 to your computer and use it in GitHub Desktop.
Generic Telerik Backend Services Repository object
public class Repository<T> where T : DataItem
{
private EverliveApp app;
public Repository()
{
this.app = new EverliveApp(ConfigurationManager.AppSettings["apiKey"]);
app.WorkWith().Authentication().Login(ConfigurationManager.AppSettings["apiUser"], ConfigurationManager.AppSettings["apiPass"]);
}
public IEnumerable<T> GetAll()
{
return app.WorkWith().Data<T>().GetAll().ExecuteSync();
}
public Activity GetById(Guid id)
{
return app.WorkWith().Data<Activity>().GetById(id).ExecuteAsync().Result;
}
public IEnumerable<T> Get(Expression<Func<T, bool>> where)
{
return app.WorkWith().Data<T>().Get().Where(where).ExecuteSync();
}
public void Save(T objToSave)
{
app.WorkWith().Data<T>().Update(objToSave).ExecuteSync();
}
public void Delete(Guid id)
{
app.WorkWith().Data<T>().Delete(id).ExecuteSync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment