diff --git a/.gitignore b/.gitignore index a161b20..7d61b57 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Documentacion/DiagramaConRepos.jpg b/Documentacion/DiagramaConRepos.jpg index 0782017..c44386c 100644 Binary files a/Documentacion/DiagramaConRepos.jpg and b/Documentacion/DiagramaConRepos.jpg differ diff --git a/Final_OOP.sln b/Final_OOP.sln index e7276d0..9c7f6a3 100644 --- a/Final_OOP.sln +++ b/Final_OOP.sln @@ -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 diff --git a/Modelo/Class1.cs b/Modelo/Class1.cs deleted file mode 100644 index fb18f0e..0000000 --- a/Modelo/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Modelo -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/Modelo/IRepositorio.cs b/Modelo/IRepositorio.cs new file mode 100644 index 0000000..b967562 --- /dev/null +++ b/Modelo/IRepositorio.cs @@ -0,0 +1,20 @@ +using System; + +namespace Modelo +{ + public interface IRepositorio + { + + private List 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); + + } +} \ No newline at end of file diff --git a/Modelo/RepositorioProductos.cs b/Modelo/RepositorioProductos.cs new file mode 100644 index 0000000..daeb09d --- /dev/null +++ b/Modelo/RepositorioProductos.cs @@ -0,0 +1,75 @@ +namespace Modelo +{ + public class RepositorioProductos : IRepositorio + { + //Contructor Privado + private RepositorioProductos() + { + almacen = new List; + } + + // 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; + } + } +}