Пример #1
0
        public List <MateriaBE> GetAll(int state, int page, int pageSize, string orderBy, string ascending, ref int count)
        {
            try
            {
                Expression <Func <DataModel.materias, Boolean> > predicate = x => x.estado == state;
                IQueryable <DataModel.materias> entity = _puente.MateriaRepository.GetAllByFilters(predicate, new string[] { "cursos" });
                count = entity.Count();
                var skipAmount = 0;

                if (page > 0)
                {
                    skipAmount = pageSize * (page - 1);
                }

                entity = entity
                         .OrderByPropertyOrField(orderBy, ascending)
                         .Skip(skipAmount)
                         .Take(pageSize);

                List <MateriaBE> BE = new List <MateriaBE>();
                foreach (var item in entity)
                {
                    BE.Add(Factory.FactoryMateria.GetInstance().CreateBusiness(item));
                }
                return(BE);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #2
0
        public bool Update(long Id, PlanBE Be)
        {
            try
            {
                var flag = false;

                if (Be != null)
                {
                    var entity = Factory.FactoryPlan.GetInstance().CreateEntity(Be);

                    _puente.Planrepository.Update(entity, new List <string>()
                    {
                        "desc_plan"
                    });
                    _puente.Commit();

                    flag = true;
                    return(flag);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo Modificar el plan", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #3
0
        public List <Alumnos_InscripcionBE> GetAll(int state, int page, int pageSize, string orderBy, string ascending, ref int count, int idalumno, Int32 id_curso)
        {
            try
            {
                Expression <Func <DataModel.alumnos_inscripciones, Boolean> > predicate = x => x.estado == state &&
                                                                                          ((x.id_alumno == idalumno) || (idalumno == 0)) &&
                                                                                          ((x.id_curso == id_curso) || (id_curso == 0)) &&
                                                                                          ((x.id_alumno == idalumno && x.id_curso == id_curso) || (idalumno == 0 || id_curso == 0));
                IQueryable <DataModel.alumnos_inscripciones> entity = _unitOfWork.Alumnos_InscripcionesRepository.GetAllByFilters(predicate, new string[] { "cursos", "personas" });
                count = entity.Count();
                var skipAmount = 0;

                if (page > 0)
                {
                    skipAmount = pageSize * (page - 1);
                }

                entity = entity
                         .OrderByPropertyOrField(orderBy, ascending)
                         .Skip(skipAmount)
                         .Take(pageSize);

                List <Alumnos_InscripcionBE> be = new List <Alumnos_InscripcionBE>();
                foreach (var item in entity)
                {
                    be.Add(Factory.FactoryAlumnos_Inscripcion.GetInstance().CreateBusiness(item));
                }
                return(be);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #4
0
        public bool Delete(long Id)
        {
            var flag = false;

            try
            {
                var especialidad = _unitofWork.EspecialidadRepository.GetById(Id);
                if (especialidad == null)
                {
                    throw new ApiBusinessException(1012, "No se pudo Dar de baja a esa especialidad", System.Net.HttpStatusCode.NotFound, "Http");
                }

                especialidad.estado = (Int32)StateEnum.Baja;
                _unitofWork.EspecialidadRepository.Delete(especialidad, new List <string>()
                {
                    "estado"
                });
                _unitofWork.Commit();

                flag = true;
                return(flag);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #5
0
        public List <EspecialidadBE> GetAll(int estado, int page, int pageSize, string orderBy, string ascending, ref int count)
        {
            try
            {
                Expression <Func <DataModel.especialidades, Boolean> > predicate = x => x.estado == estado && x.desc_especialidad != "none";
                IQueryable <DataModel.especialidades> especialidadentity         = _unitofWork.EspecialidadRepository.GetAllByFilters(predicate, new String[] { "planes" });

                count = especialidadentity.Count();
                var skipAmount = 0;

                if (page > 0)
                {
                    skipAmount = pageSize * (page - 1);
                }

                especialidadentity = especialidadentity
                                     .OrderByPropertyOrField(orderBy, ascending)
                                     .Skip(skipAmount)
                                     .Take(pageSize);

                List <EspecialidadBE> especialidad = new List <EspecialidadBE>();
                foreach (var item in especialidadentity)
                {
                    especialidad.Add(Factory.FactoryEspecialidad.CreateBusiness(item));
                }
                return(especialidad);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #6
0
        public bool Update(long Id, EspecialidadBE Be)
        {
            try
            {
                var flag = false;

                if (Be != null)
                {
                    var especialidadentity = Factory.FactoryEspecialidad.CreateEntity(Be);
                    _unitofWork.EspecialidadRepository.Update(especialidadentity, new List <string>()
                    {
                        "desc_especialidad"
                    });
                    _unitofWork.Commit();

                    flag = true;
                    return(flag);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo Modificar a esa especialidad", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #7
0
        public bool Delete(long Id)
        {
            var flag = false;

            try
            {
                Expression <Func <DataModel.materias, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_materia == Id;
                var entity = _puente.MateriaRepository.GetOneByFilters(predicate, new string[] { "cursos" });
                if (entity == null)
                {
                    throw new ApiBusinessException(1012, "No se pudo Dar de baja a ese materia", System.Net.HttpStatusCode.NotFound, "Http");
                }

                entity.estado = (Int32)StateEnum.Baja;
                _puente.MateriaRepository.Delete(entity, new List <string>()
                {
                    "estado"
                });
                _puente.Commit();

                flag = true;
                return(flag);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #8
0
        public bool Update(long Id, Alumnos_InscripcionBE Be)
        {
            try
            {
                var flag = false;

                if (Be != null)
                {
                    var entity = Factory.FactoryAlumnos_Inscripcion.GetInstance().CreateEntity(Be);

                    _unitOfWork.Alumnos_InscripcionesRepository.Update(entity, new List <string>()
                    {
                        "id_alumno", "id_curso", "condicion", "nota"
                    });
                    _unitOfWork.Commit();

                    flag = true;
                    return(flag);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo Modificar el modulo", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #9
0
        public bool Update(long Id, ModuloBE Be)
        {
            try
            {
                var flag = false;

                if (Be != null)
                {
                    var entity = Factory.FactoryModulo.GetInstance().CreateEntity(Be);

                    entity.modulos_usuarios = null;
                    _unitOfWork.ModuloRepository.Update(entity, new List <string>()
                    {
                        "desc_modulo", "ejecuta"
                    });
                    _unitOfWork.Commit();

                    flag = true;
                    return(flag);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo Modificar el modulo", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #10
0
        public bool Delete(Int32 Id)
        {
            var flag = false;

            try
            {
                Expression <Func <DataModel.planes, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_plan == Id;
                var plan = _puente.Planrepository.GetOneByFilters(predicate, null /*new string[] { "Planespecialidad" }*/);
                if (plan == null)
                {
                    throw new ApiBusinessException(1012, "No se pudo Dar de baja a ese plan", System.Net.HttpStatusCode.NotFound, "Http");
                }

                plan.estado = (Int32)StateEnum.Baja;
                _puente.Planrepository.Delete(plan, new List <string>()
                {
                    "estado"
                });
                _puente.Commit();

                flag = true;
                return(flag);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #11
0
        public List <PlanBE> GetAll(int state, int page, int pageSize, string orderBy, string ascending, ref int count)
        {
            try
            {
                Expression <Func <DataModel.planes, Boolean> > predicate = x => x.estado == state && x.desc_plan != "none";
                IQueryable <DataModel.planes> entity = _puente.Planrepository.GetAllByFilters(predicate, new string[] { "especialidades" });
                count = entity.Count();
                var skipAmount = 0;

                if (page > 0)
                {
                    skipAmount = pageSize * (page - 1);
                }

                entity = entity
                         .OrderByPropertyOrField(orderBy, ascending)
                         .Skip(skipAmount)
                         .Take(pageSize);

                List <PlanBE> plan = new List <PlanBE>();
                foreach (var item in entity)
                {
                    plan.Add(Factory.FactoryPlan.GetInstance().CreateBusiness(item));
                }
                return(plan);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #12
0
        public bool Delete(int Id)
        {
            var flag = false;

            try
            {
                Expression <Func <DataModel.alumnos_inscripciones, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_inscripcion == Id;
                var entity = _unitOfWork.Alumnos_InscripcionesRepository.GetOneByFilters(predicate, null);
                if (entity == null)
                {
                    throw new ApiBusinessException(1012, "No se pudo Dar de baja a la inscripcion", System.Net.HttpStatusCode.NotFound, "Http");
                }

                entity.estado = (Int32)StateEnum.Baja;
                _unitOfWork.Alumnos_InscripcionesRepository.Delete(entity, new List <string>()
                {
                    "estado"
                });
                _unitOfWork.Commit();

                flag = true;
                return(flag);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #13
0
        public bool ChangePassword(long Id, UsuarioBE Be)
        {
            try
            {
                var flag = false;

                if (Be != null)
                {
                    var usr = Factory.FactoryUsuario.GetInstance().CreateEntity(Be);
                    _unitOfWork.UsuarioRepository.Update(usr, new List <string>()
                    {
                        "clave", "cambia_clave"
                    });
                    _unitOfWork.Commit();

                    flag = true;
                    return(flag);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo Modificar la contraseña", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #14
0
        public List <PersonaBE> GetAll(int state, int page, int idconectado, int pageSize, string orderBy, string ascending, ref int count, Int32 tipo_persona)
        {
            try
            {
                Expression <Func <DataModel.personas, Boolean> > predicate = x => (x.estado == state || state == 0) && (x.id_persona == idconectado || idconectado == 0) && (x.tipo_persona == tipo_persona || tipo_persona == 0);
                IQueryable <DataModel.personas> entity = _unitOfWork.PersonaRepository.GetAllByFilters(predicate, new string[] { "usuarios.modulos_usuarios" });
                count = entity.Count();
                var skipAmount = 0;

                if (page > 0)
                {
                    skipAmount = pageSize * (page - 1);
                }

                entity = entity
                         .OrderByPropertyOrField(orderBy, ascending)
                         .Skip(skipAmount)
                         .Take(pageSize);

                List <PersonaBE> be = new List <PersonaBE>();
                foreach (var item in entity)
                {
                    be.Add(Factory.FactoryPersona.GetInstance().CreateBusiness(item));
                }
                return(be);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #15
0
        public PlanBE GetById(long Id)
        {
            try
            {
                if (Id == 0)
                {
                    throw new ApiBusinessException(1012, "No se encuentra disponible el plan.", System.Net.HttpStatusCode.NotFound, "Http");
                }

                Expression <Func <DataModel.planes, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_plan == Id;
                var entity = _puente.Planrepository.GetOneByFilters(predicate, new string[] { "especialidades" });
                if (entity != null)
                {
                    return(Factory.FactoryPlan.GetInstance().CreateBusiness(entity));
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se encuentra disponible el plan.", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #16
0
        public bool Update(long Id, PersonaBE Be)
        {
            try
            {
                var flag = false;

                if (Be != null)
                {
                    if (TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 1 || TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 2)
                    {
                        Be.id_plan = 20;
                    }
                    var entity = Factory.FactoryPersona.GetInstance().CreateEntity(Be);
                    if (entity.usuarios != null)
                    {
                        foreach (var item in entity.usuarios)
                        {
                            if (item.modulos_usuarios != null)
                            {
                                foreach (var mod in item.modulos_usuarios)
                                {
                                    _unitOfWork.Modulo_Usuario_repository.Update(mod, new List <string>()
                                    {
                                        "id_modulo", "id_usuario", "alta", "baja", "modificacion", "consulta"
                                    });
                                }
                            }
                            item.modulos_usuarios = null;
                            //_unitOfWork.UsuarioRepository.Update(item, new List<string>() { "nombre_usuario", "clave","habilitado","email","cambia_clave" });
                        }
                    }
                    entity.usuarios = null;
                    _unitOfWork.PersonaRepository.Update(entity, new List <string>()
                    {
                        "id_plan", "nombre", "apellido", "direccion", "telefono", "fecha_nac", "legajo", "tipo_persona"
                    });
                    _unitOfWork.Commit();

                    flag = true;
                    return(flag);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo Modificar por que la entidad no esta completa", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #17
0
        public List <CursoBE> GetAll(int state, int page, int pageSize, string orderBy, string ascending, Int32 tipo, int idconectado, bool iscripcion, ref int count)
        {
            try
            {
                Expression <Func <DataModel.cursos, Boolean> > predicate = x => x.estado == state;
                IQueryable <DataModel.cursos> entity = _unitOfWork.CursoRepository.GetAllByFilters(predicate, new string[] { "comisiones", "docentes_cursos", "alumnos_inscripciones", "materias" });
                count = entity.Count();
                var skipAmount = 0;

                if (page > 0)
                {
                    skipAmount = pageSize * (page - 1);
                }

                entity = entity
                         .OrderByPropertyOrField(orderBy, ascending)
                         .Skip(skipAmount)
                         .Take(pageSize);

                List <CursoBE> be        = new List <CursoBE>();
                List <CursoBE> Finallist = new List <CursoBE>();

                foreach (var item in entity)
                {
                    be.Add(Factory.FactoryCurso.GetInstance().CreateBusiness(item));
                }


                if (iscripcion)
                {
                    if (tipo == Convert.ToInt32(RolPersonEnum.Administrador))
                    {
                        Finallist = Administrador(be);
                    }
                    else if (tipo == Convert.ToInt32(RolPersonEnum.Alumno))
                    {
                        Finallist = Alumno(be, idconectado);
                    }
                    return(Finallist);
                }
                else
                {
                    return(be);
                }
            }

            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #18
0
 public async Task <IHttpActionResult> DeleteComision(int id)
 {
     try
     {
         this._services.Delete(id);
         return(Ok());
     }
     catch (Exception ex)
     {
         var except = (ApiBusinessException)HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
         var resp   = BadRequest(Convert.ToString(except.ErrorDescription));
         return(resp);
     }
 }
Пример #19
0
        public bool Delete(int Id)
        {
            var flag = false;

            try
            {
                Expression <Func <DataModel.personas, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_persona == Id;
                var entity = _unitOfWork.PersonaRepository.GetOneByFilters(predicate, new string[] { "usuarios.modulos_usuarios" });
                if (entity == null)
                {
                    throw new ApiBusinessException(1012, "No se pudo Dar de baja a ese persona", System.Net.HttpStatusCode.NotFound, "Http");
                }
                if (entity.usuarios != null)
                {
                    foreach (var item in entity.usuarios)
                    {
                        foreach (var modusuario in item.modulos_usuarios)
                        {
                            modusuario.estado = (Int32)StateEnum.Baja;
                            _unitOfWork.Modulo_Usuario_repository.Delete(modusuario, new List <string>()
                            {
                                "estado"
                            });
                        }
                        item.estado = (Int32)StateEnum.Baja;
                        _unitOfWork.UsuarioRepository.Delete(item, new List <string>()
                        {
                            "estado"
                        });
                    }
                }
                entity.estado = (Int32)StateEnum.Baja;
                _unitOfWork.PersonaRepository.Delete(entity, new List <string>()
                {
                    "estado"
                });
                _unitOfWork.Commit();

                flag = true;
                return(flag);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #20
0
 public async Task <IHttpActionResult> PostComision(ComisionBE comision)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         _services.Create(comision);
         return(Created(new Uri(Url.Link("DefaultApi", new { Id = comision })), comision));
     }
     catch (Exception ex)
     {
         var except = (ApiBusinessException)HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
         var resp   = BadRequest(Convert.ToString(except.ErrorDescription));
         return(resp);
     }
 }
Пример #21
0
        public long Create(PersonaBE Be)
        {
            try
            {
                if (Be != null)
                {
                    Be.legajo = GetLastLegajo();
                    Be.Usuarios[0].nombre_usuario = GetLastLegajo().ToString();
                    if (TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 1 || TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 2)
                    {
                        Be.id_plan = 20;
                    }

                    DataModel.personas entity = Factory.FactoryPersona.GetInstance().CreateEntity(Be);

                    Expression <Func <DataModel.personas, Boolean> > predicate = x => (x.telefono == entity.telefono);
                    DataModel.personas verify = _unitOfWork.PersonaRepository.GetOneByFilters(predicate, new string[] { "usuarios.modulos_usuarios" });
                    if (verify != null)
                    {
                        throw new ApiBusinessException(1012, "Ya existe un usuario con ese numero de telefono", System.Net.HttpStatusCode.Forbidden, "Http");
                    }

                    var email = entity.usuarios.FirstOrDefault().email.ToString();
                    Expression <Func <DataModel.usuarios, Boolean> > predicateuser = x => (x.email == email);
                    DataModel.usuarios usur = _unitOfWork.UsuarioRepository.GetOneByFilters(predicateuser, new string[] { "modulos_usuarios" });
                    if (usur != null)
                    {
                        throw new ApiBusinessException(1012, "Ya existe un usuario con ese email", System.Net.HttpStatusCode.Forbidden, "Http");
                    }

                    _unitOfWork.PersonaRepository.Insert(entity);
                    _unitOfWork.Commit();
                    return(entity.id_persona);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo crear el plan", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #22
0
 public async Task <IHttpActionResult> PutComision(Int32 id, ComisionBE comision)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         comision.id_comision = id;
         _services.Update(id, comision);
         return(Ok());
     }
     catch (Exception ex)
     {
         var except = (ApiBusinessException)HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
         var resp   = BadRequest(Convert.ToString(except.ErrorDescription));
         return(resp);
     }
 }
Пример #23
0
        public List <PersonaBE> Login(string usermane, string password)
        {
            try
            {
                var encrypt = SolveApi.Encriptacion.Encriptacion.GetInstance().EncryptKey(password);
                Expression <Func <DataModel.personas, Boolean> > predicate = x => x.usuarios.FirstOrDefault().estado == (Int32)StateEnum.Alta && x.usuarios.FirstOrDefault().nombre_usuario == usermane && x.usuarios.FirstOrDefault().clave == encrypt;
                IQueryable <DataModel.personas> entity = _unitOfWork.PersonaRepository.GetAllByFilters(predicate, new string[] { "usuarios.modulos_usuarios" });
                List <PersonaBE> be = new List <PersonaBE>();

                foreach (var item in entity)
                {
                    be.Add(Factory.FactoryPersona.GetInstance().CreateBusiness(item));
                }
                return(be);
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }
Пример #24
0
 public PersonaBE GetById(int Id)
 {
     try
     {
         Expression <Func <DataModel.personas, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_persona == Id;
         var entity = _unitOfWork.PersonaRepository.GetOneByFilters(predicate, new string[] { "usuarios.modulos_usuarios" });
         if (entity != null)
         {
             return(Factory.FactoryPersona.GetInstance().CreateBusiness(entity));
         }
         else
         {
             throw new ApiBusinessException(1012, "No se encuentra disponible a esa persona", System.Net.HttpStatusCode.NotFound, "Http");
         }
     }
     catch (Exception ex)
     {
         throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
     }
 }
Пример #25
0
 public Alumnos_InscripcionBE GetById(int Id)
 {
     try
     {
         Expression <Func <DataModel.alumnos_inscripciones, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_inscripcion == Id;
         var entity = _unitOfWork.Alumnos_InscripcionesRepository.GetOneByFilters(predicate, null);
         if (entity != null)
         {
             return(Factory.FactoryAlumnos_Inscripcion.GetInstance().CreateBusiness(entity));
         }
         else
         {
             throw new ApiBusinessException(1012, "No se encuentra disponible es materia para inscribir", System.Net.HttpStatusCode.NotFound, "Http");
         }
     }
     catch (Exception ex)
     {
         throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
     }
 }
Пример #26
0
 public EspecialidadBE GetById(long Id)
 {
     try
     {
         Expression <Func <DataModel.especialidades, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_especialidad == Id;
         var especialidadentity = _unitofWork.EspecialidadRepository.GetOneByFilters(predicate, null);
         if (especialidadentity != null)
         {
             return(Factory.FactoryEspecialidad.CreateBusiness(especialidadentity));
         }
         else
         {
             throw new ApiBusinessException(1012, "No se encuentra disponible esa especialidad", System.Net.HttpStatusCode.NotFound, "Http");
         }
     }
     catch (Exception ex)
     {
         throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
     }
 }
Пример #27
0
 public MateriaBE GetById(long Id)
 {
     try
     {
         Expression <Func <DataModel.materias, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_materia == Id;
         var entity = _puente.MateriaRepository.GetOneByFilters(predicate, new string[] { "cursos" });
         if (entity != null)
         {
             return(Factory.FactoryMateria.GetInstance().CreateBusiness(entity));
         }
         else
         {
             throw new ApiBusinessException(1012, "No se encuentra disponible esa materia", System.Net.HttpStatusCode.NotFound, "Http");
         }
     }
     catch (Exception ex)
     {
         throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
     }
 }
Пример #28
0
 public CursoBE GetById(long Id)
 {
     try
     {
         Expression <Func <DataModel.cursos, Boolean> > predicate = x => x.estado == (Int32)StateEnum.Alta && x.id_curso == Id;
         var entity = _unitOfWork.CursoRepository.GetOneByFilters(predicate, new string[] { "comisiones", "docentes_cursos", "alumnos_inscripciones", "materias" });
         if (entity != null)
         {
             return(Factory.FactoryCurso.GetInstance().CreateBusiness(entity));
         }
         else
         {
             throw new ApiBusinessException(1012, "No se encuentra disponible ese curso", System.Net.HttpStatusCode.NotFound, "Http");
         }
     }
     catch (Exception ex)
     {
         throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
     }
 }
Пример #29
0
 public async Task <IHttpActionResult> PutPersona(Int32 id, PersonaBE be)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         be.id_persona = id;
         string username = User.Identity.Name;
         _services.Update(id, be);
         return(Ok());
     }
     catch (Exception ex)
     {
         var except = (ApiBusinessException)HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
         var resp   = BadRequest(Convert.ToString(except.ErrorDescription));
         return(resp);
     }
 }
Пример #30
0
        public long Create(PlanBE Be)
        {
            try
            {
                if (Be != null)
                {
                    DataModel.planes entity = Factory.FactoryPlan.GetInstance().CreateEntity(Be);
                    _puente.Planrepository.Insert(entity);
                    _puente.Commit();

                    return(entity.id_plan);
                }
                else
                {
                    throw new ApiBusinessException(1012, "No se pudo crear el plan", System.Net.HttpStatusCode.NotFound, "Http");
                }
            }
            catch (Exception ex)
            {
                throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex);
            }
        }