示例#1
0
        public async Task <InstructorModel> ObtenerPorId(Guid id)
        {
            var             storeProcedure = "usp_Instructor_Obtener_Por_Id";
            InstructorModel instructor     = null;

            try
            {
                var connection = _factoryConnection.GetConnection();
                instructor = await connection.QueryFirstAsync <InstructorModel>(
                    storeProcedure,
                    new
                {
                    InstructorId = id
                },
                    commandType : CommandType.StoredProcedure
                    );

                _factoryConnection.CloseConnection();
                return(instructor);
            }
            catch (Exception e)
            {
                throw new Exception("No se pudo encontrar el instructor", e);
            }
        }
示例#2
0
        public async Task <int> NuevoInstructor(InstructorModel instructor)
        {
            try
            {
                var storeProcedure = "usp_instructor_nuevo";
                var connection     = _factoryConnection.GetConnection();

                var NuevoInstructor = new InstructorModel {
                    InstructorId = Guid.NewGuid(),
                    Nombre       = instructor.Nombre,
                    Apellidos    = instructor.Apellidos,
                    Titulo       = instructor.Titulo,
                };

                var result = await connection.ExecuteAsync(storeProcedure, NuevoInstructor, commandType :  CommandType.StoredProcedure);

                _factoryConnection.CloseConnection();

                return(result);
            }
            catch (Exception e)
            {
                throw new Exception("No se pudo guardar el nuevo instructor", e);
            }
        }
示例#3
0
        public async Task <InstructorModel> ObtenerPorId(Guid Id)
        {
            InstructorModel instructor = null;

            var storeProcedure = "usp_obtener_Instructor_Id";

            try
            {
                var connexion = this.factoriConexion.GetConnection();
                instructor = await connexion.QueryFirstAsync <InstructorModel> (storeProcedure
                                                                                , new
                {
                    InstructorId = Id,
                }, commandType : CommandType.StoredProcedure);
            }
            catch (Exception e)
            {
                throw new Exception("Error en la consulta de datos", e);
            }
            finally
            {
                this.factoriConexion.CloseConexion();
            }

            return(instructor);
        }
示例#4
0
        public async Task <int> Nuevo(InstructorModel parametros)
        {
            var storeProcedure = "usp_instructor_nuevo";

            try
            {
                var connection = factoryConnection.GetDbConnection();
                var resultado  = await connection.ExecuteAsync(storeProcedure,
                                                               new
                {
                    InstructorId = Guid.NewGuid(),
                    Nombre       = parametros.Nombre,
                    Apellidos    = parametros.Apellidos,
                    Grado        = parametros.Grado
                },
                                                               commandType : CommandType.StoredProcedure);

                factoryConnection.CloseConnection();
                return(resultado);
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo ingresar el nuevo instructor: ", ex);
            }
        }
        public async Task <InstructorModel> ObtenerPorId(int id)
        {
            var             storeProcedure = "buscarInstructor";
            InstructorModel instructor     = null;

            try
            {
                var connection = _factoryConnection.GetConnection();

                instructor = await connection.QueryFirstAsync <InstructorModel>(storeProcedure,
                                                                                new
                {
                    _idInstructor = id
                },
                                                                                commandType : CommandType.StoredProcedure);

                _factoryConnection.CloseConnection();
            }
            catch (Exception ex)
            {
                throw new Exception("{No se encontró el dato } ", ex);
            }
            finally
            {
                _factoryConnection.CloseConnection();
            }
            return(instructor);
        }
示例#6
0
        public async Task <InstructorModel> ObtenerPorId(Guid id)
        {
            var storeProcedure = "usp_obtener_instructor_por_id";
            // InstructorModel a devolver como resultado de la busqueda
            InstructorModel instructor = null;

            try
            {
                var connection = this._factoryConnection.GetConnection();
                // buscar el instructor con ID coincidente
                instructor = await connection.QueryFirstAsync <InstructorModel>(
                    storeProcedure, new
                {
                    Id = id
                },
                    commandType : CommandType.StoredProcedure);

                // cerrar la conexion y devolver el resultado obtenido del intento de almacenamiento
                this._factoryConnection.CloseConnection();
                return(instructor);
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo encontrar el Instructor - procedimiento almacenado OBTENER POR ID - ", ex);
            }
        }
示例#7
0
        public async Task <int> Actualizar(InstructorModel instructor)
        {
            var storeProcedure = "usp_instructor_editar";

            try
            {
                var connection = _factoryConnection.GetConnection();
                var result     = await connection.ExecuteAsync(storeProcedure, instructor, commandType :  CommandType.StoredProcedure);

                _factoryConnection.CloseConnection();

                return(result);
            }
            catch (Exception e)
            {
                throw new Exception("No se pudo editar el  instructor", e);
            }
        }
示例#8
0
        public async Task <int> Actualizar(InstructorModel datos)
        {
            var UserStoredProcedure = "usp_Instructor_Editar";

            try
            {
                var connection = factoryConnection.GetConnection();
                var resultado  = await connection.ExecuteAsync(UserStoredProcedure, datos, commandType : CommandType.StoredProcedure);

                return(resultado);
            }
            catch (Exception e)
            {
                throw new Exception("Error en la actualización de instructor desde USp", e);
            }
            finally
            {
                factoryConnection.CloseConnection();
            }
        }
示例#9
0
        public async Task <InstructorModel> ObtenerPorId(Guid id)
        {
            var storedProcedura = "usp_Instructor_Obtener_PorId";

            try
            {
                var             connection = factoryConnection.GetConnection();
                var             param      = new { Id = id };
                InstructorModel instructor = await connection.QueryFirstAsync <InstructorModel>(storedProcedura, param, commandType : CommandType.StoredProcedure);

                return(instructor);
            }
            catch (Exception e)
            {
                throw new Exception("Error en la consulta de Instructor por Id", e);
            }
            finally
            {
                factoryConnection.CloseConnection();
            }
        }
示例#10
0
        public async Task <InstructorModel> ObtenerPorId(Guid id)
        {
            var storeProcedure = "usp_instructor_obtenerid";

            try{
                var             connection = factoryConnection.GetDbConnection();
                InstructorModel instructor = null;
                instructor = await connection.QueryFirstAsync <InstructorModel>(storeProcedure,
                                                                                new {
                    InstructorId = id
                },
                                                                                commandType : CommandType.StoredProcedure
                                                                                );

                factoryConnection.CloseConnection();
                return(instructor);
            }catch (Exception e)
            {
                throw new Exception("error al consultar el instructor: ", e);
            }
        }
示例#11
0
        public async Task <InstructorModel> ObtenerPorId(Guid id)
        {
            InstructorModel instructor      = null;
            var             storedProcedure = "usp_obtener_instructores_porId";

            try
            {
                var connection = this.factoryConnection.GetConnection();
                instructor = await connection.QueryFirstAsync <InstructorModel>(
                    storedProcedure,
                    new { InstructorId = id },
                    commandType : CommandType.StoredProcedure);

                factoryConnection.CloseConnection();

                return(instructor);
            }
            catch (Exception e)
            {
                throw new Exception("Error en la consulta", e);
            }
        }
        public async Task <InstructorModel> ObtenerPorId(Guid id)
        {
            var             storeProcedure = "usp_Obtener_Instructor_Id";
            InstructorModel instructor     = null;

            try
            {
                var connection = _factoryConnection.GetConnection();
                //mapear el tipo
                instructor = await connection.QueryFirstAsync <InstructorModel>(
                    storeProcedure,
                    new {
                    Id = id
                },
                    commandType : CommandType.StoredProcedure
                    );

                return(instructor);
            }
            catch (Exception e)
            {
                throw new Exception("Error en la consulta", e);
            }
        }
示例#13
0
        public async Task <int> Actualiza(InstructorModel parametros)
        {
            var storeProcedure = "usp_instructor_editar";

            try{
                var connection = factoryConnection.GetDbConnection();
                var resultado  = await connection.ExecuteAsync(storeProcedure,
                                                               new {
                    InstructorId = parametros.InstructorId,
                    Nombre       = parametros.Nombre,
                    Apellidos    = parametros.Apellidos,
                    Grado        = parametros.Grado
                },
                                                               commandType : CommandType.StoredProcedure
                                                               );

                factoryConnection.CloseConnection();
                return(resultado);
            }
            catch (Exception e)
            {
                throw new Exception("Error al editar: ", e);
            }
        }
示例#14
0
 public Task <int> Nuevo(InstructorModel parametros)
 {
     throw new NotImplementedException();
 }