Advertisement
ingomarmurcia

ServiceGrupo.cs

May 16th, 2020
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.96 KB | None | 0 0
  1. using ADSProjectLab.DAL;
  2. using ADSProjectLab.Models;
  3. using ADSProjectLab.Models.Context;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8.  
  9. namespace ADSProjectLab.Services
  10. {
  11.     public class ServiceGrupos
  12.     {
  13.  
  14.         // Se obtienen todos los Grupos
  15.         public List<Grupo> ObtenerTodos()
  16.         {
  17.             try
  18.             {
  19.                 using (MyDbContext context = new MyDbContext())
  20.                 {
  21.                     GrupoDAL dal = new GrupoDAL(context);
  22.                     return dal.ObtenerTodos();
  23.                 }
  24.             }
  25.             catch (Exception ex)
  26.             {
  27.                 throw;
  28.             }
  29.         }
  30.  
  31.         // Se obtienen todos los Grupos
  32.         public List<Grupo> ObtenerTodos(string[] includes)
  33.         {
  34.             try
  35.             {
  36.                 using (MyDbContext context = new MyDbContext())
  37.                 {
  38.                     GrupoDAL dal = new GrupoDAL(context);
  39.                     return dal.ObtenerTodos(includes);
  40.                 }
  41.             } catch(Exception ex)
  42.             {
  43.                 throw;
  44.             }
  45.         }
  46.  
  47.         // Se busca el Grupo por el Id
  48.         public Grupo ObtenerById(int Id, string[] includes)
  49.         {
  50.             try
  51.             {
  52.                 using (MyDbContext context = new MyDbContext())
  53.                 {
  54.                     GrupoDAL dal = new GrupoDAL(context);
  55.                     return dal.ObtenerById(Id, includes);
  56.                 }
  57.             }
  58.             catch (Exception ex)
  59.             {
  60.                 throw;
  61.             }
  62.         }
  63.  
  64.         // Se inserta un Grupo
  65.         public int Insertar(Grupo model)
  66.         {
  67.             try
  68.             {
  69.                 using (MyDbContext context = new MyDbContext())
  70.                 {
  71.                     GrupoDAL dal = new GrupoDAL(context);
  72.                     return dal.Insertar(model);
  73.                 }
  74.             }
  75.             catch (Exception ex)
  76.             {
  77.                 throw;
  78.             }
  79.         }
  80.  
  81.         // Se modifica un Grupo
  82.         public int Modificar(int Id, Grupo model)
  83.         {
  84.             try
  85.             {
  86.                 using (MyDbContext context = new MyDbContext())
  87.                 {
  88.                     GrupoDAL dal = new GrupoDAL(context);
  89.                     return dal.Modificar(Id, model);
  90.                 }
  91.             }
  92.             catch (Exception ex)
  93.             {
  94.                 throw;
  95.             }
  96.         }
  97.  
  98.         // Se elimina un Grupo
  99.         public bool Eliminar(int Id)
  100.         {
  101.             try
  102.             {
  103.                 using (MyDbContext context = new MyDbContext())
  104.                 {
  105.                     GrupoDAL dal = new GrupoDAL(context);
  106.                     return dal.Eliminar(Id);
  107.                 }
  108.                    
  109.             }
  110.             catch (Exception ex)
  111.             {
  112.                 throw;
  113.             }
  114.         }
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement