Feat: primera iteracion de los repositorios hecha

Signed-off-by fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
2024-02-23 23:35:00 -03:00
parent 619b6c5e04
commit 4e2e723ea4
6 changed files with 110 additions and 9 deletions

15
.gitignore vendored
View File

@@ -2,4 +2,17 @@
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################
/Vista/bin/Debug/net6.0-windows
Documentacion/DiagramaDeClases.bbl
Documentacion/DiagramaDeClases.pdf
Documentacion/DiagramaDeClases.synctex.gz
Documentacion/DiagramaDeClases.tex
Documentacion/final.bbl
Documentacion/final.synctex.gz
Documentacion/final.tex
Documentacion/svg-inkscape
.vs/Final_OOP/xs/UserPrefs.xml
Vista
Vista/obj/Vista.csproj.nuget.dgspec.json
Vista/obj/Vista.csproj.nuget.g.props
Vista/obj/project.assets.json
Vista/obj/project.nuget.cache

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 217 KiB

View File

@@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Controladora", "Controlador
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entidades", "Entidades\Entidades.csproj", "{78A331E5-86D4-427E-AA45-5879F9E5E98B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Modelo", "Modelo\Modelo.csproj", "{9A0960D9-C909-4B68-8BBB-8C44B9CD0E97}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modelo", "Modelo\Modelo.csproj", "{9A0960D9-C909-4B68-8BBB-8C44B9CD0E97}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vista", "Vista\Vista.csproj", "{8C9E8090-5D8F-42AE-9813-C68D384C6863}"
EndProject

View File

@@ -1,7 +0,0 @@
namespace Modelo
{
public class Class1
{
}
}

20
Modelo/IRepositorio.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
namespace Modelo
{
public interface IRepositorio<T>
{
private List<T> almacen;
// Añade objetos al almacen
public bool Add(T t);
// Modifica objetos del almacen
public bool Mod(T t);
// Elimina objetos del almacen
public bool Del(T t);
}
}

View File

@@ -0,0 +1,75 @@
namespace Modelo
{
public class RepositorioProductos : IRepositorio<Producto>
{
//Contructor Privado
private RepositorioProductos()
{
almacen = new List<Producto>;
}
// Singleton
private static RepositorioProductos instancia;
public static RepositorioProductos Instancia
{
get
{
if (instancia == null) instancia = new RepositorioProductos();
return instancia;
}
}
public bool Add(Producto t)
{
bool ret;
try
{
almacen.add(t);
ret = true;
}
catch (Exception e)
{
throw;
}
return ret;
}
public bool Mod(Producto t)
{
bool ret;
try
{
var AModificar = almacen.Find(x => x.Id == t.Id);
AModificar = t;
ret = true;
}
catch (Exception e)
{
throw;
}
return ret;
}
public bool Del(Producto t)
{
bool ret;
try
{
var AEliminar = almacen.Find(x => x.Id == t.Id);
almacen.remove(AEliminar);
ret = true;
}
catch (Exception e)
{
throw;
}
return ret;
}
}
}