Example #1
0
        public async Task <InstructorModel> GetForId(Guid Id)
        {
            InstructorModel instructor     = null;
            var             storeProcedure = "usp_instructor_id";

            try{
                var connection = _factoryConnection.GetConnection();
                instructor = await connection.QueryFirstAsync <InstructorModel>(
                    storeProcedure,
                    new {
                    InstructorId = Id
                },
                    commandType : CommandType.StoredProcedure
                    );
            }catch (Exception e) {
                throw new Exception("No se encontro el instructor", e);
            }finally{
                _factoryConnection.CloseConnection();
            }
            return(instructor);
        }
Example #2
0
        public async Task <InstructorModel> ObtainById(Guid id)
        {
            var             storeProcedure = "usp_obtain_instructor_by_id";
            InstructorModel instructor     = null;

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

                _factoryConnection.CloseConexion();

                return(instructor);
            }catch (Exception ex) {
                throw new Exception("Something wrong, dont found instructor", ex);
            }
        }