Commit 45688c04 authored by Facundo Nicolas Prieto Motta's avatar Facundo Nicolas Prieto Motta
Browse files

commit inicial

parents
using dal;
using System.Collections.Generic;
using System.Linq;
namespace bl
{
public class CursoManager
{
public List<Curso> lists()
{
using (var ctx = new MyContext())
{
var cursos = ctx.Cursos.ToList();
return cursos;
}
}
public void add(Curso curso)
{
using (var ctx = new MyContext())
{
ctx.Cursos.Add(curso);
ctx.SaveChanges();
}
}
public void delete(int id)
{
using (var ctx = new MyContext())
{
var curso = ctx.Cursos.SingleOrDefault(c => c.Id == id);
ctx.Cursos.Remove(curso);
ctx.SaveChanges();
}
}
public Curso get(int id)
{
using (var ctx = new MyContext())
{
var curso = ctx.Cursos.SingleOrDefault(c => c.Id == id);
return curso;
}
}
public void edit(Curso curso)
{
using (var ctx = new MyContext())
{
var curso_update = ctx.Cursos.SingleOrDefault(c => c.Id == curso.Id);
curso_update.Nombre = curso.Nombre;
curso_update.Descripcion = curso.Descripcion;
ctx.SaveChanges();
}
}
public List<Curso> getCursosEnFacultad(int idFacu)
{
using (var ctx = new MyContext())
{
var cursos = ctx.Cursos.Where(c => c.Facultad.Id == idFacu).ToList<Curso>();
return cursos;
}
}
}
}
\ No newline at end of file
using dal;
using System;
using System.Collections.Generic;
using System.Linq;
namespace bl
{
public class FacultadManager
{
public List<Facultad> lists()
{
using (var ctx = new MyContext())
{
var facultades = ctx.Facultades.ToList();
return facultades;
}
}
public void add(Facultad facultad)
{
using (var ctx = new MyContext())
{
ctx.Facultades.Add(facultad);
ctx.SaveChanges();
}
}
public void delete(int id)
{
using (var ctx = new MyContext())
{
var facultad = ctx.Facultades.SingleOrDefault(f => f.Id == id);
ctx.Facultades.Remove(facultad);
ctx.SaveChanges();
}
}
public Facultad get(int id)
{
using (var ctx = new MyContext())
{
var facultad = ctx.Facultades.SingleOrDefault(f => f.Id == id);
return facultad;
}
}
public void edit(Facultad facultad)
{
using (var ctx = new MyContext())
{
var facultad_update = ctx.Facultades.SingleOrDefault(f => f.Id == facultad.Id);
facultad_update.Nombre = facultad.Nombre;
facultad_update.Abreviatura = facultad.Abreviatura;
ctx.SaveChanges();
}
}
public void agregarCurso(int IdFacu, int idCurso)
{
using (var ctx = new MyContext())
{
var facultad_update = ctx.Facultades.SingleOrDefault(f => f.Id == IdFacu);
var curso = ctx.Cursos.SingleOrDefault(c => c.Id == idCurso);
//estos dos controles no deberian ejecutarse xq deberia controlar que exista en el frontend
if (facultad_update.Cursos == null || !facultad_update.Cursos.Any())
{
facultad_update.Cursos = new List<Curso>();
}
if (curso == null)
{
curso = new Curso();
}
facultad_update.Cursos.Add(curso);
ctx.SaveChanges();
}
}
public void agregarEstudiante(int IdFacu, int idUsuario)
{
using (var ctx = new MyContext())
{
var facultad_update = ctx.Facultades.SingleOrDefault(f => f.Id == IdFacu);
var usuario = ctx.Usuarios.SingleOrDefault(c => c.Id == idUsuario);
//estos dos controles no deberian ejecutarse xq deberia controlar que exista en el frontend
if (facultad_update.Usuarios == null || !facultad_update.Usuarios.Any())
{
facultad_update.Usuarios = new List<Usuario>();
}
if (usuario == null)
{
usuario = new Usuario();
}
facultad_update.Usuarios.Add(usuario);
ctx.SaveChanges();
}
}
}
}
\ No newline at end of file
using dal;
using System;
using System.Collections.Generic;
using System.Linq;
namespace bl
{
public class UsuarioManager
{
public List<Usuario> lists()
{
using (var ctx = new MyContext())
{
var usuarios = ctx.Usuarios.ToList();
return usuarios;
}
}
public void add(Usuario usu)
{
using (var ctx = new MyContext())
{
ctx.Usuarios.Add(usu);
ctx.SaveChanges();
}
}
public void delete(int id)
{
using (var ctx = new MyContext())
{
var usu = ctx.Usuarios.SingleOrDefault(u => u.Id == id); // SELECT * FROM Usuario WHERE Id = @ID
ctx.Usuarios.Remove(usu); //DELETE .. WHERE Id =
ctx.SaveChanges();
}
}
public Usuario get(int id)
{
using (var ctx = new MyContext())
{
var usu = ctx.Usuarios.SingleOrDefault(u => u.Id == id);
return usu;
}
}
public void edit(Usuario usu)
{
using (var ctx = new MyContext())
{
var usu_update = ctx.Usuarios.SingleOrDefault(u => u.Id == usu.Id);
usu_update.Nombre = usu.Nombre;
usu_update.Apellido = usu.Apellido;
usu_update.Correo = usu.Correo;
usu_update.Telefono = usu.Telefono;
usu_update.Rol = usu.Rol;
ctx.SaveChanges();
}
}
public List<Usuario> getUsuariosEnFacultad(int idFacu)
{
using (var ctx = new MyContext())
{
var usus = ctx.Usuarios.Where(u => u.Facultad.Id == idFacu).ToList<Usuario>();
return usus;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\dal\dal.csproj" />
</ItemGroup>
</Project>
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("bl")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("bl")]
[assembly: System.Reflection.AssemblyTitleAttribute("bl")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.
18fec410648a1c6b4030000dbe917409533f8ad6
D:\TSI .NET\udelaronline\udelaronline\bl\bin\Debug\netcoreapp3.1\bl.deps.json
D:\TSI .NET\udelaronline\udelaronline\bl\bin\Debug\netcoreapp3.1\bl.dll
D:\TSI .NET\udelaronline\udelaronline\bl\bin\Debug\netcoreapp3.1\bl.pdb
D:\TSI .NET\udelaronline\udelaronline\bl\bin\Debug\netcoreapp3.1\dal.dll
D:\TSI .NET\udelaronline\udelaronline\bl\bin\Debug\netcoreapp3.1\dal.pdb
D:\TSI .NET\udelaronline\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.csprojAssemblyReference.cache
D:\TSI .NET\udelaronline\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.AssemblyInfoInputs.cache
D:\TSI .NET\udelaronline\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.AssemblyInfo.cs
D:\TSI .NET\udelaronline\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.csproj.CoreCompileInputs.cache
D:\TSI .NET\udelaronline\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.csproj.CopyComplete
D:\TSI .NET\udelaronline\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.dll
D:\TSI .NET\udelaronline\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.pdb
D:\TSI .NET\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.dll
D:\TSI .NET\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.pdb
D:\TSI .NET\udelaronline\bl\bin\Debug\netcoreapp3.1\bl.deps.json
D:\TSI .NET\udelaronline\bl\bin\Debug\netcoreapp3.1\bl.dll
D:\TSI .NET\udelaronline\bl\bin\Debug\netcoreapp3.1\bl.pdb
D:\TSI .NET\udelaronline\bl\bin\Debug\netcoreapp3.1\dal.dll
D:\TSI .NET\udelaronline\bl\bin\Debug\netcoreapp3.1\dal.pdb
D:\TSI .NET\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.csprojAssemblyReference.cache
D:\TSI .NET\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.AssemblyInfoInputs.cache
D:\TSI .NET\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.AssemblyInfo.cs
D:\TSI .NET\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.csproj.CoreCompileInputs.cache
D:\TSI .NET\udelaronline\bl\obj\Debug\netcoreapp3.1\bl.csproj.CopyComplete
{
"format": 1,
"restore": {
"C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\bl\\bl.csproj": {}
},
"projects": {
"C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\bl\\bl.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\bl\\bl.csproj",
"projectName": "bl",
"projectPath": "C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\bl\\bl.csproj",
"packagesPath": "C:\\Users\\facun\\.nuget\\packages\\",
"outputPath": "C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\bl\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Microsoft\\Xamarin\\NuGet\\"
],
"configFilePaths": [
"C:\\Users\\facun\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {
"C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\dal\\dal.csproj": {
"projectPath": "C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\dal\\dal.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.402\\RuntimeIdentifierGraph.json"
}
}
},
"C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\dal\\dal.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\dal\\dal.csproj",
"projectName": "dal",
"projectPath": "C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\dal\\dal.csproj",
"packagesPath": "C:\\Users\\facun\\.nuget\\packages\\",
"outputPath": "C:\\Users\\facun\\source\\repos\\udelaronlineindividual\\dal\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Microsoft\\Xamarin\\NuGet\\"
],
"configFilePaths": [
"C:\\Users\\facun\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"dependencies": {
"Microsoft.EntityFrameworkCore": {
"target": "Package",
"version": "[3.1.8, )"
},
"Microsoft.EntityFrameworkCore.Design": {
"include": "Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive",
"suppressParent": "All",
"target": "Package",
"version": "[3.1.8, )"
},
"Microsoft.EntityFrameworkCore.SqlServer": {
"target": "Package",
"version": "[3.1.8, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.402\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment