Beispiel #1
0
        public void Delete(int Id)
        {
            Init();
            try
            {
                using (LQCEEntities context = new LQCEEntities())
                {
                    RepositorioPRESTACION_VETERINARIA repositorio             = new RepositorioPRESTACION_VETERINARIA(context);
                    PRESTACION_VETERINARIA            _PRESTACION_VETERINARIA = repositorio.GetById(Id);

                    if (Equals(_PRESTACION_VETERINARIA, null))
                    {
                        throw new Exception(String.Concat("No se ha encontrado PRESTACION_VETERINARIA con Id =", Id.ToString()));
                    }

                    _PRESTACION_VETERINARIA.ACTIVO = false;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ISException.RegisterExcepcion(ex);
                Error = ex.Message;
                throw ex;
            }
        }
Beispiel #2
0
 public PRESTACION_VETERINARIA GetByIdWithReferences(int ID)
 {
     Init();
     try
     {
         using (LQCEEntities context = new LQCEEntities())
         {
             RepositorioPRESTACION_VETERINARIA repositorio = new RepositorioPRESTACION_VETERINARIA(context);
             return(repositorio.GetByIdWithReferences(ID));
         }
     }
     catch (Exception ex)
     {
         ISException.RegisterExcepcion(ex);
         Error = ex.Message;
         throw ex;
     }
 }
Beispiel #3
0
 public List <PRESTACION_VETERINARIA> GetAllWithReferences()
 {
     Init();
     try
     {
         using (LQCEEntities context = new LQCEEntities())
         {
             RepositorioPRESTACION_VETERINARIA repositorio = new RepositorioPRESTACION_VETERINARIA(context);
             return(repositorio.GetAllWithReferences().OrderBy(i => i.NOMBRE).ToList());
         }
     }
     catch (Exception ex)
     {
         ISException.RegisterExcepcion(ex);
         Error = ex.Message;
         throw ex;
     }
 }
Beispiel #4
0
 public List <PRESTACION_VETERINARIA> GetByFilterWithReferences(int?ESPECIEId = null, int?RAZAId = null, string NOMBRE = "", string EDAD = "", string TELEFONO = "", string SEXO = "", string SOLICITANTE = "", string PROCEDENCIA = "", int?FICHA_CLINICA = null)
 {
     Init();
     try
     {
         using (LQCEEntities context = new LQCEEntities())
         {
             RepositorioPRESTACION_VETERINARIA repositorio = new RepositorioPRESTACION_VETERINARIA(context);
             return(repositorio.GetByFilterWithReferences(ESPECIEId, RAZAId, NOMBRE, EDAD, TELEFONO, SEXO, SOLICITANTE, PROCEDENCIA, FICHA_CLINICA).OrderBy(i => i.ID).ToList());
         }
     }
     catch (Exception ex)
     {
         ISException.RegisterExcepcion(ex);
         Error = ex.Message;
         throw ex;
     }
 }
Beispiel #5
0
        public void Update(int Id, int ESPECIEId, int RAZAId, string NOMBRE, string EDAD = "", string TELEFONO = "", string SEXO = "", string SOLICITANTE = "", string PROCEDENCIA = "", int?FICHA_CLINICA = null)
        {
            Init();
            try
            {
                using (LQCEEntities context = new LQCEEntities())
                {
                    RepositorioPRESTACION_VETERINARIA repositorio             = new RepositorioPRESTACION_VETERINARIA(context);
                    PRESTACION_VETERINARIA            _PRESTACION_VETERINARIA = repositorio.GetById(Id);
                    if (Equals(_PRESTACION_VETERINARIA, null))
                    {
                        throw new Exception(String.Concat("No se ha encontrado PRESTACION_VETERINARIA con Id =", Id.ToString()));
                    }

                    RepositorioESPECIE _repositorioESPECIE = new RepositorioESPECIE(context);
                    ESPECIE            _objESPECIE         = _repositorioESPECIE.GetById(ESPECIEId);
                    if (Equals(_objESPECIE, null))
                    {
                        throw new Exception(String.Concat("No se ha encontrado ESPECIE con Id =", ESPECIEId.ToString()));
                    }

                    RepositorioRAZA _repositorioRAZA = new RepositorioRAZA(context);
                    RAZA            _objRAZA         = _repositorioRAZA.GetById(RAZAId);
                    if (Equals(_objRAZA, null))
                    {
                        throw new Exception(String.Concat("No se ha encontrado RAZA con Id =", RAZAId.ToString()));
                    }

                    //properties

                    if (!string.IsNullOrEmpty(NOMBRE))
                    {
                        _PRESTACION_VETERINARIA.NOMBRE = NOMBRE;
                    }
                    if (!string.IsNullOrEmpty(EDAD))
                    {
                        _PRESTACION_VETERINARIA.EDAD = EDAD;
                    }
                    if (!string.IsNullOrEmpty(TELEFONO))
                    {
                        _PRESTACION_VETERINARIA.TELEFONO = TELEFONO;
                    }
                    if (!string.IsNullOrEmpty(SEXO))
                    {
                        _PRESTACION_VETERINARIA.SEXO = SEXO;
                    }
                    if (!string.IsNullOrEmpty(SOLICITANTE))
                    {
                        _PRESTACION_VETERINARIA.SOLICITANTE = SOLICITANTE;
                    }
                    if (!string.IsNullOrEmpty(PROCEDENCIA))
                    {
                        _PRESTACION_VETERINARIA.PROCEDENCIA = PROCEDENCIA;
                    }
                    if (FICHA_CLINICA.HasValue)
                    {
                        _PRESTACION_VETERINARIA.FICHA_CLINICA = FICHA_CLINICA.Value;
                    }

                    //parents

                    _PRESTACION_VETERINARIA.ESPECIE = _objESPECIE;
                    _PRESTACION_VETERINARIA.RAZA    = _objRAZA;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ISException.RegisterExcepcion(ex);
                Error = ex.Message;
                throw ex;
            }
        }