Skip to content

Instantly share code, notes, and snippets.

@camarin24
Created November 22, 2016 19:09
Show Gist options
  • Save camarin24/6d2f56daabf9be73636de614cc5b8c39 to your computer and use it in GitHub Desktop.
Save camarin24/6d2f56daabf9be73636de614cc5b8c39 to your computer and use it in GitHub Desktop.
TypeScript Interfaces implementations
interface IRepository<T>{
Delete(Entity:T):T;
Update(Entity:T):T;
Create(Entity:T):T;
}
class IComprasRepository implements IRepository<ComprasModel>{
private _url:string;
constructor(url:string){
this._url = url;
}
Delete(Entity:ComprasModel){
return Entity;
}
Update(Entity:ComprasModel){
return Entity;
}
Create(Entity:ComprasModel){
console.log("Se inserto en la url:" + this._url);
console.log(Entity.ProductoId);
console.log(Entity.Producto);
console.log(Entity.Descripcion);
return Entity;
};
}
class ComprasService extends IComprasRepository{
constructor(url:string){
super(url);
};
}
function Insertar(){
let service = new ComprasService("/ComprasService");
service.Create({Descripcion:"Esto es una descripción",Producto:"Cebollas",ProductoId:15})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment