using System; using System.Collections.Generic; using System.Linq; namespace EPS.Common.Repositories { /// /// This is the contact for a repository. /// /// This is the type that will be used in the repository, it must /// implement IModel and have a public parameterless constructor. public interface IRepository where TModel : IModel, new() { /// /// Finds an instance of TModel by id. /// /// The id of the TModel instance to find. /// TModel if the id is found, otherwise null. TModel Find(int id); /// /// Doesn't really find anything, just returns everything in the repository. /// /// The contents of the repository. IEnumerable FindAll(); /// /// Orders the list by property name. /// /// Name of the property. /// The sort direction. /// A new list sorted by property name in the order indicated by the sortDirection. IEnumerable OrderBy(string propertyName, Sort sortDirection); /// /// Orders the list by property name. /// /// Values to indicate sorting properties. /// eg, new { Property = "FirName", SortAscending = true } /// IEnumerable OrderBy(object values); /// /// Inserts the instance if it does not already exist, otherwise updates the existing one. /// /// The model to save. void Save(TModel model); /// /// Deletes the specified model from the repository. /// /// The model to be removed. void Delete(TModel model); /// /// Gets a count of the number of models in the repository. /// /// The number of models in the repository. int Count { get; } } }